From: "Brendan Jackman" <brendan.jackman@linux.dev>
To: "Petr Tesarik" <ptesarik@suse.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"David Hildenbrand" <david@kernel.org>,
"Lorenzo Stoakes" <ljs@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
"Vlastimil Babka" <vbabka@kernel.org>,
"Mike Rapoport" <rppt@kernel.org>,
"Suren Baghdasaryan" <surenb@google.com>,
"Michal Hocko" <mhocko@suse.com>, <linux-mm@kvack.org>
Cc: "Brendan Jackman" <jackmanb@google.com>,
"Johannes Weiner" <hannes@cmpxchg.org>, "Zi Yan" <ziy@nvidia.com>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1] mm: remove NODE_RECLAIM_xxx macros
Date: Thu, 11 Jun 2026 13:32:04 +0000 [thread overview]
Message-ID: <DJ69AE1CHPJC.3H4BPJUL9YYOV@linux.dev> (raw)
In-Reply-To: <20260611124501.1465806-1-ptesarik@suse.com>
On Thu Jun 11, 2026 at 12:45 PM UTC, Petr Tesarik wrote:
> Change node_reclaim() to return a bool indicating whether any
> pages have been reclaimed, because that's the only information
> needed by the only caller, get_page_from_freelist().
>
> Originally, I wanted to convert the preprocessor macros to an
> enum, but I couldn't find any explicit use of NODE_RECLAIM_SOME
> and NODE_RECLAIM_SUCCESS. That's because they are typecast from
> a bool.
I'm slightly confused by the "typecast from a bool" thing - nr_reclaim
returns nr_reclaimed and then node_reclaim()'s caller gets that value
directly - is that what you're referring to?
> This seemed a bit fragile,
.. Which, yeah, is awkward, thanks for fixing it.
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 3f3ff25e561ac..64f6b649eeac1 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -7786,9 +7786,9 @@ static unsigned long __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask,
> return sc->nr_reclaimed;
> }
>
> -int node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned int order)
> +bool node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned int order)
I really dislike returning bools with no obvious polarity. Personally I
would keep NODE_RECLAIM_*, (optionally convert to an enum), move the
comments to the definition of the NODE_RECLAIM_ thingies instead of
get_page_from_freelist(), and fix node_reclaim() to return
NODE_RECLAIM_{SUCCESS,SOME} expliticly.
I realise this philosophy is not favourable to concision though, I won't
die on that hill but could we at least get a comment on node_reclaim()'s
defintion...
> - ret = node_reclaim(zone->zone_pgdat, gfp_mask, order);
> - switch (ret) {
> - case NODE_RECLAIM_NOSCAN:
> - /* did not scan */
> - continue;
> - case NODE_RECLAIM_FULL:
> - /* scanned but unreclaimable */
> + if (!node_reclaim(zone->zone_pgdat, gfp_mask, order))
> continue;
> - default:
> - /* did we reclaim enough */
> - if (zone_watermark_ok(zone, order, mark,
> - ac->highest_zoneidx, alloc_flags))
> - goto try_this_zone;
>
> + /* did we reclaim enough */
> + if (!zone_watermark_ok(zone, order, mark,
> + ac->highest_zoneidx, alloc_flags))
> continue;
> - }
> }
... or keep the intermediate variable and do:
bool reclaimed_some = node_reclaim(...):
Since then the variable name at least tells you what you're looking at
without needing to jump into the function implementation.
next prev parent reply other threads:[~2026-06-11 13:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-11 12:45 [PATCH 1/1] mm: remove NODE_RECLAIM_xxx macros Petr Tesarik
2026-06-11 13:32 ` Brendan Jackman [this message]
2026-06-11 13:57 ` Petr Tesarik
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=DJ69AE1CHPJC.3H4BPJUL9YYOV@linux.dev \
--to=brendan.jackman@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=jackmanb@google.com \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=ptesarik@suse.com \
--cc=rppt@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=ziy@nvidia.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