From: Peter Xu <peterx@redhat.com>
To: stsp <stsp2@yandex.ru>
Cc: Muhammad Usama Anjum <Usama.Anjum@collabora.com>,
Linux kernel <linux-kernel@vger.kernel.org>
Subject: Re: userfaultfd: two-step UFFDIO_API always gives -EINVAL
Date: Tue, 26 Nov 2024 10:56:50 -0500 [thread overview]
Message-ID: <Z0XvwitcZ6ujoV9Y@x1n> (raw)
In-Reply-To: <2dd0bcee-a594-4de9-b499-a8ad37be155c@yandex.ru>
On Tue, Nov 26, 2024 at 10:32:28AM +0300, stsp wrote:
> 25.11.2024 21:44, Muhammad Usama Anjum пишет:
> > The UFFD_FEATURE_WP_ASYNC was designed for exactly this case.
> > The IOCTL will return you the modified pages. An example of usage
> > can be found in selftest/mm/pagemap_ioctl.c.
> Thank you!
> I studied the examples.
> They are quite clear and good
> for copy/pasting purposes.
>
> I had yet another "problem":
> I tried to create the usefaultfd,
> then register the API and fork()
> the process. In child I do UFFDIO_REGISTER,
This doesn't sound like the right thing to do.. as the fd (returned from
syscall(userfaultfd)) should be linked to a specific mm. If the parent
invoked that syscall, it's linked to the parent address space, not child.
You may want to do syscall(userfalut) in child process, then pass it over
with scm rights. Otherwise IIUC the trap will be armed on parent virtual
address space.
> but the parent can't see that.
> So instead of copy by fork, I
> had to use SCM_RIGHTS.
> Is this expected, or should it
> work fine with forked fd? That
> would be a bit simpler than to
> apply to SCM_RIGHTS tricks.
If child is the process you'd like to monitor, I think scm rights is
exactly the right approach. Otherwise you can have a look at
UFFD_FEATURE_EVENT_FORK. However that's not designed for child-only traps,
IIUC.
Thanks,
--
Peter Xu
next prev parent reply other threads:[~2024-11-26 15:57 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-23 15:13 userfaultfd: two-step UFFDIO_API always gives -EINVAL 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 [this message]
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
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=Z0XvwitcZ6ujoV9Y@x1n \
--to=peterx@redhat.com \
--cc=Usama.Anjum@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stsp2@yandex.ru \
/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