From: David Howells <dhowells@redhat.com>
To: Lorenzo Stoakes <lstoakes@gmail.com>
Cc: dhowells@redhat.com, Christoph Hellwig <hch@infradead.org>,
David Hildenbrand <david@redhat.com>,
Jens Axboe <axboe@kernel.dk>, Al Viro <viro@zeniv.linux.org.uk>,
Matthew Wilcox <willy@infradead.org>, Jan Kara <jack@suse.cz>,
Jeff Layton <jlayton@kernel.org>,
Jason Gunthorpe <jgg@nvidia.com>,
Logan Gunthorpe <logang@deltatee.com>,
Hillf Danton <hdanton@sina.com>,
Christian Brauner <brauner@kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [RFC PATCH v2 1/3] mm: Don't pin ZERO_PAGE in pin_user_pages()
Date: Fri, 26 May 2023 09:43:35 +0100 [thread overview]
Message-ID: <520730.1685090615@warthog.procyon.org.uk> (raw)
In-Reply-To: <89c7f535-8fc5-4480-845f-de94f335d332@lucifer.local>
Lorenzo Stoakes <lstoakes@gmail.com> wrote:
> I guess we're not quite as concerned about FOLL_GET because FOLL_GET should
> be ephemeral and FOLL_PIN (horrifically) adds GUP_PIN_COUNTING_BIAS each
> time?
It's not that - it's that iov_iter_get_pages*() is a lot more commonly used at
the moment, and we'd have to find *all* the places that things using that hand
refs around.
iov_iter_extract_pages(), on the other hand, is only used in two places with
these patches and the pins are always released with unpin_user_page*() so it's
a lot easier to audit.
I could modify put_page(), folio_put(), etc. to ignore the zero pages, but
that might have a larger performance impact.
> > + if (is_zero_page(page))
> > + return page_folio(page);
> > +
>
> This will capture huge page cases too which have folio->_pincount and thus
> don't suffer the GUP_PIN_COUNTING_BIAS issue, however it is equally logical
> to simply skip these when pinning.
I'm not sure I understand. The zero page(s) is/are single-page folios?
> This does make me think that we should just skip pinning for FOLL_GET cases
> too - there's literally no sane reason we should be pinning zero pages in
> any case (unless I'm missing something!)
As mentioned above, there's a code auditing issue and a potential performance
issue, depending on how it's done.
> Another nitty thing that I noticed is, in is_longterm_pinnable_page():-
>
> /* The zero page may always be pinned */
> if (is_zero_pfn(page_to_pfn(page)))
> return true;
>
> Which, strictly speaking I suppose we are 'pinning' it or rather allowing
> the pin to succeed without actually pinning, but to be super pedantic
> perhaps it's worth updating this comment too.
Yeah. It is "pinnable" but no pin will actually be added.
David
next prev parent reply other threads:[~2023-05-26 8:43 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-25 22:39 [RFC PATCH v2 0/3] block: Make old dio use iov_iter_extract_pages() and page pinning David Howells
2023-05-25 22:39 ` [RFC PATCH v2 1/3] mm: Don't pin ZERO_PAGE in pin_user_pages() David Howells
2023-05-26 8:10 ` Lorenzo Stoakes
2023-05-26 8:17 ` Christoph Hellwig
2023-05-26 8:22 ` Christoph Hellwig
2023-05-26 8:27 ` Lorenzo Stoakes
2023-05-26 8:29 ` David Howells
2023-05-26 8:43 ` David Howells [this message]
2023-05-26 8:58 ` Lorenzo Stoakes
2023-05-26 9:15 ` David Howells
2023-05-26 9:23 ` Lorenzo Stoakes
2023-05-26 9:24 ` David Hildenbrand
2023-05-25 22:39 ` [RFC PATCH v2 2/3] mm: Provide a function to get an additional pin on a page David Howells
2023-05-26 2:29 ` Linus Torvalds
2023-05-26 5:50 ` David Howells
2023-05-26 8:20 ` Christoph Hellwig
2023-05-26 8:31 ` David Howells
2023-05-25 22:39 ` [RFC PATCH v2 3/3] block: Use iov_iter_extract_pages() and page pinning in direct-io.c David Howells
2023-05-26 8:26 ` Christoph Hellwig
2023-05-26 8:33 ` David Howells
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=520730.1685090615@warthog.procyon.org.uk \
--to=dhowells@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=david@redhat.com \
--cc=hch@infradead.org \
--cc=hdanton@sina.com \
--cc=jack@suse.cz \
--cc=jgg@nvidia.com \
--cc=jlayton@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=logang@deltatee.com \
--cc=lstoakes@gmail.com \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.org \
/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