On Tue, Jun 17, 2025 at 11:52:52AM -0400, Peter Xu wrote:
On Mon, Jun 16, 2025 at 05:26:18PM -0700, Andrew Morton wrote:
On Mon, 16 Jun 2025 15:34:06 +0530 Ujwal Kundur ujwal.kundur@gmail.com wrote:
Refactor macros and non-composite global variable definitions into a struct that is defined at the start of a test and is passed around instead of relying on global vars.
Well I guess that's nicer.
5 files changed, 616 insertions(+), 542 deletions(-)
It needs to be!
Thanks, I'll queue it for testing while Peter thinks about it :)
I didn't pay much attention on this one as I saw Brandan was actively reviewing it, which was great.
This is definitely an improvement to the test. Thanks both!
I did give it a quick run today, but I found I hit this:
$ ./uffd-unit-tests Testing UFFDIO_API (with syscall)... done Testing UFFDIO_API (with /dev/userfaultfd)... done Testing register-ioctls on anon... done ERROR: munmap (errno=22, @uffd-common.c:277)
IIUC it's because after moving most globals to stack, they are not properly zero-initialized anymore. In this case it failed at MEM_ANON of register-ioctls test, trying to munmap() some address that will start to be random garbage since it's on the stack. So maybe we at least need something like this?
diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c index bed96f41c578..0b66ca3e7b82 100644 --- a/tools/testing/selftests/mm/uffd-unit-tests.c +++ b/tools/testing/selftests/mm/uffd-unit-tests.c @@ -1744,7 +1744,7 @@ int main(int argc, char *argv[]) mem_type = &mem_types[j];
/* Initialize global test options */ - uffd_global_test_opts_t gopts; + uffd_global_test_opts_t gopts = { 0 };
gopts.map_shared = mem_type->shared; uffd_test_ops = mem_type->mem_ops;
Even with that, it fails somewhere later.
Ujwal, can you reproduce these issues and have a look?
Thanks,