lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <a6e16aa3-b98b-44ff-ae05-4f1002840f4a@suse.cz>
Date: Tue, 6 Jan 2026 11:38:44 +0100
From: Vlastimil Babka <vbabka@...e.cz>
To: Joshua Hahn <joshua.hahnjy@...il.com>
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 12/22/25 08:40, Joshua Hahn wrote:
> 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:

I initially made the helper because there were multiple uses of it but then
went away with the refactoring. Agree it's not useful at this point.

> [...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.

Yeah I'll leave the open coded variants, as with single usages the wrappers
would just add another layer to go through when trying to understand the code.

> [...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 : -)

Ack.

> Otherwise, LGTM! Thank you for your work, it looks a lot cleaner.
> 
> Reviewed-by: Joshua Hahn <joshua.hahnjy@...il.com>

Thanks!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ