[LTP] hugemmap10: Account for memory policy in counter checks

Huaisheng Ye yehuaisheng@open-hieco.net
Tue Sep 29 04:19:55 CEST 2026



On 9/14/2026 8:03 PM, linuxtestproject.agent@gmail.com wrote:
> Hi Huaisheng,
>
> On Mon Sep 14 11:23:59 2026 +0800, Huaisheng Ye wrote:
>> hugemmap10: Account for memory policy in counter checks
>> Note that a kernel patch has already been posted for solving Hugetlb
>> reservations defect. Without that, hugemmap10 would fail when mapping .
>> https://lore.kernel.org/all/20260909074642.7308-1-yehuaisheng@open-hieco.net/
> The referenced kernel patch is not merged in mainline or the latest stable
> release (7.3). Tests depending on unmerged kernel changes must use the
> [STAGING] prefix and reside in runtest/staging rather than modifying
> tests in default test suites.

It has been merged to AKPM's mm-new branch only.
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git/commit/?h=mm-new&id=506f9bf248c092fc80df046f9deb26094ea84592

>> +static int node_isset(unsigned long node, const unsigned long *nodemask)
>> +{
>> +	return nodemask[node / ULONG_BITS] & (1UL << (node % ULONG_BITS));
>> +}
> On 64-bit systems, the return value truncates to a 32-bit int, yielding 0
> for any node with (node % 64) >= 32. Return !!(...) instead.
Fixed that in V2.

>> +		if ((unsigned long)hpages > allowed_free)
>> +			shortfall = MAX(shortfall,
>> +					(unsigned long)hpages - allowed_free);
> allowed_free sums sysfs free_hugepages, which includes pages already
> reserved by prior mappings. Comparing hpages against allowed_free without
> accounting for reservations on those nodes undercalculates the shortfall
> when prior reservations exist.

That is intended to verify that the requested hugepages cannot be
satisfied by the nodes allowed by the memory policy based on currently
available hugepages.

However, free_hugepages exported via sysfs does include hugepages that
may already be reserved by existing mappings. Therefore
(hpages - allowed_free) cannot provide an exact reservation availability
calculation. So take the larger value of the global_shortfall and
allowed_shortfall, that is taking into account the global reservation.

This is a best-effort check based on per-node free hugepages rather than
exact reservation accounting. And based on our observations that is enough
for LTP testcase hugemmap10.

A fully accurate check would require per-node reservation information,
which is not available from sysfs.

Furthermore, I believe the fundamental reason lies in the lazy page 
allocation
principle of MM. Only when page-fault time can the MM determine hugepage
originates from which nodes. So Kernel is unable to provide Per-node
reservation in multi-node numa system.

Huaisheng Ye




More information about the ltp mailing list