linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Shengken.Lin@amlogic.com" <Shengken.Lin@amlogic.com>
To: "Matthew Wilcox" <willy@infradead.org>
Cc: akpm <akpm@linux-foundation.org>,  linux-mm <linux-mm@kvack.org>,
	 linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: Re: [PATCH] mm: Remove redundant PageMemcgKmem(page) call
Date: Thu, 20 Feb 2025 17:47:56 +0800	[thread overview]
Message-ID: <202502201747552959016@amlogic.com> (raw)
In-Reply-To: <Z6wjYQUxIstEqJHC@casper.infradead.org>

[-- Attachment #1: Type: text/plain, Size: 1073 bytes --]

On Wed, 12 Feb 2025 04:28PM +0000, Matthew Wilcox wrote:
>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.
Hi Matthew Wilcox,
If it can save a function call, then adding PageMemcgKmem(page)
in include/linux/memcontrol.h would make the code more consistent.
If this is considered more reasonable, I can submit a new patch.
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -1707,7 +1707,7 @@ static inline int memcg_kmem_charge_page(struct page *page, gfp_t gfp,
 
 static inline void memcg_kmem_uncharge_page(struct page *page, int order)
 {
-       if (memcg_kmem_online())
+       if (memcg_kmem_online() && PageMemcgKmem(page))
                __memcg_kmem_uncharge_page(page, order);
 }
--
Best regards,
Shengken Lin

[-- Attachment #2: Type: text/html, Size: 1718 bytes --]

  reply	other threads:[~2025-02-20  9:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-12  2:06 Shengken Lin
2025-02-12  4:28 ` Matthew Wilcox
2025-02-20  9:47   ` Shengken.Lin [this message]
2025-02-20 13:22     ` Matthew Wilcox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202502201747552959016@amlogic.com \
    --to=shengken.lin@amlogic.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox