On Tue, Jul 29, 2025 at 11:36 PM Zi Yan <ziy@xxxxxxxxxx> wrote: > > On 29 Jul 2025, at 5:18, Yafang Shao wrote: > > > This self-test verifies that PMD-mapped THP allocation is restricted in > > page faults for tasks within a specific cgroup, while still permitting > > THP allocation via khugepaged. > > > > Since THP allocation depends on various factors (e.g., system memory > > pressure), using the actual allocated THP size for validation is > > unreliable. Instead, we check the return value of get_suggested_order(), > > which indicates whether the system intends to allocate a THP, regardless of > > whether the allocation ultimately succeeds. > > > > Signed-off-by: Yafang Shao <laoar.shao@xxxxxxxxx> > > --- > > tools/testing/selftests/bpf/config | 2 + > > .../selftests/bpf/prog_tests/thp_adjust.c | 183 ++++++++++++++++++ > > .../selftests/bpf/progs/test_thp_adjust.c | 69 +++++++ > > .../bpf/progs/test_thp_adjust_failure.c | 24 +++ > > 4 files changed, 278 insertions(+) > > create mode 100644 tools/testing/selftests/bpf/prog_tests/thp_adjust.c > > create mode 100644 tools/testing/selftests/bpf/progs/test_thp_adjust.c > > create mode 100644 tools/testing/selftests/bpf/progs/test_thp_adjust_failure.c > > > > The program below will only work on architectures with 4KB base page > and PMD order is 9. It is better to read base page size and PMD page size > from the system. Thanks for the suggestion. I’ll change it. -- Regards Yafang