From: stsp <stsp2@yandex.ru>
To: Peter Xu <peterx@redhat.com>
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 19:16:19 +0300 [thread overview]
Message-ID: <3d4c1c59-4b01-4fa3-af84-e2d84f4ebf44@yandex.ru> (raw)
In-Reply-To: <Z0XvwitcZ6ujoV9Y@x1n>
26.11.2024 18:56, Peter Xu пишет:
> 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.
Ok, thanks for info.
man page doesn't seem to describe
the multi-process case, so both fork()
and SCM_RIGHTS were just a guesses
on my side, one of which worked.
Probably something to add to the doc.
The last problem I had (last one, I promise! :)
is that if I remove O_NONBLOCK, then
the entire app hangs. It turns out, w/o
O_NONBLOCK, userfaultfd's fd awakes
the select() call with the ready-to-read
descriptor at the very beginning, long
before any fault is detected. Then it
goes to read() and blocks forever. My
code is not prepared for read() blocking
after select().
I then checked and double-checked
and re-checked that with O_NONBLOCK
nothing like that happens at all: select()
is not awaken until the faults are coming.
It could be that select awakes anyway
but read() doesn block, but no, its not
the case. In nonblock mode select()
awakes only when it should. And in
blocking mode - it awakes immediately,
leading to a hang.
Is this a bug?
next prev parent reply other threads:[~2024-11-26 16:16 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 [this message]
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=3d4c1c59-4b01-4fa3-af84-e2d84f4ebf44@yandex.ru \
--to=stsp2@yandex.ru \
--cc=Usama.Anjum@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterx@redhat.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®