diff options
author | Matthew Wilcox (Oracle) <willy@infradead.org> | 2024-01-11 18:12:19 +0000 |
---|---|---|
committer | Andrew Morton <akpm@linux-foundation.org> | 2024-02-21 16:00:03 -0800 |
commit | f6c7590b4e05c7963f3e56a0ff07df2c520f78cd (patch) | |
tree | 8ba19d3242006994675e2bbe0dd2a5c97ae447b1 | |
parent | b67fa6e47bffd6edf417a789c7010cc32a47a41b (diff) | |
download | linux-stable-f6c7590b4e05c7963f3e56a0ff07df2c520f78cd.tar.gz linux-stable-f6c7590b4e05c7963f3e56a0ff07df2c520f78cd.tar.bz2 linux-stable-f6c7590b4e05c7963f3e56a0ff07df2c520f78cd.zip |
memcg: use a folio in get_mctgt_type_thp
Replace five calls to compound_head() with one.
Link: https://lkml.kernel.org/r/20240111181219.3462852-5-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Roman Gushchin <roman.gushchin@linux.dev>
Reviewed-by: Muchun Song <muchun.song@linux.dev>
Acked-by: Shakeel Butt <shakeelb@google.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-rw-r--r-- | mm/memcontrol.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index a5bc34d44dbd..db92401257f7 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -6194,6 +6194,7 @@ static enum mc_target_type get_mctgt_type_thp(struct vm_area_struct *vma, unsigned long addr, pmd_t pmd, union mc_target *target) { struct page *page = NULL; + struct folio *folio; enum mc_target_type ret = MC_TARGET_NONE; if (unlikely(is_swap_pmd(pmd))) { @@ -6203,17 +6204,18 @@ static enum mc_target_type get_mctgt_type_thp(struct vm_area_struct *vma, } page = pmd_page(pmd); VM_BUG_ON_PAGE(!page || !PageHead(page), page); + folio = page_folio(page); if (!(mc.flags & MOVE_ANON)) return ret; - if (page_memcg(page) == mc.from) { + if (folio_memcg(folio) == mc.from) { ret = MC_TARGET_PAGE; if (target) { - get_page(page); - if (!trylock_page(page)) { - put_page(page); + folio_get(folio); + if (!folio_trylock(folio)) { + folio_put(folio); return MC_TARGET_NONE; } - target->folio = page_folio(page); + target->folio = folio; } } return ret; |