]> bbs.cooldavid.org Git - net-next-2.6.git/blame - include/linux/ksm.h
ksm: the mm interface to ksm
[net-next-2.6.git] / include / linux / ksm.h
CommitLineData
f8af4da3
HD
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
15int ksm_madvise(struct vm_area_struct *vma, unsigned long start,
16 unsigned long end, int advice, unsigned long *vm_flags);
17int __ksm_enter(struct mm_struct *mm);
18void __ksm_exit(struct mm_struct *mm);
19
20static 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
27static 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
34static 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
40static inline int ksm_fork(struct mm_struct *mm, struct mm_struct *oldmm)
41{
42 return 0;
43}
44
45static inline void ksm_exit(struct mm_struct *mm)
46{
47}
48#endif /* !CONFIG_KSM */
49
50#endif