diff options
Diffstat (limited to 'include/linux/rmap.h')
| -rw-r--r-- | include/linux/rmap.h | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/include/linux/rmap.h b/include/linux/rmap.h index 77216742c178..31b2fd75dcba 100644 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | */ | 26 | */ |
| 27 | struct anon_vma { | 27 | struct anon_vma { |
| 28 | spinlock_t lock; /* Serialize access to vma list */ | 28 | spinlock_t lock; /* Serialize access to vma list */ |
| 29 | struct anon_vma *root; /* Root of this anon_vma tree */ | ||
| 29 | #if defined(CONFIG_KSM) || defined(CONFIG_MIGRATION) | 30 | #if defined(CONFIG_KSM) || defined(CONFIG_MIGRATION) |
| 30 | 31 | ||
| 31 | /* | 32 | /* |
| @@ -80,6 +81,13 @@ static inline int anonvma_external_refcount(struct anon_vma *anon_vma) | |||
| 80 | { | 81 | { |
| 81 | return atomic_read(&anon_vma->external_refcount); | 82 | return atomic_read(&anon_vma->external_refcount); |
| 82 | } | 83 | } |
| 84 | |||
| 85 | static inline void get_anon_vma(struct anon_vma *anon_vma) | ||
| 86 | { | ||
| 87 | atomic_inc(&anon_vma->external_refcount); | ||
| 88 | } | ||
| 89 | |||
| 90 | void drop_anon_vma(struct anon_vma *); | ||
| 83 | #else | 91 | #else |
| 84 | static inline void anonvma_external_refcount_init(struct anon_vma *anon_vma) | 92 | static inline void anonvma_external_refcount_init(struct anon_vma *anon_vma) |
| 85 | { | 93 | { |
| @@ -89,6 +97,14 @@ static inline int anonvma_external_refcount(struct anon_vma *anon_vma) | |||
| 89 | { | 97 | { |
| 90 | return 0; | 98 | return 0; |
| 91 | } | 99 | } |
| 100 | |||
| 101 | static inline void get_anon_vma(struct anon_vma *anon_vma) | ||
| 102 | { | ||
| 103 | } | ||
| 104 | |||
| 105 | static inline void drop_anon_vma(struct anon_vma *anon_vma) | ||
| 106 | { | ||
| 107 | } | ||
| 92 | #endif /* CONFIG_KSM */ | 108 | #endif /* CONFIG_KSM */ |
| 93 | 109 | ||
| 94 | static inline struct anon_vma *page_anon_vma(struct page *page) | 110 | static inline struct anon_vma *page_anon_vma(struct page *page) |
| @@ -99,18 +115,28 @@ static inline struct anon_vma *page_anon_vma(struct page *page) | |||
| 99 | return page_rmapping(page); | 115 | return page_rmapping(page); |
| 100 | } | 116 | } |
| 101 | 117 | ||
| 102 | static inline void anon_vma_lock(struct vm_area_struct *vma) | 118 | static inline void vma_lock_anon_vma(struct vm_area_struct *vma) |
| 103 | { | 119 | { |
| 104 | struct anon_vma *anon_vma = vma->anon_vma; | 120 | struct anon_vma *anon_vma = vma->anon_vma; |
| 105 | if (anon_vma) | 121 | if (anon_vma) |
| 106 | spin_lock(&anon_vma->lock); | 122 | spin_lock(&anon_vma->root->lock); |
| 107 | } | 123 | } |
| 108 | 124 | ||
| 109 | static inline void anon_vma_unlock(struct vm_area_struct *vma) | 125 | static inline void vma_unlock_anon_vma(struct vm_area_struct *vma) |
| 110 | { | 126 | { |
| 111 | struct anon_vma *anon_vma = vma->anon_vma; | 127 | struct anon_vma *anon_vma = vma->anon_vma; |
| 112 | if (anon_vma) | 128 | if (anon_vma) |
| 113 | spin_unlock(&anon_vma->lock); | 129 | spin_unlock(&anon_vma->root->lock); |
| 130 | } | ||
| 131 | |||
| 132 | static inline void anon_vma_lock(struct anon_vma *anon_vma) | ||
| 133 | { | ||
| 134 | spin_lock(&anon_vma->root->lock); | ||
| 135 | } | ||
| 136 | |||
| 137 | static inline void anon_vma_unlock(struct anon_vma *anon_vma) | ||
| 138 | { | ||
| 139 | spin_unlock(&anon_vma->root->lock); | ||
| 114 | } | 140 | } |
| 115 | 141 | ||
| 116 | /* | 142 | /* |
| @@ -136,10 +162,17 @@ static inline void anon_vma_merge(struct vm_area_struct *vma, | |||
| 136 | */ | 162 | */ |
| 137 | void page_move_anon_rmap(struct page *, struct vm_area_struct *, unsigned long); | 163 | void page_move_anon_rmap(struct page *, struct vm_area_struct *, unsigned long); |
| 138 | void page_add_anon_rmap(struct page *, struct vm_area_struct *, unsigned long); | 164 | void page_add_anon_rmap(struct page *, struct vm_area_struct *, unsigned long); |
| 165 | void do_page_add_anon_rmap(struct page *, struct vm_area_struct *, | ||
| 166 | unsigned long, int); | ||
| 139 | void page_add_new_anon_rmap(struct page *, struct vm_area_struct *, unsigned long); | 167 | void page_add_new_anon_rmap(struct page *, struct vm_area_struct *, unsigned long); |
| 140 | void page_add_file_rmap(struct page *); | 168 | void page_add_file_rmap(struct page *); |
| 141 | void page_remove_rmap(struct page *); | 169 | void page_remove_rmap(struct page *); |
| 142 | 170 | ||
| 171 | void hugepage_add_anon_rmap(struct page *, struct vm_area_struct *, | ||
| 172 | unsigned long); | ||
| 173 | void hugepage_add_new_anon_rmap(struct page *, struct vm_area_struct *, | ||
| 174 | unsigned long); | ||
| 175 | |||
| 143 | static inline void page_dup_rmap(struct page *page) | 176 | static inline void page_dup_rmap(struct page *page) |
| 144 | { | 177 | { |
| 145 | atomic_inc(&page->_mapcount); | 178 | atomic_inc(&page->_mapcount); |
