|
4 | 4 |
|
5 | 5 | #include <linux/huge_mm.h> |
6 | 6 | #include <linux/swap.h> |
| 7 | +#include <linux/string.h> |
7 | 8 |
|
8 | 9 | /** |
9 | 10 | * folio_is_file_lru - Should the folio be on a file LRU or anon LRU? |
@@ -135,4 +136,53 @@ static __always_inline void del_page_from_lru_list(struct page *page, |
135 | 136 | { |
136 | 137 | lruvec_del_folio(lruvec, page_folio(page)); |
137 | 138 | } |
| 139 | + |
| 140 | +#ifdef CONFIG_ANON_VMA_NAME |
| 141 | +/* |
| 142 | + * mmap_lock should be read-locked when calling vma_anon_name() and while using |
| 143 | + * the returned pointer. |
| 144 | + */ |
| 145 | +extern const char *vma_anon_name(struct vm_area_struct *vma); |
| 146 | + |
| 147 | +/* |
| 148 | + * mmap_lock should be read-locked for orig_vma->vm_mm. |
| 149 | + * mmap_lock should be write-locked for new_vma->vm_mm or new_vma should be |
| 150 | + * isolated. |
| 151 | + */ |
| 152 | +extern void dup_vma_anon_name(struct vm_area_struct *orig_vma, |
| 153 | + struct vm_area_struct *new_vma); |
| 154 | + |
| 155 | +/* |
| 156 | + * mmap_lock should be write-locked or vma should have been isolated under |
| 157 | + * write-locked mmap_lock protection. |
| 158 | + */ |
| 159 | +extern void free_vma_anon_name(struct vm_area_struct *vma); |
| 160 | + |
| 161 | +/* mmap_lock should be read-locked */ |
| 162 | +static inline bool is_same_vma_anon_name(struct vm_area_struct *vma, |
| 163 | + const char *name) |
| 164 | +{ |
| 165 | + const char *vma_name = vma_anon_name(vma); |
| 166 | + |
| 167 | + /* either both NULL, or pointers to same string */ |
| 168 | + if (vma_name == name) |
| 169 | + return true; |
| 170 | + |
| 171 | + return name && vma_name && !strcmp(name, vma_name); |
| 172 | +} |
| 173 | +#else /* CONFIG_ANON_VMA_NAME */ |
| 174 | +static inline const char *vma_anon_name(struct vm_area_struct *vma) |
| 175 | +{ |
| 176 | + return NULL; |
| 177 | +} |
| 178 | +static inline void dup_vma_anon_name(struct vm_area_struct *orig_vma, |
| 179 | + struct vm_area_struct *new_vma) {} |
| 180 | +static inline void free_vma_anon_name(struct vm_area_struct *vma) {} |
| 181 | +static inline bool is_same_vma_anon_name(struct vm_area_struct *vma, |
| 182 | + const char *name) |
| 183 | +{ |
| 184 | + return true; |
| 185 | +} |
| 186 | +#endif /* CONFIG_ANON_VMA_NAME */ |
| 187 | + |
138 | 188 | #endif |
0 commit comments