Commit a47a7af9 authored by Audra Mitchell's avatar Audra Mitchell Committed by Andrew Morton

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.comSigned-off-by: default avatarAudra 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: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 8ac5dc66
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
#include <asm-generic/unistd.h> #include <asm-generic/unistd.h>
#include "uffd-common.h" #include "uffd-common.h"
uint64_t features;
#define BOUNCE_RANDOM (1<<0) #define BOUNCE_RANDOM (1<<0)
#define BOUNCE_RACINGFAULTS (1<<1) #define BOUNCE_RACINGFAULTS (1<<1)
#define BOUNCE_VERIFY (1<<2) #define BOUNCE_VERIFY (1<<2)
...@@ -245,10 +247,14 @@ static int userfaultfd_stress(void) ...@@ -245,10 +247,14 @@ static int userfaultfd_stress(void)
unsigned long nr; unsigned long nr;
struct uffd_args args[nr_cpus]; struct uffd_args args[nr_cpus];
uint64_t mem_size = nr_pages * page_size; uint64_t mem_size = nr_pages * page_size;
int flags = 0;
memset(args, 0, sizeof(struct uffd_args) * nr_cpus); memset(args, 0, sizeof(struct uffd_args) * nr_cpus);
if (uffd_test_ctx_init(UFFD_FEATURE_WP_UNPOPULATED, NULL)) if (features & UFFD_FEATURE_WP_UNPOPULATED && test_type == TEST_ANON)
flags = UFFD_FEATURE_WP_UNPOPULATED;
if (uffd_test_ctx_init(flags, NULL))
err("context init failed"); err("context init failed");
if (posix_memalign(&area, page_size, page_size)) if (posix_memalign(&area, page_size, page_size))
...@@ -383,8 +389,6 @@ static void set_test_type(const char *type) ...@@ -383,8 +389,6 @@ static void set_test_type(const char *type)
static void parse_test_type_arg(const char *raw_type) static void parse_test_type_arg(const char *raw_type)
{ {
uint64_t features = UFFD_API_FEATURES;
set_test_type(raw_type); set_test_type(raw_type);
if (!test_type) if (!test_type)
...@@ -407,8 +411,8 @@ static void parse_test_type_arg(const char *raw_type) ...@@ -407,8 +411,8 @@ static void parse_test_type_arg(const char *raw_type)
* feature. * feature.
*/ */
if (userfaultfd_open(&features)) if (uffd_get_features(&features))
err("Userfaultfd open failed"); err("failed to get available features");
test_uffdio_wp = test_uffdio_wp && test_uffdio_wp = test_uffdio_wp &&
(features & UFFD_FEATURE_PAGEFAULT_FLAG_WP); (features & UFFD_FEATURE_PAGEFAULT_FLAG_WP);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment