From: Joshua Hahn <joshua.hahnjy@gmail.com>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>,
Brendan Jackman <jackmanb@google.com>,
Johannes Weiner <hannes@cmpxchg.org>, Zi Yan <ziy@nvidia.com>,
David Rientjes <rientjes@google.com>,
David Hildenbrand <david@kernel.org>,
Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
"Liam R. Howlett" <Liam.Howlett@oracle.com>,
Mike Rapoport <rppt@kernel.org>, Pedro Falcato <pfalcato@suse.de>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFC v2 2/3] mm/page_alloc: refactor the initial compaction handling
Date: Sun, 21 Dec 2025 23:40:55 -0800 [thread overview]
Message-ID: <20251222074055.74545-1-joshua.hahnjy@gmail.com> (raw)
In-Reply-To: <20251219-thp-thisnode-tweak-v2-2-0c01f231fd1c@suse.cz>
On Fri, 19 Dec 2025 18:38:52 +0100 Vlastimil Babka <vbabka@suse.cz> wrote:
Hi Vlastimil,
I hope you are doing well, sorry for the late reply. The patch overall looks
good to me, but I have a few very small nits.
> The initial direct compaction done in some cases in
> __alloc_pages_slowpath() stands out from the main retry loop of
> reclaim + compaction.
>
> We can simplify this by instead skipping the initial reclaim attempt via
> a new local variable compact_first, and handle the compact_prority to
> match the original behavior.
>
> Suggested-by: Johannes Weiner <hannes@cmpxchg.org>
> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
> ---
> mm/page_alloc.c | 106 +++++++++++++++++++++++++++++---------------------------
> 1 file changed, 54 insertions(+), 52 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 9e7b0967f1b5..cb8965fd5e20 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -4512,6 +4512,11 @@ static bool oom_reserves_allowed(struct task_struct *tsk)
> return true;
> }
>
> +static inline bool gfp_thisnode_noretry(gfp_t gfp_mask)
> +{
> + return (gfp_mask & __GFP_NORETRY) && (gfp_mask & __GFP_THISNODE);
> +}
NIT: Is there a reason why this was turned into its own function? The checks
seem short enough to open-code and it seems like there's only one caller as
far as I can tell. Actually I think there are some better candidates of
turning boolean checks into functions, like the one below:
[...snip...]
> + /*
> + * For costly allocations, try direct compaction first, as it's likely
> + * that we have enough base pages and don't need to reclaim. For non-
> + * movable high-order allocations, do that as well, as compaction will
> + * try prevent permanent fragmentation by migrating from blocks of the
> + * same migratetype.
> + */
> + if (can_compact && (costly_order || (order > 0 &&
> + ac->migratetype != MIGRATE_MOVABLE))) {
> + compact_first = true;
> + compact_priority = INIT_COMPACT_PRIORITY;
> + }
> +
It has indeed become shorter thanks to this patch, but I think if we want to
make the code more "readable" we can stay consistent and move these into thier
own boolean checks, or just leave them open-coded. No strong preference here,
just wanted to offer my 2c and hear what you think.
[...snip...]
> + /*
> + * For the initial compaction attempt we have lowered its
> + * priority. Restore it for further retries. With __GFP_NORETRY
> + * there will be a single round of reclaim+compaction with the
> + * lowered priority.
> + */
> + if (!(gfp_mask & __GFP_NORETRY)) {
> + compact_priority = DEF_COMPACT_PRIORITY;
> + }
NIT: I think these braces are unecessary : -)
Otherwise, LGTM! Thank you for your work, it looks a lot cleaner.
Reviewed-by: Joshua Hahn <joshua.hahnjy@gmail.com>
next prev parent reply other threads:[~2025-12-22 7:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-19 17:38 [PATCH RFC v2 0/3] tweaks for __alloc_pages_slowpath() Vlastimil Babka
2025-12-19 17:38 ` [PATCH RFC v2 1/3] mm/page_alloc: ignore the exact initial compaction result Vlastimil Babka
2025-12-19 17:38 ` [PATCH RFC v2 2/3] mm/page_alloc: refactor the initial compaction handling Vlastimil Babka
2025-12-22 7:40 ` Joshua Hahn [this message]
2025-12-19 17:38 ` [PATCH RFC v2 3/3] mm/page_alloc: simplify __alloc_pages_slowpath() flow Vlastimil Babka
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=20251222074055.74545-1-joshua.hahnjy@gmail.com \
--to=joshua.hahnjy@gmail.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=jackmanb@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=mhocko@suse.com \
--cc=pfalcato@suse.de \
--cc=rientjes@google.com \
--cc=rppt@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
--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