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: <20251220063738.hbypivj3d34c7ffs@master>
Date: Sat, 20 Dec 2025 06:37:38 +0000
From: Wei Yang <richard.weiyang@...il.com>
To: Zi Yan <ziy@...dia.com>
Cc: Gregory Price <gourry@...rry.net>, Wei Yang <richard.weiyang@...il.com>,
	linux-mm@...ck.org, linux-kernel@...r.kernel.org,
	kernel-team@...a.com, akpm@...ux-foundation.org, vbabka@...e.cz,
	surenb@...gle.com, mhocko@...e.com, jackmanb@...gle.com,
	hannes@...xchg.org, osalvador@...e.de, rientjes@...gle.com,
	david@...hat.com, joshua.hahnjy@...il.com, fvdl@...gle.com
Subject: Re: [PATCH v6] page_alloc: allow migration of smaller hugepages
 during contig_alloc

On Fri, Dec 19, 2025 at 03:46:25PM -0500, Zi Yan wrote:
>On 19 Dec 2025, at 9:26, Gregory Price wrote:
>
>> On Fri, Dec 19, 2025 at 12:08:00AM +0000, Wei Yang wrote:
>>>> +
>>>> +			page = compound_head(page);
>>>> +			order = compound_order(page);
>>>
>>> The order is get from head page.
>>>
>>>> +			if ((order >= MAX_FOLIO_ORDER) ||
>>>> +			    (nr_pages <= (1 << order)))
>>>> +				return false;
>>>> +
>>>> +			/* No need to check the pfns for this page */
>>>> +			i += (1 << order) - 1;
>>>
>>> So this advance should based on "head page" instead of original page, right?
>>>
>>
>> hm, I think the thought here was that since we're moving forward from
>> start of an aligned chunk, we'd never hit a non-head page - but this
>> may not be true.
>>
>> Will think about this for a bit.
>
>The sole caller of pfn_range_valid_contig(), alloc_contig_pages_noprof(),
>scans from the beginning of a zone to the end. pfn_range_valid_contig()
>should see head pages all the time, except it scans in the middle of
>a 1GB hugetlb when alloc_contig_pages_noprof() is asking for a smaller
>nr_pages, like 2MB. But in that case, the if above i += (1 << order) - 1
>would return false without reaching it. Basically, to get to
>i += ..., pfn_range_valid_contig() needs to search for nr_pages larger
>than PageHuge(page) and nr_pages is always power of two based on
>alloc_contig_pages_noprof() requirement, but that means
>pfn_range_valid_contig() always sees such PageHuge pages as a whole
>within nr_pages range, thus cannot see a tail PageHuge page at the
>point of i += ....
>

Thanks, I think you are right. For current use case, it is safe.

But I am not sure others could get it on first sight. For example, me :-)
Do you think it would be helpful to add some comment here?

Generally LGTM.

Reviewed-by: Wei Yang <richard.weiyang@...il.com>

>Best Regards,
>Yan, Zi

-- 
Wei Yang
Help you, Help me

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ