Re: [RFC PATCH v3 2/2] selftests: restrictedmem: Check hugepage-ness of shmem file backing restrictedmem fd

Ackerley Tng
2023-04-11T01:35:30Z

David Hildenbrand <david@redhat.com> writes:

> On 01.04.23 01:50, Ackerley Tng wrote:
>> For memfd_restricted() calls without a userspace mount, the backing
>> file should be the shmem mount in the kernel, and the size of backing
>> pages should be as defined by system-wide shmem configuration.

>> If a userspace mount is provided, the size of backing pages should be
>> as defined in the mount.

>> Also includes negative tests for invalid inputs, including fds
>> representing read-only superblocks/mounts.

> When you talk about "hugepage" in this patch, do you mean THP or
> hugetlb? I suspect thp, so it might be better to spell that out. IIRC,
> there are plans to support actual huge pages in the future, at which
> point "hugepage" terminology could be misleading.

Thanks for pointing this out! I've replaced references to hugepage with
thp, please see RFC v4 at
https://lore.kernel.org/lkml/cover.1681176340.git.ackerleytng@google.com/T/

>> Signed-off-by: Ackerley Tng <ackerleytng@google.com>
>> ---
>> tools/testing/selftests/Makefile | 1 +
>> .../selftests/restrictedmem/.gitignore | 3 +
>> .../testing/selftests/restrictedmem/Makefile | 15 +
>> .../testing/selftests/restrictedmem/common.c | 9 +
>> .../testing/selftests/restrictedmem/common.h | 8 +
>> .../restrictedmem_hugepage_test.c | 486 ++++++++++++++++++
>> 6 files changed, 522 insertions(+)
>> create mode 100644 tools/testing/selftests/restrictedmem/.gitignore
>> create mode 100644 tools/testing/selftests/restrictedmem/Makefile
>> create mode 100644 tools/testing/selftests/restrictedmem/common.c
>> create mode 100644 tools/testing/selftests/restrictedmem/common.h
>> create mode 100644
>> tools/testing/selftests/restrictedmem/restrictedmem_hugepage_test.c

>> ...