From: Chaitanya Kulkarni <chaitanyak@nvidia.com>
To: John Hubbard <jhubbard@nvidia.com>
Cc: Jan Kara <jack@suse.cz>, Christoph Hellwig <hch@lst.de>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>
Subject: Re: RFA (Request for Advice): block/bio: get_user_pages() --> pin_user_pages()
Date: Mon, 24 Jan 2022 10:38:13 +0000 [thread overview]
Message-ID: <cde9acbb-ba1f-16ba-40a8-a5b4fdf2d2dc@nvidia.com> (raw)
In-Reply-To: <20220124100501.gwkaoohkm2b6h7xl@quack3.lan>
On 1/24/22 2:05 AM, Jan Kara wrote:
> External email: Use caution opening links or attachments
>
>
> Hello,
>
> On Sun 23-01-22 23:52:07, John Hubbard wrote:
>> Background: despite having very little experience in the block and bio
>> layers, I am attempting to convert the Direct IO parts of them from
>> using get_user_pages_fast(), to pin_user_pages_fast(). This requires the
>> use of a corresponding special release call: unpin_user_pages(), instead
>> of the generic put_page().
>>
>> Fortunately, Christoph Hellwig has observed [1] (more than once [2]) that
>> only "a little" refactoring is required, because it is *almost* true
>> that bio_release_pages() could just be switched over from calling
>> put_page(), to unpin_user_page(). The "not quite" part is mainly due to
>> the zero page. There are a few write paths that pad zeroes, and they use
>> the zero page.
>>
>> That's where I'd like some advice. How to refactor things, so that the
>> zero page does not end up in the list of pages that bio_release_pages()
>> acts upon?
this maybe wrong but thinking out loudly, have you consider adding a
ZERO_PAGE() address check since it should have a unique same
address for each ZERO_PAGE() (unless I'm totally wrong here) and
using this check you can distinguish between ZERO_PAGE() and
non ZERO_PAGE() on the bio list in bio_release_pages().
>>
>> To ground this in reality, one of the partial call stacks is:
>>
>> do_direct_IO()
>> dio_zero_block()
>> page = ZERO_PAGE(0); <-- This is a problem
>>
>> I'm not sure what to use, instead of that zero page! The zero page
>> doesn't need to be allocated nor tracked, and so any replacement
>> approaches would need either other storage, or some horrid scheme that I
>> won't go so far as to write on the screen. :)
>
> Well, I'm not sure if you consider this ugly but currently we use
> get_page() in that path exactly so that bio_release_pages() does not have
> to care about zero page. So now we could grab pin on the zero page instead
> through try_grab_page() or something like that...
>
>
submit_page_section() does call get_page() in that same path
irrespective of whether it is ZERO_PAGE() or not, this actually
makes accounting much easier and we also avoid any special case
for ZERO_PAGE().
dio_zero_block()
submit_page_section()
get_page()
That also means that on completion of dio for each bio we also call
put_page() from bio_release_page() path.
Honza
> --
> Jan Kara <jack@suse.com>
> SUSE Labs, CR
>
next prev parent reply other threads:[~2022-01-24 10:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-24 7:52 RFA (Request for Advice): block/bio: get_user_pages() --> pin_user_pages() John Hubbard
2022-01-24 10:05 ` Jan Kara
2022-01-24 10:38 ` Chaitanya Kulkarni [this message]
2022-01-24 12:19 ` Jan Kara
2022-01-24 19:34 ` John Hubbard
2022-01-24 21:06 ` Jan Kara
2022-01-24 21:06 ` John Hubbard
2022-01-24 22:17 ` Jan Kara
2022-01-24 13:18 ` Matthew Wilcox
2022-01-24 19:48 ` John Hubbard
2022-01-26 5:42 ` Chaitanya Kulkarni
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=cde9acbb-ba1f-16ba-40a8-a5b4fdf2d2dc@nvidia.com \
--to=chaitanyak@nvidia.com \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=jhubbard@nvidia.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).