All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Ricardo Branco <rbranco@suse.de>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2] userfaultfd: Use two-step handshake to probe features
Date: Mon, 4 May 2026 17:50:12 +0200	[thread overview]
Message-ID: <afjANI7jr23hP4IJ@yuki.lan> (raw)
In-Reply-To: <20260415080623.164440-1-rbranco@suse.de>

Hi!
> +	/*
> +	 * Two-step handshake to check if feature is available
> +	 */

Please no obvious comments like this.

> +	uffd = SAFE_USERFAULTFD(O_CLOEXEC | O_NONBLOCK, false);
> +	uffdio_api.api = UFFD_API;
> +	SAFE_IOCTL(uffd, UFFDIO_API, &uffdio_api);
> +	if (!(uffdio_api.features & UFFD_FEATURE_PAGEFAULT_FLAG_WP))
> +		tst_brk(TCONF, "UFFD_FEATURE_PAGEFAULT_FLAG_WP not supported");
> +	SAFE_CLOSE(uffd);

I do not get why are we adding this code when we do the same just a few
lines below. Shouldn't just this suffice?

diff --git a/testcases/kernel/syscalls/userfaultfd/userfaultfd05.c b/testcases/kernel/syscalls/userfaultfd/userfaultfd05.c
index e25a227cf..b19132d0c 100644
--- a/testcases/kernel/syscalls/userfaultfd/userfaultfd05.c
+++ b/testcases/kernel/syscalls/userfaultfd/userfaultfd05.c
@@ -95,6 +95,9 @@ static void run(void)
 
        SAFE_IOCTL(uffd, UFFDIO_API, &uffdio_api);
 
+       if (!(uffdio_api.features & UFFD_FEATURE_PAGEFAULT_FLAG_WP))
+               tst_brk(TCONF, "UFFD_FEATURE_PAGEFAULT_FLAG_WP not supported");
+
        uffdio_register.range.start = (unsigned long) page;
        uffdio_register.range.len = page_size;
        uffdio_register.mode = UFFDIO_REGISTER_MODE_WP;


> index 5b1252c35..e1b3c2f6f 100644
> --- a/testcases/kernel/syscalls/userfaultfd/userfaultfd06.c
> +++ b/testcases/kernel/syscalls/userfaultfd/userfaultfd06.c
> @@ -97,18 +97,25 @@ static void run(void)
>  
>  	poison_fault_seen = 0;
>  	sigbus_seen = 0;
> -	set_pages();
>  
> +	/*
> +	 * Two-step handshake to check if feature is available
> +	 */
>  	uffd = SAFE_USERFAULTFD(O_CLOEXEC | O_NONBLOCK, false);
> +	uffdio_api.api = UFFD_API;
> +	SAFE_IOCTL(uffd, UFFDIO_API, &uffdio_api);
> +	if (!(uffdio_api.features & UFFD_FEATURE_POISON))
> +		tst_brk(TCONF, "UFFD_FEATURE_POISON not supported");
> +	SAFE_CLOSE(uffd);
>  
> +	set_pages();
> +
> +	uffd = SAFE_USERFAULTFD(O_CLOEXEC | O_NONBLOCK, false);
>  	uffdio_api.api = UFFD_API;
>  	uffdio_api.features = UFFD_FEATURE_POISON;
>
>  	SAFE_IOCTL(uffd, UFFDIO_API, &uffdio_api);
>  
> -	if (!(uffdio_api.features & UFFD_FEATURE_POISON))
> -		tst_brk(TCONF, "UFFD_FEATURE_POISON not supported");
> -

This does not seem to make any sense. The code already checks for the
feature, or do I miss something?

>  	uffdio_register.range.start = (unsigned long) page;
>  	uffdio_register.range.len = page_size;
>  	uffdio_register.mode = UFFDIO_REGISTER_MODE_MISSING;
> -- 
> 2.53.0
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  parent reply	other threads:[~2026-05-04 15:50 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-11  9:24 [LTP] [PATCH] userfaultfd: Use two-step handshake to probe features Ricardo Branco
2026-04-11  9:46 ` [LTP] " acervesato
2026-04-11 10:39 ` acervesato
2026-04-15  8:06 ` [LTP] [PATCH v2] " Ricardo Branco
2026-04-15  9:24   ` [LTP] " linuxtestproject.agent
2026-05-04 15:50   ` Cyril Hrubis [this message]
2026-05-04 15:59     ` [LTP] [PATCH v2] " Ricardo Branco
2026-05-04 17:48       ` Cyril Hrubis
2026-05-05 11:27         ` Ricardo Branco
2026-05-05 12:07           ` Cyril Hrubis
2026-05-07  8:32             ` Ricardo Branco

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=afjANI7jr23hP4IJ@yuki.lan \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=rbranco@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.