On 24.06.25 05:27, Li Wang wrote:
> Some systems (e.g. minimal or real-time kernels) may not enable
> Transparent Hugepages (THP), causing MADV_HUGEPAGE to return EINVAL.
> This patch introduces a runtime check using the existing THP sysfs
> interface and skips the hugepage merging test (`-H`) when THP is
> not available.
>
> To avoid those failures:
But we deliberately have in tools/testing/selftests/mm/config:
CONFIG_TRANSPARENT_HUGEPAGE=y
So isn't this rather a test setup issue? Meaning, the environment is
not well prepared.
It's true that CONFIG_TRANSPARENT_HUGEPAGE=y
is explicitly
enabled in tools/testing/selftests/mm/config, so ideally the runtime
environment should also support THP.
However, in practice, we've found that on some systems:
- THP is disabled at boot time (transparent_hugepage=never)
- Or manually disabled via sysfs
- Or unavailable in RT kernels, containers, or minimal CI environments
In these cases, the test will fail with EINVAL on madvise(MADV_HUGEPAGE),
even though the kernel config is correct.
To make the test suite more robust and avoid false negatives, this patch
adds a runtime check for /sys/kernel/mm/transparent_hugepage/enabled.
If THP is not available, the hugepage test (-H) is skipped with a clear message.
--