Skip to content

selftests/mm: avoid false failures in hugetlb and KSM tests

Sayali Patil linux-kselftest linux-mm linuxppc-dev lkml 3 versions – Applied

Status from this message: [merged mm-stable] selftests-mm-fix-ternary-operator-precedence-in-ksm_tests.patch removed from -mm tree

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest3 patches 5 repliesApplied 3/3
  2. v23 patches 6 repliesSuperseded
  3. v12 patches 4 repliesSuperseded

Changes in v3 from the cover letter

- For "selftests/mm: handle EINVAL when configuring gigantic hugepages":
Reworked the implementation to use internal helper functions with an ignore_einval flag, as suggested by David Hildenbrand.
Added __write_file() and __write_num() helpers to optionally ignore -EINVAL from sysfs writes.
Added write_num_ignore_einval() wrapper for callers that need to tolerate unsupported hugepage configurations.

Patches in v3 All 3 applied

#Subject and filesSizeRepliesApplied
1/3selftests/mm: handle EINVAL when configuring gigantic hugepagestools/testing/selftests/mm/hugepage_settings.c tools/testing/selftests/mm/vm_util.c tools/testing/selftests/mm/vm_util.h+24 -52 repliesApplied
2/3selftests/mm: fix ksm NUMA merge test for systems with memoryless NUMA nodestools/testing/selftests/mm/ksm_tests.c+9 -71 replyApplied
3/3selftests/mm: fix ternary operator precedence in ksm_teststools/testing/selftests/mm/ksm_tests.c+6 -60 repliesApplied

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchDavid Hildenbrand (Arm)Usama Arif
1/3A-b
2/3A-b
3/3A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/3] selftests/mm: avoid false failures in hugetlb and KSM tests

Hi all,

This series fixes issues in the hugetlb and KSM MM selftest categories that can report failures when the prerequisites for the tests are not satisfied.

Patch 1 updates the hugetlb selftest helpers to handle -EINVAL when attempting to configure gigantic HugeTLB pages via nr_hugepages. PowerPC hash MMU pSeries systems expose gigantic hugepage sizes but do not allow runtime allocation of such pages, causing the sysfs write to fail. Handle this case gracefully and continue running the test instead of aborting.

Patch 2 fixes the KSM NUMA merge test on systems with memoryless NUMA nodes. The test currently relies on the number of configured NUMA nodes and may attempt allocations on nodes that have no memory, resulting in spurious failures. Use the existing helpers to identify
NUMA nodes that contain memory and skip the test when fewer than two such nodes are available.

Patch 3 fixes a pre-existing operator precedence issue in ksm_tests, where a ternary expression combined with logical OR operators could be evaluated differently than intended. Added parentheses to ensure the correct evaluation order.

These changes improve handling of unsupported test configurations and unmet test prerequisites, avoiding spurious failures.

Thanks,
Sayali
---

V2 -> V3:
- For "selftests/mm: handle EINVAL when configuring gigantic hugepages":
Reworked the implementation to use internal helper functions with an ignore_einval flag, as suggested by David Hildenbrand.
Added __write_file() and __write_num() helpers to optionally ignore -EINVAL from sysfs writes.
Added write_num_ignore_einval() wrapper for callers that need to tolerate unsupported hugepage configurations.

V2: https://lore.kernel.org/all/[email protected]/

---

V1 -> V2:
- For "selftests/mm: handle EINVAL when configuring gigantic hugepages":
Added a dedicated hugetlb_write_num() helper to handle the expected EINVAL returned by gigantic hugepage configuration, in the
hugepage setup code rather than modifying the generic write_file() helper.
- For "selftests/mm: fix ksm NUMA merge test for systems with memoryless NUMA nodes":
Updated implementation as per David's review comment to build upon existing helpers get_next_mem_node().
- Added new patch "selftests/mm: fix ternary operator precedence in ksm_tests" to address a pre-existing issue identified during Sahiko's review.

V1: https://lore.kernel.org/all/[email protected]/

---

Sayali Patil (3):
selftests/mm: handle EINVAL when configuring gigantic hugepages selftests/mm: fix ksm NUMA merge test for systems with memoryless NUMA
nodes
selftests/mm: fix ternary operator precedence in ksm_tests

 .../testing/selftests/mm/hugepage_settings.c  |  2 +-
 tools/testing/selftests/mm/ksm_tests.c        | 28 ++++++++++---------
 tools/testing/selftests/mm/vm_util.c          | 26 ++++++++++++++---
 tools/testing/selftests/mm/vm_util.h          |  1 +
 4 files changed, 39 insertions(+), 18 deletions(-)
Signature · 1 line
2.52.0