mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mm: Remove redundant PageMemcgKmem(page) call
@ 2025-02-12  2:06 Shengken Lin
  2025-02-12  4:28 ` Matthew Wilcox
  0 siblings, 1 reply; 3+ messages in thread
From: Shengken Lin @ 2025-02-12  2:06 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, Shengken Lin

The function of PageMemcgKmem(page) is the same as that of
folio_memcg_kmem(folio).

Since __memcg_kmem_uncharge_page already uses folio_memcg_kmem to check
if a folio has been uncharged, calling PageMemcgKmem(page) before
__memcg_kmem_uncharge_page is redundant.

Signed-off-by: Shengken Lin <shengken.lin@amlogic.com>
---
 mm/page_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 579789600a3c..5a76760de495 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1055,7 +1055,7 @@ __always_inline bool free_pages_prepare(struct page *page,
 	trace_mm_page_free(page, order);
 	kmsan_free_page(page, order);

-	if (memcg_kmem_online() && PageMemcgKmem(page))
+	if (memcg_kmem_online())
 		__memcg_kmem_uncharge_page(page, order);

 	/*
--
2.34.1


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

* Re: [PATCH] mm: Remove redundant PageMemcgKmem(page) call
  2025-02-12  2:06 [PATCH] mm: Remove redundant PageMemcgKmem(page) call Shengken Lin
@ 2025-02-12  4:28 ` Matthew Wilcox
       [not found]   ` <202502201747552959016@amlogic.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Matthew Wilcox @ 2025-02-12  4:28 UTC (permalink / raw)
  To: Shengken Lin; +Cc: akpm, linux-mm, linux-kernel

On Wed, Feb 12, 2025 at 10:06:27AM +0800, Shengken Lin wrote:
> The function of PageMemcgKmem(page) is the same as that of
> folio_memcg_kmem(folio).
> 
> Since __memcg_kmem_uncharge_page already uses folio_memcg_kmem to check
> if a folio has been uncharged, calling PageMemcgKmem(page) before
> __memcg_kmem_uncharge_page is redundant.

But it saves a function call.  NAK.

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

* Re: Re: [PATCH] mm: Remove redundant PageMemcgKmem(page) call
       [not found]   ` <202502201747552959016@amlogic.com>
@ 2025-02-20 13:22     ` Matthew Wilcox
  0 siblings, 0 replies; 3+ messages in thread
From: Matthew Wilcox @ 2025-02-20 13:22 UTC (permalink / raw)
  To: Shengken.Lin; +Cc: akpm, linux-mm, linux-kernel

On Thu, Feb 20, 2025 at 05:47:56PM +0800, Shengken.Lin@amlogic.com wrote:
> If it can save a function call, then adding PageMemcgKmem(page)
> in include/linux/memcontrol.h would make the code more consistent.

The code is fine the way it is.

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

end of thread, other threads:[~2025-02-20 13:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-12  2:06 [PATCH] mm: Remove redundant PageMemcgKmem(page) call Shengken Lin
2025-02-12  4:28 ` Matthew Wilcox
     [not found]   ` <202502201747552959016@amlogic.com>
2025-02-20 13:22     ` Matthew Wilcox

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

all inboxes | Powered by JetHome®