Re: [PATCH v1 06/11] mm: support GUP-triggered unsharing via FAULT_FLAG_UNSHARE (!hugetlb)

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
2021-12-21 18:31:22
Also in
linux-kselftest, linux-mm, lkml
Reply to
Jan Kara, 2021-12-21
On Tue, Dec 21, 2021 at 10:07 AM Jan Kara [off-list ref] wrote:
For record we always intended (and still intend) to make O_DIRECT use
FOLL_PIN. Just it is tricky because some users mix pages pinned with GUP
and pages acquired through get_page() in a single bio (such as zero page)
and thus it is non-trivial to do the right thing on IO completion (unpin or
just put_page).
Side note: the new "exclusive VM" bit wouldn't _solve_ this issue, but
it might make it much easier to debug and catch.

If we only set the exclusive VM bit on pages that get mapped into user
space, and we guarantee that GUP only looks up such pages, then we can
also add a debug test to the "unpin" case that the bit is still set.

And that would catch anybody who ends up using other pages for
unpin(), and you could have a WARN_ON() for it (obviously also trigger
on the page count being too small to unpin).

That way, at least from a kernel debugging and development standpoint
it would make it easy to see "ok, this unpinning got a page that
wasn't pinned", and it would help find these cases where some
situation had used just a get_page() rather than a pin to get a page
pointer.

No?

                  Linus
Thread (137 messages) 137 messages, 11 authors, last reply 2022-01-04
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help