[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251222074055.74545-1-joshua.hahnjy@gmail.com>
Date: Sun, 21 Dec 2025 23:40:55 -0800
From: Joshua Hahn <joshua.hahnjy@...il.com>
To: Vlastimil Babka <vbabka@...e.cz>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Suren Baghdasaryan <surenb@...gle.com>,
Michal Hocko <mhocko@...e.com>,
Brendan Jackman <jackmanb@...gle.com>,
Johannes Weiner <hannes@...xchg.org>,
Zi Yan <ziy@...dia.com>,
David Rientjes <rientjes@...gle.com>,
David Hildenbrand <david@...nel.org>,
Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
"Liam R. Howlett" <Liam.Howlett@...cle.com>,
Mike Rapoport <rppt@...nel.org>,
Pedro Falcato <pfalcato@...e.de>,
linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH RFC v2 2/3] mm/page_alloc: refactor the initial compaction handling
On Fri, 19 Dec 2025 18:38:52 +0100 Vlastimil Babka <vbabka@...e.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@...xchg.org>
> Signed-off-by: Vlastimil Babka <vbabka@...e.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@...il.com>
Powered by blists - more mailing lists