All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ridong Chen <ridong.chen@linux.dev>
To: Barry Song <baohua@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Kairui Song <kasong@tencent.com>,
	David Hildenbrand <david@kernel.org>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Qi Zheng <qi.zheng@linux.dev>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	Axel Rasmussen <axelrasmussen@google.com>,
	Yuanchu Xie <yuanchu@google.com>, Wei Xu <weixugc@google.com>,
	Baoquan He <baoquan.he@linux.dev>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	"Liam R. Howlett" <liam@infradead.org>,
	Vlastimil Babka <vbabka@kernel.org>,
	Mike Rapoport <rppt@kernel.org>, Michal Hocko <mhocko@suse.com>,
	Yu Zhao <yuzhao@google.com>,
	"open list:MEMORY MANAGEMENT - MGLRU (MULTI-GEN LRU)"
	<linux-mm@kvack.org>, Ridong Chen <chenridong@xiaomi.com>
Subject: Re: [PATCH v2 1/2] mm/mglru: pass a seq range to lru_gen_add_folio()
Date: Tue, 24 Nov 2026 09:48:05 +0800	[thread overview]
Message-ID: <76ab403d-2e4c-4aa3-a638-830971c13669@linux.dev> (raw)
In-Reply-To: <CAGsJ_4yiSji++3BPgFUWDp0SGJkFj13qjEfkjNZu7ak1JNozSw@mail.gmail.com>



On 11/24/2026 8:43 AM, Barry Song wrote:
> On Thu, Nov 19, 2026 at 9:48 PM Ridong Chen <ridong.chen@linux.dev> wrote:
> [...]
>> -                       /*
>> -                        * Borrow reclaiming=true to place inactive folios in
>> -                        * the older gens.
>> -                        */
>> -                       success = lru_gen_add_folio(lruvec, folio, !active);
>> +                       success = lru_gen_add_folio(lruvec, folio, -1UL, -1UL, !active);
> 
> 
> I'm still struggling to understand what the two `-1UL` arguments mean
> when used together. Could we use meaningful macros to make the code
> easier to read?
> 
> For example:
> 
> #define MIN_SEQ_UNBOUNDED ULONG_MAX
> #define MAX_SEQ_UNBOUNDED ULONG_MAX
> 
> Then the call becomes:
> 
> lru_gen_add_folio(lruvec, folio, MIN_SEQ_UNBOUNDED,
>                    MAX_SEQ_UNBOUNDED, !active);
> 
> for other places, they are:
> 
> lru_gen_add_folio(lruvec, folio, seq + 1, MAX_SEQ_UNBOUNDED, false);
> 
> lru_gen_add_folio(lruvec, folio, MIN_SEQ_UNBOUNDED,
> lruvec->lrugen.min_seq[type], false);
> 
Good point, thanks. I'll add the macros in v3, with one change: I'd
like to define MIN_SEQ_UNBOUNDED as 0 instead of ULONG_MAX:

#define MIN_SEQ_UNBOUNDED       0UL
#define MAX_SEQ_UNBOUNDED       ULONG_MAX

Both are then identity bounds. max(seq, 0) and min(seq, ULONG_MAX)
leave seq unchanged, so lru_gen_add_folio() can drop the two
"!= -1UL" checks and cap unconditionally:

	  seq = max(seq, min(min_seq, lrugen->max_seq));
	  seq = min(seq, max_seq);

It also reads more naturally: "no lower bound" is 0, rather than a
lower bound of ULONG_MAX that has to be special-cased.

The callers then become what you listed:

	  lru_gen_add_folio(lruvec, folio, MIN_SEQ_UNBOUNDED,
				MAX_SEQ_UNBOUNDED, !active);
	  lru_gen_add_folio(lruvec, folio, seq + 1, MAX_SEQ_UNBOUNDED, false);
	  lru_gen_add_folio(lruvec, folio, MIN_SEQ_UNBOUNDED,
				lruvec->lrugen.min_seq[type], false);

Does that look OK to you?

-- 
Best regards
Ridong



  reply	other threads:[~2026-11-24  1:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 13:47 [PATCH v2 0/2] mm/mglru: deactivate anon folios into the oldest generation Ridong Chen
2026-11-19 13:47 ` [PATCH v2 1/2] mm/mglru: pass a seq range to lru_gen_add_folio() Ridong Chen
2026-11-24  0:43   ` Barry Song
2026-11-24  1:48     ` Ridong Chen [this message]
2026-11-24  1:54       ` Barry Song
2026-11-19 13:47 ` [PATCH v2 2/2] mm/mglru: deactivate anon folios into the oldest generation Ridong Chen
2026-11-24  1:18   ` Barry Song
2026-11-24  1:50     ` Ridong Chen

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=76ab403d-2e4c-4aa3-a638-830971c13669@linux.dev \
    --to=ridong.chen@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=axelrasmussen@google.com \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=baoquan.he@linux.dev \
    --cc=chenridong@xiaomi.com \
    --cc=david@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=kasong@tencent.com \
    --cc=liam@infradead.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=qi.zheng@linux.dev \
    --cc=rppt@kernel.org \
    --cc=shakeel.butt@linux.dev \
    --cc=vbabka@kernel.org \
    --cc=weixugc@google.com \
    --cc=yuanchu@google.com \
    --cc=yuzhao@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.