Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Barry Song (Xiaomi)" <baohua@kernel.org>
To: david@kernel.org, akpm@linux-foundation.org
Cc: baohua@kernel.org, baoquan.he@linux.dev, chrisl@kernel.org,
	jp.kobryn@linux.dev, liam@infradead.org,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org, ljs@kernel.org,
	mhocko@suse.com, nphamcs@gmail.com, rppt@kernel.org,
	ryncsn@gmail.com, shakeel.butt@linux.dev,
	shikemeng@huaweicloud.com, surenb@google.com,
	usama.arif@linux.dev, vbabka@kernel.org, youngjun.park@lge.com
Subject: Re: [PATCH v3 1/4] mm: avoid unnecessary lru drain for wp_can_reuse_anon_folio()
Date: Wed,  8 Jul 2026 22:57:18 +0800	[thread overview]
Message-ID: <20260708145718.82690-1-baohua@kernel.org> (raw)
In-Reply-To: <793fe8b9-f5f5-4458-9150-5edbabde44e7@kernel.org>

On Tue, Jul 7, 2026 at 11:58 PM David Hildenbrand (Arm) <david@kernel.org> wrote:
>
> On 7/7/26 17:26, Kairui Song wrote:
> > On Mon, Jul 6, 2026 at 4:54 PM Barry Song <baohua@kernel.org> wrote:
> >>
> >> On Thu, Jul 2, 2026 at 4:05 PM David Hildenbrand (Arm) <david@kernel.org> wrote:
> >>>
> >>> The other folks should probably re-review this patch that changed quite a bit :)
> >>>
> >>>
> >>> Acked-by: David Hildenbrand (Arm) <david@kernel.org>
> >>
> >> Thanks!
> >>
> >> Hi Baoquan, Shakeel, and Kairui,
> >>
> >> Would you like to re-review the patches so I can re-collect your
> >> tags? If not, are you okay with me removing your tags when I
> >> send v4?
> >
> > Sure, no problem.
> >
> > The only complain from me, and a trivial one is that `in_lru_cache =
> > !folio_test_lru(folio)` looks a bit odd.
>
> I was debating with myself a bit, how to keep it short yet expressive.
>
> "maybe_in_lru_cache" could work.

yes. sounds very good to me. Thanks, Kairui and David.

Hi Andrew,

Would you like to squash the below change?


From 4ce3a8e95eaa58ca58291ac8c2986f00e0e4db12 Mon Sep 17 00:00:00 2001
From: "Barry Song (Xiaomi)" <baohua@kernel.org>
Date: Wed, 8 Jul 2026 22:46:43 +0800
Subject: [PATCH] mm: rename in_lru_cache to maybe_in_lru_cache

!folio_test_lru(folio) doesn't necessarily mean folio
is in lru cache. so let's put "maybe" prefix.

Suggested-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Barry Song (Xiaomi) <baohua@kernel.org>
---
 mm/memory.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mm/memory.c b/mm/memory.c
index 5689b7cff76c..631c170f812a 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -4174,7 +4174,7 @@ static bool __wp_can_reuse_large_anon_folio(struct folio *folio,
 static bool wp_can_reuse_anon_folio(struct folio *folio,
 				    struct vm_area_struct *vma)
 {
-	const bool in_lru_cache = !folio_test_lru(folio);
+	const bool maybe_in_lru_cache = !folio_test_lru(folio);
 	const bool in_swapcache = folio_test_swapcache(folio);
 
 	if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && folio_test_large(folio))
@@ -4188,9 +4188,9 @@ static bool wp_can_reuse_anon_folio(struct folio *folio,
 	 * KSM doesn't necessarily raise the folio refcount.
 	 */
 	if (folio_test_ksm(folio) ||
-	    folio_ref_count(folio) > 1 + in_lru_cache + in_swapcache)
+	    folio_ref_count(folio) > 1 + maybe_in_lru_cache + in_swapcache)
 		return false;
-	if (in_lru_cache)
+	if (maybe_in_lru_cache)
 		/*
 		 * We cannot easily detect+handle references from
 		 * remote LRU caches or references to LRU folios.
-- 
2.39.3 (Apple Git-146)


>
> --
> Cheers,
>
> David


  reply	other threads:[~2026-07-08 14:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260701235955.36126-1-baohua@kernel.org>
     [not found] ` <20260701235955.36126-3-baohua@kernel.org>
     [not found]   ` <3a185a5d-2f2c-4e9d-9cd9-8bdb236dfc5c@kernel.org>
2026-07-06  8:14     ` [PATCH v3 2/4] mm: drop stale folio_ref_count()==1 check in do_swap_page reuse logic Barry Song
2026-07-07 11:08     ` Barry Song
2026-07-07 20:18       ` Andrew Morton
     [not found] ` <20260701235955.36126-2-baohua@kernel.org>
2026-07-07 12:55   ` [PATCH v3 1/4] mm: avoid unnecessary lru drain for wp_can_reuse_anon_folio() Baoquan He
     [not found]   ` <a9829fdd-75b3-4035-935a-f3a74fdc29bc@kernel.org>
2026-07-06  8:18     ` Barry Song
2026-07-06  9:12       ` Baoquan He
2026-07-06  9:17         ` Barry Song
2026-07-07 15:26       ` Kairui Song
2026-07-07 15:58         ` David Hildenbrand (Arm)
2026-07-08 14:57           ` Barry Song (Xiaomi) [this message]
2026-07-07 15:21     ` Shakeel Butt

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=20260708145718.82690-1-baohua@kernel.org \
    --to=baohua@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=baoquan.he@linux.dev \
    --cc=chrisl@kernel.org \
    --cc=david@kernel.org \
    --cc=jp.kobryn@linux.dev \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=nphamcs@gmail.com \
    --cc=rppt@kernel.org \
    --cc=ryncsn@gmail.com \
    --cc=shakeel.butt@linux.dev \
    --cc=shikemeng@huaweicloud.com \
    --cc=surenb@google.com \
    --cc=usama.arif@linux.dev \
    --cc=vbabka@kernel.org \
    --cc=youngjun.park@lge.com \
    /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