From: Axel Rasmussen <axelrasmussen@google.com>
To: Dimitris Siakavaras <jimsiak@cslab.ece.ntua.gr>
Cc: viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, Peter Xu <peterx@redhat.com>,
linux-mm@kvack.org, Axel Rasmussen <axelrasmussen@google.com>
Subject: Re: Using userfaultfd with KVM's async page fault handling causes processes to hung waiting for mmap_lock to be released
Date: Wed, 19 Jul 2023 14:16:31 -0700 [thread overview]
Message-ID: <20230719211631.890995-1-axelrasmussen@google.com> (raw)
In-Reply-To: <79375b71-db2e-3e66-346b-254c90d915e2@cslab.ece.ntua.gr>
Thanks for the detailed report Dimitris! I've CCed the MM mailing list and some
folks who work on userfaultfd.
I took a look at this today, but I haven't quite come up with a solution.
I thought it might be as easy as changing userfaultfd_release() to set released
*after* taking the lock. But no such luck, the ordering is what it is to deal
with another subtle case:
WRITE_ONCE(ctx->released, true);
if (!mmget_not_zero(mm))
goto wakeup;
/*
* Flush page faults out of all CPUs. NOTE: all page faults
* must be retried without returning VM_FAULT_SIGBUS if
* userfaultfd_ctx_get() succeeds but vma->vma_userfault_ctx
* changes while handle_userfault released the mmap_lock. So
* it's critical that released is set to true (above), before
* taking the mmap_lock for writing.
*/
mmap_write_lock(mm);
I think perhaps the right thing to do is to have handle_userfault() release
mmap_lock when it returns VM_FAULT_NOPAGE, and to have GUP deal with that
appropriately? But, some investigation is required to be sure that's okay to do
in the other non-GUP ways we can end up in handle_userfault().
next prev parent reply other threads:[~2023-07-19 21:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-18 14:33 Using userfaultfd with KVM's async page fault handling causes processes to hung waiting for mmap_lock to be released Dimitris Siakavaras
2023-07-19 21:16 ` Axel Rasmussen [this message]
2023-07-19 21:54 ` Axel Rasmussen
2023-07-20 20:06 ` Peter Xu
2025-03-07 7:21 ` Jinjiang Tu
2025-03-07 8:07 ` Jinjiang Tu
2025-03-07 13:11 ` jimsiak
2025-03-07 22:41 ` Peter Xu
2025-03-10 6:40 ` Jinjiang Tu
2025-03-10 18:50 ` Peter Xu
2025-03-11 8:14 ` Jinjiang Tu
2025-03-12 9:18 ` Jinjiang Tu
2025-03-12 14:09 ` 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=20230719211631.890995-1-axelrasmussen@google.com \
--to=axelrasmussen@google.com \
--cc=jimsiak@cslab.ece.ntua.gr \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=peterx@redhat.com \
--cc=viro@zeniv.linux.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).