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 19:48:19 +0200	[thread overview]
Message-ID: <afjb4yWvM8Abh98q@yuki.lan> (raw)
In-Reply-To: <bc75c487-59db-47a8-a2f3-db860919b35b@suse.de>

Hi!
> >> +	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?
> 
> That's why the comment is needed because it isn't obvious.
> 
> We need to do the 2 step handshake, first with uffdio_api.features set 
> to zero, then again with the desired features.

The obviously the comment is not useful because it does not explain
anything :-).

Looking at the kernel code, it seems to set the output flags
uncoditionally so we can use that.

Or check for EINVAL when we pass unsupported flags.

However I would put this code into a common header and call it only in
the test setup (so that it's not executed on each test iteration).

#define CHECK_UFFD_FLAG(flag) do { \
        ... \
	if (!(uffdio_api.features & (flag))) \
		tst_brk(TCONF, #flag " not supported"); \
	... \
} while (0)


-- 
Cyril Hrubis
chrubis@suse.cz

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

  reply	other threads:[~2026-05-04 17:48 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   ` [LTP] [PATCH v2] " Cyril Hrubis
2026-05-04 15:59     ` Ricardo Branco
2026-05-04 17:48       ` Cyril Hrubis [this message]
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=afjb4yWvM8Abh98q@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.