From: Baoquan He <baoquan.he@linux.dev>
To: "Barry Song (Xiaomi)" <baohua@kernel.org>
Cc: akpm@linux-foundation.org, baolin.wang@linux.alibaba.com,
hannes@cmpxchg.org, hebaoquan@kylinos.cn, kasong@tencent.com,
linux-mm@kvack.org, mhocko@kernel.org, qi.zheng@linux.dev,
shakeel.butt@linux.dev
Subject: Re: [PATCH 2/4] mm/mglru: rename positive_ctrl_err() to should_reclaim()
Date: Thu, 3 Dec 2026 16:13:43 +0800 [thread overview]
Message-ID: <axEkt2w1CdT8ejiH@fedora> (raw)
In-Reply-To: <20261202095957.52379-1-baohua@kernel.org>
On 12/02/26 at 05:59pm, Barry Song (Xiaomi) wrote:
> On Wed, Dec 2, 2026 at 2:17 PM Baoquan He <baoquan.he@linux.dev> wrote:
> >
> > From: Baoquan He <hebaoquan@kylinos.cn>
> >
> > positive_ctrl_err() is named after control-theory jargon, which
> > obscures what the function actually asks: whether the candidate position
> > (pv) is worth reclaiming, i.e. it has a limited number of refaults or a
> > lower refaulted/total than the current position (sp).
> >
> > Rename it to should_reclaim() so the reclaim decision is self-evident at
> > its call site.
>
> Yes, I agree we should definitely do something here. But simply
> renaming the function to should_reclaim() doesn't seem sufficient.
> Perhaps we could make things much clearer by doing something like
> this?
Makes sense to me, while the naming may need be carefully considerred. I
will think about this and update accoding to your suggestions. Thanks.
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 443ee5d30531..65a0ae024524 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -3483,7 +3483,7 @@ static bool iterate_mm_list_nowalk(struct lruvec *lruvec, unsigned long seq)
> * 1. The D term may discount the other two terms over time so that long-lived
> * generations can resist stale information.
> */
> -struct ctrl_pos {
> +struct refault_stats {
> unsigned long refaulted;
> unsigned long total;
> int gain;
> @@ -3492,8 +3492,8 @@ struct ctrl_pos {
> /*
> * __noipa works around gcc-16 warning for uninitialized use of pos->refaulted
> */
> -static void __noipa read_ctrl_pos(struct lruvec *lruvec, int type, int tier_min,
> - int tier_max, int gain, struct ctrl_pos *pos)
> +static void __noipa read_refault_stats(struct lruvec *lruvec, int type, int tier_min,
> + int tier_max, int gain, struct refault_stats *pos)
> {
> int i;
> struct lru_gen_folio *lrugen = &lruvec->lrugen;
> @@ -3511,7 +3511,7 @@ static void __noipa read_ctrl_pos(struct lruvec *lruvec, int type, int tier_min,
> }
> }
>
> -static void reset_ctrl_pos(struct lruvec *lruvec, int type, bool carryover)
> +static void reset_refault_stats(struct lruvec *lruvec, int type, bool carryover)
> {
> int hist, tier;
> struct lru_gen_folio *lrugen = &lruvec->lrugen;
> @@ -3547,8 +3547,10 @@ static void reset_ctrl_pos(struct lruvec *lruvec, int type, bool carryover)
> }
> }
>
> -static bool positive_ctrl_err(struct ctrl_pos *sp, struct ctrl_pos *pv)
> +static bool can_reclaim_tier(struct refault_stats *base, struct refault_stats *cand)
> {
> + struct refault_stats *sp = base, *pv = cand;
> +
> /*
> * Return true if the PV has a limited number of refaults or a lower
> * refaulted/total than the SP.
> @@ -4288,7 +4290,7 @@ static bool inc_min_seq(struct lruvec *lruvec, int type, int swappiness)
> return false;
> }
> done:
> - reset_ctrl_pos(lruvec, type, true);
> + reset_refault_stats(lruvec, type, true);
> WRITE_ONCE(lrugen->min_seq[type], lrugen->min_seq[type] + 1);
>
> return true;
> @@ -4354,7 +4356,7 @@ static void try_to_inc_min_seq(struct lruvec *lruvec, int swappiness)
> if (min_seq[type] <= lrugen->min_seq[type])
> continue;
>
> - reset_ctrl_pos(lruvec, type, true);
> + reset_refault_stats(lruvec, type, true);
> WRITE_ONCE(lrugen->min_seq[type], min_seq[type]);
> }
> }
> @@ -4389,7 +4391,7 @@ static bool inc_max_seq(struct lruvec *lruvec, unsigned long seq, int swappiness
> }
>
> for (type = 0; type < ANON_AND_FILE; type++)
> - reset_ctrl_pos(lruvec, type, false);
> + reset_refault_stats(lruvec, type, false);
>
> next = lru_gen_from_seq(lrugen->max_seq + 1);
> WRITE_ONCE(lrugen->timestamps[next], jiffies);
> @@ -5193,7 +5195,7 @@ static int scan_folios(unsigned long nr_to_scan, struct lruvec *lruvec,
> static int get_tier_idx(struct lruvec *lruvec, int type)
> {
> int tier;
> - struct ctrl_pos sp, pv;
> + struct refault_stats base, cand;
>
> /*
> * To leave a margin for fluctuations, use a larger gain factor (1:2).
> @@ -5202,9 +5204,9 @@ static int get_tier_idx(struct lruvec *lruvec, int type)
> * protects the tiers above it.
> */
> for (tier = LRU_TIER_MIN + 1; tier <= LRU_TIER_MAX; tier++) {
> - read_ctrl_pos(lruvec, type, LRU_TIER_MIN, tier - 1, 1, &sp);
> - read_ctrl_pos(lruvec, type, tier, tier, 2, &pv);
> - if (!positive_ctrl_err(&sp, &pv))
> + read_refault_stats(lruvec, type, LRU_TIER_MIN, tier - 1, 1, &base);
> + read_refault_stats(lruvec, type, tier, tier, 2, &cand);
> + if (!can_reclaim_tier(&base, &cand))
> break;
> }
>
next prev parent reply other threads:[~2026-12-03 8:14 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 6:17 [PATCH 0/4] mm/mglru: cleanup series and a small correctness Baoquan He
2026-12-02 6:17 ` [PATCH 1/4] mm/mglru: use a common helper to check evictable type Baoquan He
2026-12-02 6:41 ` Barry Song
2026-12-02 8:43 ` Baoquan He
2026-12-02 21:49 ` Andrew Morton
2026-12-02 22:40 ` Barry Song
2026-12-03 1:22 ` Baoquan He
2026-12-02 6:17 ` [PATCH 2/4] mm/mglru: rename positive_ctrl_err() to should_reclaim() Baoquan He
2026-12-02 9:59 ` Barry Song (Xiaomi)
2026-12-03 8:13 ` Baoquan He [this message]
2026-12-02 6:17 ` [PATCH 3/4] mm/mglru: split reset_ctrl_pos() into _update and _reset Baoquan He
2026-12-02 10:12 ` Barry Song
2026-12-03 8:16 ` Baoquan He
2026-12-02 6:20 ` [PATCH 4/4] mm/mglru: stop counting isolation races as PGSCAN_SKIP in scan_folios() Baoquan He
2026-12-02 9:22 ` Barry Song
2026-12-03 8:22 ` Baoquan He
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=axEkt2w1CdT8ejiH@fedora \
--to=baoquan.he@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=hannes@cmpxchg.org \
--cc=hebaoquan@kylinos.cn \
--cc=kasong@tencent.com \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=qi.zheng@linux.dev \
--cc=shakeel.butt@linux.dev \
/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