From: Peter Xu <peterx@redhat.com>
To: stsp <stsp2@yandex.ru>
Cc: Axel Rasmussen <axelrasmussen@google.com>,
Linux kernel <linux-kernel@vger.kernel.org>,
Muhammad Usama Anjum <usama.anjum@collabora.com>,
Mike Rapoport <rppt@kernel.org>
Subject: Re: userfaultfd: two-step UFFDIO_API always gives -EINVAL
Date: Tue, 26 Nov 2024 10:50:40 -0500 [thread overview]
Message-ID: <Z0XuUBqBvUvhQzGn@x1n> (raw)
In-Reply-To: <cfc58081-c49a-4f30-bb39-966c7f18b9eb@yandex.ru>
On Tue, Nov 26, 2024 at 10:39:19AM +0300, stsp wrote:
> Please, just why do you have that UFFD_API
> const? Only to call every screw-up like this
> one, a sailed ship? :)
> Why not to add UFFD_API_v2?
> Then UFFD_API_v3?
> Full binary and source compatibility is
> therefore preserved, you only need to
> update the man page to document the
> latest one.
We could. I'd say we only need UFFDIO_FEATURE to fetch the features, if we
want the interface clean. I just never feel strongly to add it.
"Creating two fds" is indeed awkward, but that isn't too bad either when
the userapp can easily wrap a function to do that, open+close the fd
within. Actually that's what our unit test was doing.
int uffd_get_features(uint64_t *features)
{
struct uffdio_api uffdio_api = { .api = UFFD_API, .features = 0 };
/*
* This should by default work in most kernels; the feature list
* will be the same no matter what we pass in here.
*/
int fd = uffd_open(UFFD_USER_MODE_ONLY);
if (fd < 0)
/* Maybe the kernel is older than user-only mode? */
fd = uffd_open(0);
if (fd < 0)
return fd;
if (ioctl(fd, UFFDIO_API, &uffdio_api)) {
close(fd);
return -errno;
}
*features = uffdio_api.features;
close(fd);
return 0;
}
--
Peter Xu
prev parent reply other threads:[~2024-11-26 15:50 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-23 15:13 stsp
2024-11-25 9:05 ` stsp
2024-11-25 15:59 ` Peter Xu
2024-11-25 16:15 ` stsp
2024-11-25 16:58 ` Peter Xu
2024-11-25 17:07 ` stsp
2024-11-25 17:13 ` Peter Xu
2024-11-25 17:32 ` stsp
2024-11-25 17:44 ` Peter Xu
2024-11-25 18:01 ` stsp
2024-11-25 18:44 ` Muhammad Usama Anjum
2024-11-26 7:32 ` stsp
2024-11-26 15:56 ` Peter Xu
2024-11-26 16:16 ` stsp
2024-11-26 17:41 ` Peter Xu
2024-11-26 9:41 ` stsp
2024-11-25 22:42 ` Axel Rasmussen
2024-11-26 7:39 ` stsp
2024-11-26 15:50 ` Peter Xu [this message]
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=Z0XuUBqBvUvhQzGn@x1n \
--to=peterx@redhat.com \
--cc=axelrasmussen@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rppt@kernel.org \
--cc=stsp2@yandex.ru \
--cc=usama.anjum@collabora.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®