]> git.karo-electronics.de Git - mv-sheeva.git/blob - include/linux/ksm.h
ksm: the mm interface to ksm
[mv-sheeva.git] / include / linux / ksm.h
1 #ifndef __LINUX_KSM_H
2 #define __LINUX_KSM_H
3 /*
4  * Memory merging support.
5  *
6  * This code enables dynamic sharing of identical pages found in different
7  * memory areas, even if they are not shared by fork().
8  */
9
10 #include <linux/bitops.h>
11 #include <linux/mm.h>
12 #include <linux/sched.h>
13
14 #ifdef CONFIG_KSM
15 int ksm_madvise(struct vm_area_struct *vma, unsigned long start,
16                 unsigned long end, int advice, unsigned long *vm_flags);
17 int __ksm_enter(struct mm_struct *mm);
18 void __ksm_exit(struct mm_struct *mm);
19
20 static inline int ksm_fork(struct mm_struct *mm, struct mm_struct *oldmm)
21 {
22         if (test_bit(MMF_VM_MERGEABLE, &oldmm->flags))
23                 return __ksm_enter(mm);
24         return 0;
25 }
26
27 static inline void ksm_exit(struct mm_struct *mm)
28 {
29         if (test_bit(MMF_VM_MERGEABLE, &mm->flags))
30                 __ksm_exit(mm);
31 }
32 #else  /* !CONFIG_KSM */
33
34 static inline int ksm_madvise(struct vm_area_struct *vma, unsigned long start,
35                 unsigned long end, int advice, unsigned long *vm_flags)
36 {
37         return 0;
38 }
39
40 static inline int ksm_fork(struct mm_struct *mm, struct mm_struct *oldmm)
41 {
42         return 0;
43 }
44
45 static inline void ksm_exit(struct mm_struct *mm)
46 {
47 }
48 #endif /* !CONFIG_KSM */
49
50 #endif