Skip to content

Commit 42ee2fd

Browse files
committed
mm: update uffd-stress to handle EINVAL for unset config features
Conflicts: Missing a number of commits that add new test cases. commit a47a7af Author: Audra Mitchell <audra@redhat.com> Date: Wed Jun 26 09:05:12 2024 -0400 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> JIRA: https://issues.redhat.com/browse/RHEL-39306 Signed-off-by: Nico Pache <npache@redhat.com>
1 parent b06258c commit 42ee2fd

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

tools/testing/selftests/mm/uffd-stress.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "uffd-common.h"
3838

3939
#ifdef __NR_userfaultfd
40+
uint64_t features;
4041

4142
#define BOUNCE_RANDOM (1<<0)
4243
#define BOUNCE_RACINGFAULTS (1<<1)
@@ -249,8 +250,12 @@ static int userfaultfd_stress(void)
249250
unsigned long nr;
250251
struct uffd_args args[nr_cpus];
251252
uint64_t mem_size = nr_pages * page_size;
253+
int flags = 0;
252254

253-
if (uffd_test_ctx_init(UFFD_FEATURE_WP_UNPOPULATED, NULL))
255+
if (features & UFFD_FEATURE_WP_UNPOPULATED && test_type == TEST_ANON)
256+
flags = UFFD_FEATURE_WP_UNPOPULATED;
257+
258+
if (uffd_test_ctx_init(flags, NULL))
254259
err("context init failed");
255260

256261
if (posix_memalign(&area, page_size, page_size))
@@ -382,8 +387,6 @@ static void set_test_type(const char *type)
382387

383388
static void parse_test_type_arg(const char *raw_type)
384389
{
385-
uint64_t features = UFFD_API_FEATURES;
386-
387390
set_test_type(raw_type);
388391

389392
if (!test_type)
@@ -406,8 +409,8 @@ static void parse_test_type_arg(const char *raw_type)
406409
* feature.
407410
*/
408411

409-
if (userfaultfd_open(&features))
410-
err("Userfaultfd open failed");
412+
if (uffd_get_features(&features))
413+
err("failed to get available features");
411414

412415
test_uffdio_wp = test_uffdio_wp &&
413416
(features & UFFD_FEATURE_PAGEFAULT_FLAG_WP);

0 commit comments

Comments
 (0)