Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: update uffd-stress to handle EINVAL for unset config features

Now that we have updated userfaultfd_api to correctly return EINVAL when a
feature is requested but not available, let's fix the uffd-stress test to
only set the UFFD_FEATURE_WP_UNPOPULATED feature when the config is set.
In addition, still run the test if the CONFIG_PTE_MARKER_UFFD_WP is not
set, just dont use the corresponding UFFD_FEATURE_WP_UNPOPULATED feature.

Link: https://lkml.kernel.org/r/20240626130513.120193-2-audra@redhat.com
Signed-off-by: Audra Mitchell <audra@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Rafael Aquini <raquini@redhat.com>
Cc: Shaohua Li <shli@fb.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Audra Mitchell and committed by
Andrew Morton
a47a7af9 8ac5dc66

+9 -5
+9 -5
tools/testing/selftests/mm/uffd-stress.c
··· 36 36 #include <asm-generic/unistd.h> 37 37 #include "uffd-common.h" 38 38 39 + uint64_t features; 40 + 39 41 #define BOUNCE_RANDOM (1<<0) 40 42 #define BOUNCE_RACINGFAULTS (1<<1) 41 43 #define BOUNCE_VERIFY (1<<2) ··· 247 245 unsigned long nr; 248 246 struct uffd_args args[nr_cpus]; 249 247 uint64_t mem_size = nr_pages * page_size; 248 + int flags = 0; 250 249 251 250 memset(args, 0, sizeof(struct uffd_args) * nr_cpus); 252 251 253 - if (uffd_test_ctx_init(UFFD_FEATURE_WP_UNPOPULATED, NULL)) 252 + if (features & UFFD_FEATURE_WP_UNPOPULATED && test_type == TEST_ANON) 253 + flags = UFFD_FEATURE_WP_UNPOPULATED; 254 + 255 + if (uffd_test_ctx_init(flags, NULL)) 254 256 err("context init failed"); 255 257 256 258 if (posix_memalign(&area, page_size, page_size)) ··· 389 383 390 384 static void parse_test_type_arg(const char *raw_type) 391 385 { 392 - uint64_t features = UFFD_API_FEATURES; 393 - 394 386 set_test_type(raw_type); 395 387 396 388 if (!test_type) ··· 411 407 * feature. 412 408 */ 413 409 414 - if (userfaultfd_open(&features)) 415 - err("Userfaultfd open failed"); 410 + if (uffd_get_features(&features)) 411 + err("failed to get available features"); 416 412 417 413 test_uffdio_wp = test_uffdio_wp && 418 414 (features & UFFD_FEATURE_PAGEFAULT_FLAG_WP);