mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-17 13:58:46 +00:00
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. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
This commit is contained in:
parent
2f031c6f04
commit
84fbbe2189
@ -51,7 +51,7 @@ static inline void ksm_exit(struct mm_struct *mm)
|
|||||||
struct page *ksm_might_need_to_copy(struct page *page,
|
struct page *ksm_might_need_to_copy(struct page *page,
|
||||||
struct vm_area_struct *vma, unsigned long address);
|
struct vm_area_struct *vma, unsigned long address);
|
||||||
|
|
||||||
void rmap_walk_ksm(struct folio *folio, struct rmap_walk_control *rwc);
|
void rmap_walk_ksm(struct folio *folio, const struct rmap_walk_control *rwc);
|
||||||
void folio_migrate_ksm(struct folio *newfolio, struct folio *folio);
|
void folio_migrate_ksm(struct folio *newfolio, struct folio *folio);
|
||||||
|
|
||||||
#else /* !CONFIG_KSM */
|
#else /* !CONFIG_KSM */
|
||||||
@ -79,7 +79,7 @@ static inline struct page *ksm_might_need_to_copy(struct page *page,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline void rmap_walk_ksm(struct folio *folio,
|
static inline void rmap_walk_ksm(struct folio *folio,
|
||||||
struct rmap_walk_control *rwc)
|
const struct rmap_walk_control *rwc)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,8 +292,8 @@ struct rmap_walk_control {
|
|||||||
bool (*invalid_vma)(struct vm_area_struct *vma, void *arg);
|
bool (*invalid_vma)(struct vm_area_struct *vma, void *arg);
|
||||||
};
|
};
|
||||||
|
|
||||||
void rmap_walk(struct folio *folio, struct rmap_walk_control *rwc);
|
void rmap_walk(struct folio *folio, const struct rmap_walk_control *rwc);
|
||||||
void rmap_walk_locked(struct folio *folio, struct rmap_walk_control *rwc);
|
void rmap_walk_locked(struct folio *folio, const struct rmap_walk_control *rwc);
|
||||||
|
|
||||||
#else /* !CONFIG_MMU */
|
#else /* !CONFIG_MMU */
|
||||||
|
|
||||||
|
2
mm/ksm.c
2
mm/ksm.c
@ -2588,7 +2588,7 @@ struct page *ksm_might_need_to_copy(struct page *page,
|
|||||||
return new_page;
|
return new_page;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rmap_walk_ksm(struct folio *folio, struct rmap_walk_control *rwc)
|
void rmap_walk_ksm(struct folio *folio, const struct rmap_walk_control *rwc)
|
||||||
{
|
{
|
||||||
struct stable_node *stable_node;
|
struct stable_node *stable_node;
|
||||||
struct rmap_item *rmap_item;
|
struct rmap_item *rmap_item;
|
||||||
|
@ -103,7 +103,7 @@ static void page_idle_clear_pte_refs(struct page *page)
|
|||||||
if (need_lock && !folio_trylock(folio))
|
if (need_lock && !folio_trylock(folio))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rmap_walk(folio, (struct rmap_walk_control *)&rwc);
|
rmap_walk(folio, &rwc);
|
||||||
|
|
||||||
if (need_lock)
|
if (need_lock)
|
||||||
folio_unlock(folio);
|
folio_unlock(folio);
|
||||||
|
14
mm/rmap.c
14
mm/rmap.c
@ -2173,7 +2173,7 @@ void __put_anon_vma(struct anon_vma *anon_vma)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct anon_vma *rmap_walk_anon_lock(struct folio *folio,
|
static struct anon_vma *rmap_walk_anon_lock(struct folio *folio,
|
||||||
struct rmap_walk_control *rwc)
|
const struct rmap_walk_control *rwc)
|
||||||
{
|
{
|
||||||
struct anon_vma *anon_vma;
|
struct anon_vma *anon_vma;
|
||||||
|
|
||||||
@ -2203,8 +2203,8 @@ static struct anon_vma *rmap_walk_anon_lock(struct folio *folio,
|
|||||||
* Find all the mappings of a page using the mapping pointer and the vma chains
|
* Find all the mappings of a page using the mapping pointer and the vma chains
|
||||||
* contained in the anon_vma struct it points to.
|
* contained in the anon_vma struct it points to.
|
||||||
*/
|
*/
|
||||||
static void rmap_walk_anon(struct folio *folio, struct rmap_walk_control *rwc,
|
static void rmap_walk_anon(struct folio *folio,
|
||||||
bool locked)
|
const struct rmap_walk_control *rwc, bool locked)
|
||||||
{
|
{
|
||||||
struct anon_vma *anon_vma;
|
struct anon_vma *anon_vma;
|
||||||
pgoff_t pgoff_start, pgoff_end;
|
pgoff_t pgoff_start, pgoff_end;
|
||||||
@ -2251,8 +2251,8 @@ static void rmap_walk_anon(struct folio *folio, struct rmap_walk_control *rwc,
|
|||||||
* Find all the mappings of a page using the mapping pointer and the vma chains
|
* Find all the mappings of a page using the mapping pointer and the vma chains
|
||||||
* contained in the address_space struct it points to.
|
* contained in the address_space struct it points to.
|
||||||
*/
|
*/
|
||||||
static void rmap_walk_file(struct folio *folio, struct rmap_walk_control *rwc,
|
static void rmap_walk_file(struct folio *folio,
|
||||||
bool locked)
|
const struct rmap_walk_control *rwc, bool locked)
|
||||||
{
|
{
|
||||||
struct address_space *mapping = folio_mapping(folio);
|
struct address_space *mapping = folio_mapping(folio);
|
||||||
pgoff_t pgoff_start, pgoff_end;
|
pgoff_t pgoff_start, pgoff_end;
|
||||||
@ -2294,7 +2294,7 @@ done:
|
|||||||
i_mmap_unlock_read(mapping);
|
i_mmap_unlock_read(mapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rmap_walk(struct folio *folio, struct rmap_walk_control *rwc)
|
void rmap_walk(struct folio *folio, const struct rmap_walk_control *rwc)
|
||||||
{
|
{
|
||||||
if (unlikely(folio_test_ksm(folio)))
|
if (unlikely(folio_test_ksm(folio)))
|
||||||
rmap_walk_ksm(folio, rwc);
|
rmap_walk_ksm(folio, rwc);
|
||||||
@ -2305,7 +2305,7 @@ void rmap_walk(struct folio *folio, struct rmap_walk_control *rwc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Like rmap_walk, but caller holds relevant rmap lock */
|
/* Like rmap_walk, but caller holds relevant rmap lock */
|
||||||
void rmap_walk_locked(struct folio *folio, struct rmap_walk_control *rwc)
|
void rmap_walk_locked(struct folio *folio, const struct rmap_walk_control *rwc)
|
||||||
{
|
{
|
||||||
/* no ksm support for now */
|
/* no ksm support for now */
|
||||||
VM_BUG_ON_FOLIO(folio_test_ksm(folio), folio);
|
VM_BUG_ON_FOLIO(folio_test_ksm(folio), folio);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user