1#ifndef __LINUX_KSM_H
2#define __LINUX_KSM_H
3
4
5
6
7
8
9
10#include <linux/bitops.h>
11#include <linux/mm.h>
12#include <linux/pagemap.h>
13#include <linux/rmap.h>
14#include <linux/sched.h>
15
16struct stable_node;
17struct mem_cgroup;
18
19#ifdef CONFIG_KSM
20int ksm_madvise(struct vm_area_struct *vma, unsigned long start,
21 unsigned long end, int advice, unsigned long *vm_flags);
22int __ksm_enter(struct mm_struct *mm);
23void __ksm_exit(struct mm_struct *mm);
24
25static inline int ksm_fork(struct mm_struct *mm, struct mm_struct *oldmm)
26{
27 if (test_bit(MMF_VM_MERGEABLE, &oldmm->flags))
28 return __ksm_enter(mm);
29 return 0;
30}
31
32static inline void ksm_exit(struct mm_struct *mm)
33{
34 if (test_bit(MMF_VM_MERGEABLE, &mm->flags))
35 __ksm_exit(mm);
36}
37
38static inline struct stable_node *page_stable_node(struct page *page)
39{
40 return PageKsm(page) ? page_rmapping(page) : NULL;
41}
42
43static inline void set_page_stable_node(struct page *page,
44 struct stable_node *stable_node)
45{
46 page->mapping = (void *)stable_node +
47 (PAGE_MAPPING_ANON | PAGE_MAPPING_KSM);
48}
49
50
51
52
53
54
55
56
57
58
59
60
61struct page *ksm_might_need_to_copy(struct page *page,
62 struct vm_area_struct *vma, unsigned long address);
63
64int rmap_walk_ksm(struct page *page, struct rmap_walk_control *rwc);
65void ksm_migrate_page(struct page *newpage, struct page *oldpage);
66
67#else
68
69static inline int ksm_fork(struct mm_struct *mm, struct mm_struct *oldmm)
70{
71 return 0;
72}
73
74static inline void ksm_exit(struct mm_struct *mm)
75{
76}
77
78#ifdef CONFIG_MMU
79static inline int ksm_madvise(struct vm_area_struct *vma, unsigned long start,
80 unsigned long end, int advice, unsigned long *vm_flags)
81{
82 return 0;
83}
84
85static inline struct page *ksm_might_need_to_copy(struct page *page,
86 struct vm_area_struct *vma, unsigned long address)
87{
88 return page;
89}
90
91static inline int page_referenced_ksm(struct page *page,
92 struct mem_cgroup *memcg, unsigned long *vm_flags)
93{
94 return 0;
95}
96
97static inline int rmap_walk_ksm(struct page *page,
98 struct rmap_walk_control *rwc)
99{
100 return 0;
101}
102
103static inline void ksm_migrate_page(struct page *newpage, struct page *oldpage)
104{
105}
106#endif
107#endif
108
109#endif
110