~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/ksm.h

Version: ~ [ linux-5.3-rc5 ] ~ [ linux-5.2.9 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.67 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.139 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.189 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.189 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.72 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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/pagemap.h>
 13 #include <linux/rmap.h>
 14 #include <linux/sched.h>
 15 #include <linux/sched/coredump.h>
 16 
 17 struct stable_node;
 18 struct mem_cgroup;
 19 
 20 #ifdef CONFIG_KSM
 21 int ksm_madvise(struct vm_area_struct *vma, unsigned long start,
 22                 unsigned long end, int advice, unsigned long *vm_flags);
 23 int __ksm_enter(struct mm_struct *mm);
 24 void __ksm_exit(struct mm_struct *mm);
 25 
 26 static inline int ksm_fork(struct mm_struct *mm, struct mm_struct *oldmm)
 27 {
 28         if (test_bit(MMF_VM_MERGEABLE, &oldmm->flags))
 29                 return __ksm_enter(mm);
 30         return 0;
 31 }
 32 
 33 static inline void ksm_exit(struct mm_struct *mm)
 34 {
 35         if (test_bit(MMF_VM_MERGEABLE, &mm->flags))
 36                 __ksm_exit(mm);
 37 }
 38 
 39 static inline struct stable_node *page_stable_node(struct page *page)
 40 {
 41         return PageKsm(page) ? page_rmapping(page) : NULL;
 42 }
 43 
 44 static inline void set_page_stable_node(struct page *page,
 45                                         struct stable_node *stable_node)
 46 {
 47         page->mapping = (void *)((unsigned long)stable_node | PAGE_MAPPING_KSM);
 48 }
 49 
 50 /*
 51  * When do_swap_page() first faults in from swap what used to be a KSM page,
 52  * no problem, it will be assigned to this vma's anon_vma; but thereafter,
 53  * it might be faulted into a different anon_vma (or perhaps to a different
 54  * offset in the same anon_vma).  do_swap_page() cannot do all the locking
 55  * needed to reconstitute a cross-anon_vma KSM page: for now it has to make
 56  * a copy, and leave remerging the pages to a later pass of ksmd.
 57  *
 58  * We'd like to make this conditional on vma->vm_flags & VM_MERGEABLE,
 59  * but what if the vma was unmerged while the page was swapped out?
 60  */
 61 struct page *ksm_might_need_to_copy(struct page *page,
 62                         struct vm_area_struct *vma, unsigned long address);
 63 
 64 void rmap_walk_ksm(struct page *page, struct rmap_walk_control *rwc);
 65 void ksm_migrate_page(struct page *newpage, struct page *oldpage);
 66 
 67 #else  /* !CONFIG_KSM */
 68 
 69 static inline int ksm_fork(struct mm_struct *mm, struct mm_struct *oldmm)
 70 {
 71         return 0;
 72 }
 73 
 74 static inline void ksm_exit(struct mm_struct *mm)
 75 {
 76 }
 77 
 78 #ifdef CONFIG_MMU
 79 static 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 
 85 static 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 
 91 static inline int page_referenced_ksm(struct page *page,
 92                         struct mem_cgroup *memcg, unsigned long *vm_flags)
 93 {
 94         return 0;
 95 }
 96 
 97 static inline void rmap_walk_ksm(struct page *page,
 98                         struct rmap_walk_control *rwc)
 99 {
100 }
101 
102 static inline void ksm_migrate_page(struct page *newpage, struct page *oldpage)
103 {
104 }
105 #endif /* CONFIG_MMU */
106 #endif /* !CONFIG_KSM */
107 
108 #endif /* __LINUX_KSM_H */
109 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp