History

mm/rmap: Constify the rmap_walk_control argument

The rmap walking functions do not modify the rmap_walk_control, and page_idle_clear_pte_refs() takes advantage of that to move construction of the rmap_walk_control to compile time. This lets us remove an unclean cast.

Matthew Wilcox (Oracle) committed 4 years ago

Commit 84fbbe21 parent 2f031c65 files · +13 −13Browse files

Unified · Split

5 files
  1. include/linux/ksm.h +2 −2
  2. include/linux/rmap.h +2 −2
  3. mm/ksm.c +1 −1
  4. mm/page_idle.c +1 −1
  5. mm/rmap.c +7 −7
include/linux/ksm.h+2−2
@@ -51,7 +51,7 @@ static inline void ksm_exit(struct mm_struct *mm) · 50 unmodified lines
51struct page *ksm_might_need_to_copy(struct page *page,51struct page *ksm_might_need_to_copy(struct page *page,
52 struct vm_area_struct *vma, unsigned long address);52 struct vm_area_struct *vma, unsigned long address);
53 53
54void rmap_walk_ksm(struct folio *folio, struct rmap_walk_control *rwc);54void rmap_walk_ksm(struct folio *folio, const struct rmap_walk_control *rwc);
55void folio_migrate_ksm(struct folio *newfolio, struct folio *folio);55void folio_migrate_ksm(struct folio *newfolio, struct folio *folio);
56 56
57#else /* !CONFIG_KSM */57#else /* !CONFIG_KSM */
@@ -79,7 +79,7 @@ static inline struct page *ksm_might_need_to_copy(struct page *page, · 21 unmodified lines
79}79}
80 80
81static inline void rmap_walk_ksm(struct folio *folio,81static inline void rmap_walk_ksm(struct folio *folio,
82 struct rmap_walk_control *rwc)82 const struct rmap_walk_control *rwc)
83{83{
84}84}
85 85
include/linux/rmap.h+2−2
@@ -292,8 +292,8 @@ struct rmap_walk_control { · 291 unmodified lines
292 bool (*invalid_vma)(struct vm_area_struct *vma, void *arg);292 bool (*invalid_vma)(struct vm_area_struct *vma, void *arg);
293};293};
294 294
295void rmap_walk(struct folio *folio, struct rmap_walk_control *rwc);295void rmap_walk(struct folio *folio, const struct rmap_walk_control *rwc);
296void rmap_walk_locked(struct folio *folio, struct rmap_walk_control *rwc);296void rmap_walk_locked(struct folio *folio, const struct rmap_walk_control *rwc);
297 297
298#else /* !CONFIG_MMU */298#else /* !CONFIG_MMU */
299 299
mm/ksm.c+1−1
@@ -2588,7 +2588,7 @@ struct page *ksm_might_need_to_copy(struct page *page, · 2587 unmodified lines
2588 return new_page;2588 return new_page;
2589}2589}
2590 2590
2591void rmap_walk_ksm(struct folio *folio, struct rmap_walk_control *rwc)2591void rmap_walk_ksm(struct folio *folio, const struct rmap_walk_control *rwc)
2592{2592{
2593 struct stable_node *stable_node;2593 struct stable_node *stable_node;
2594 struct rmap_item *rmap_item;2594 struct rmap_item *rmap_item;
mm/page_idle.c+1−1
@@ -103,7 +103,7 @@ static void page_idle_clear_pte_refs(struct page *page) · 102 unmodified lines
103 if (need_lock && !folio_trylock(folio))103 if (need_lock && !folio_trylock(folio))
104 return;104 return;
105 105
106 rmap_walk(folio, (struct rmap_walk_control *)&rwc);106 rmap_walk(folio, &rwc);
107 107
108 if (need_lock)108 if (need_lock)
109 folio_unlock(folio);109 folio_unlock(folio);
mm/rmap.c+7−7
@@ -2173,7 +2173,7 @@ void __put_anon_vma(struct anon_vma *anon_vma) · 2172 unmodified lines
2173}2173}
2174 2174
2175static struct anon_vma *rmap_walk_anon_lock(struct folio *folio,2175static struct anon_vma *rmap_walk_anon_lock(struct folio *folio,
2176 struct rmap_walk_control *rwc)2176 const struct rmap_walk_control *rwc)
2177{2177{
2178 struct anon_vma *anon_vma;2178 struct anon_vma *anon_vma;
2179 2179
@@ -2203,8 +2203,8 @@ static struct anon_vma *rmap_walk_anon_lock(struct folio *folio, · 23 unmodified lines
2203 * Find all the mappings of a page using the mapping pointer and the vma chains2203 * Find all the mappings of a page using the mapping pointer and the vma chains
2204 * contained in the anon_vma struct it points to.2204 * contained in the anon_vma struct it points to.
2205 */2205 */
2206static void rmap_walk_anon(struct folio *folio, struct rmap_walk_control *rwc,2206static void rmap_walk_anon(struct folio *folio,
2207 bool locked)2207 const struct rmap_walk_control *rwc, bool locked)
2208{2208{
2209 struct anon_vma *anon_vma;2209 struct anon_vma *anon_vma;
2210 pgoff_t pgoff_start, pgoff_end;2210 pgoff_t pgoff_start, pgoff_end;
@@ -2251,8 +2251,8 @@ static void rmap_walk_anon(struct folio *folio, struct rmap_walk_control *rwc, · 40 unmodified lines
2251 * Find all the mappings of a page using the mapping pointer and the vma chains2251 * Find all the mappings of a page using the mapping pointer and the vma chains
2252 * contained in the address_space struct it points to.2252 * contained in the address_space struct it points to.
2253 */2253 */
2254static void rmap_walk_file(struct folio *folio, struct rmap_walk_control *rwc,2254static void rmap_walk_file(struct folio *folio,
2255 bool locked)2255 const struct rmap_walk_control *rwc, bool locked)
2256{2256{
2257 struct address_space *mapping = folio_mapping(folio);2257 struct address_space *mapping = folio_mapping(folio);
2258 pgoff_t pgoff_start, pgoff_end;2258 pgoff_t pgoff_start, pgoff_end;
@@ -2294,7 +2294,7 @@ done: · 35 unmodified lines
2294 i_mmap_unlock_read(mapping);2294 i_mmap_unlock_read(mapping);
2295}2295}
2296 2296
2297void rmap_walk(struct folio *folio, struct rmap_walk_control *rwc)2297void rmap_walk(struct folio *folio, const struct rmap_walk_control *rwc)
2298{2298{
2299 if (unlikely(folio_test_ksm(folio)))2299 if (unlikely(folio_test_ksm(folio)))
2300 rmap_walk_ksm(folio, rwc);2300 rmap_walk_ksm(folio, rwc);
@@ -2305,7 +2305,7 @@ void rmap_walk(struct folio *folio, struct rmap_walk_control *rwc) · 4 unmodified lines
2305}2305}
2306 2306
2307/* Like rmap_walk, but caller holds relevant rmap lock */2307/* Like rmap_walk, but caller holds relevant rmap lock */
2308void rmap_walk_locked(struct folio *folio, struct rmap_walk_control *rwc)2308void rmap_walk_locked(struct folio *folio, const struct rmap_walk_control *rwc)
2309{2309{
2310 /* no ksm support for now */2310 /* no ksm support for now */
2311 VM_BUG_ON_FOLIO(folio_test_ksm(folio), folio);2311 VM_BUG_ON_FOLIO(folio_test_ksm(folio), folio);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t