linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mm: cleanup some useless code
@ 2019-12-10 16:04 chengkaitao
  2019-12-10 21:04 ` Chris Down
  0 siblings, 1 reply; 2+ messages in thread
From: chengkaitao @ 2019-12-10 16:04 UTC (permalink / raw)
  To: hannes
  Cc: mhocko, vdavydov.dev, akpm, cgroups, linux-mm, linux-kernel,
	smuchun, Kaitao Cheng, Michal Hocko

From: Kaitao Cheng <pilgrimtao@gmail.com>

Compound pages handling in mem_cgroup_migrate is more convoluted than
necessary. The state is duplicated in compound variable and the same
could be achieved by PageTransHuge check which is trivial and
hpage_nr_pages is already PageTransHuge aware.

It is much simpler to just use hpage_nr_pages for nr_pages and replace
the local variable by PageTransHuge check directly

Signed-off-by: Kaitao Cheng <pilgrimtao@gmail.com>
Acked-by: Michal Hocko <mhocko@suse.com>
---
Change in v2:
	Update commit message

 mm/memcontrol.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index bc01423277c5..870284d3ee9d 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -6678,7 +6678,6 @@ void mem_cgroup_migrate(struct page *oldpage, struct page *newpage)
 {
 	struct mem_cgroup *memcg;
 	unsigned int nr_pages;
-	bool compound;
 	unsigned long flags;
 
 	VM_BUG_ON_PAGE(!PageLocked(oldpage), oldpage);
@@ -6700,8 +6699,7 @@ void mem_cgroup_migrate(struct page *oldpage, struct page *newpage)
 		return;
 
 	/* Force-charge the new page. The old one will be freed soon */
-	compound = PageTransHuge(newpage);
-	nr_pages = compound ? hpage_nr_pages(newpage) : 1;
+	nr_pages = hpage_nr_pages(newpage);
 
 	page_counter_charge(&memcg->memory, nr_pages);
 	if (do_memsw_account())
@@ -6711,7 +6709,8 @@ void mem_cgroup_migrate(struct page *oldpage, struct page *newpage)
 	commit_charge(newpage, memcg, false);
 
 	local_irq_save(flags);
-	mem_cgroup_charge_statistics(memcg, newpage, compound, nr_pages);
+	mem_cgroup_charge_statistics(memcg, newpage, PageTransHuge(newpage),
+			nr_pages);
 	memcg_check_events(memcg, newpage);
 	local_irq_restore(flags);
 }
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] mm: cleanup some useless code
  2019-12-10 16:04 [PATCH v2] mm: cleanup some useless code chengkaitao
@ 2019-12-10 21:04 ` Chris Down
  0 siblings, 0 replies; 2+ messages in thread
From: Chris Down @ 2019-12-10 21:04 UTC (permalink / raw)
  To: chengkaitao
  Cc: hannes, mhocko, vdavydov.dev, akpm, cgroups, linux-mm,
	linux-kernel, smuchun, Michal Hocko

chengkaitao writes:
>Subject: Re: [PATCH v2] mm: cleanup some useless code

Can you please write a more descriptive commit title? Seeing this in the commit 
history tells the reader nothing, "code" could mean anything from a state 
machine to a boolean, and "cleanup" could mean anything from some complex 
refactoring to something trivial like this, and right now I have to look and 
see the individual commit. This patch is really just deduplication of effort.

Perhaps:

     mm, memcg: Don't check PageTransHuge before calling hpage_nr_pages

>It is much simpler to just use hpage_nr_pages for nr_pages and replace
>the local variable by PageTransHuge check directly

Heh, calling it "much" simpler seems a bit excessive. I mean, the code is just 
as readable in both cases, but if it's going to go in, then that's fine. Any 
merge conflict should be trivial enough to fix.

>Signed-off-by: Kaitao Cheng <pilgrimtao@gmail.com>
>Acked-by: Michal Hocko <mhocko@suse.com>

I'm indifferent to this patch, but after the title change:

Acked-by: Chris Down <chris@chrisdown.name>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-12-10 21:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-10 16:04 [PATCH v2] mm: cleanup some useless code chengkaitao
2019-12-10 21:04 ` Chris Down

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).