linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/memcg: minor cleanup for mc_handle_present_pte()
@ 2023-07-17 11:36 Miaohe Lin
  0 siblings, 0 replies; only message in thread
From: Miaohe Lin @ 2023-07-17 11:36 UTC (permalink / raw)
  To: akpm, hannes, mhocko, roman.gushchin, shakeelb
  Cc: muchun.song, linux-mm, cgroups, linux-kernel, linmiaohe

When pagetable lock is held, the page will always be page_mapped(). So
remove unneeded page_mapped() check. Also the page can't be freed from
under us in this case. So use get_page() to get extra page reference to
simplify the code. No functional change intended.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/memcontrol.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 284396ea8a33..60b5ff3b4a52 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5649,7 +5649,7 @@ static struct page *mc_handle_present_pte(struct vm_area_struct *vma,
 {
 	struct page *page = vm_normal_page(vma, addr, ptent);
 
-	if (!page || !page_mapped(page))
+	if (!page)
 		return NULL;
 	if (PageAnon(page)) {
 		if (!(mc.flags & MOVE_ANON))
@@ -5658,8 +5658,7 @@ static struct page *mc_handle_present_pte(struct vm_area_struct *vma,
 		if (!(mc.flags & MOVE_FILE))
 			return NULL;
 	}
-	if (!get_page_unless_zero(page))
-		return NULL;
+	get_page(page);
 
 	return page;
 }
-- 
2.33.0



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-07-17 11:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-17 11:36 [PATCH] mm/memcg: minor cleanup for mc_handle_present_pte() Miaohe Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox