From: Matthew Wilcox <willy@infradead.org>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: Christoph Hellwig <hch@infradead.org>,
linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] iomap: Handle memory allocation failure in readahead
Date: Wed, 1 Apr 2020 04:23:21 -0700 [thread overview]
Message-ID: <20200401112321.GF21484@bombadil.infradead.org> (raw)
In-Reply-To: <20200401043125.GD56958@magnolia>
On Tue, Mar 31, 2020 at 09:31:25PM -0700, Darrick J. Wong wrote:
> On Tue, Mar 31, 2020 at 08:04:21PM -0700, Matthew Wilcox wrote:
> > From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
> >
> > bio_alloc() can fail when we use GFP_NORETRY. If it does, allocate
> > a bio large enough for a single page like mpage_readpages() does.
>
> Why does mpage_readpages() do that?
>
> Is this a means to guarantee some kind of forward (readahead?) progress?
> Forgive my ignorance, but if memory is so tight we can't allocate a bio
> for readahead then why not exit having accomplished nothing?
As far as I can tell, it's just a general fallback in mpage_readpages().
* If anything unusual happens, such as:
*
* - encountering a page which has buffers
* - encountering a page which has a non-hole after a hole
* - encountering a page with non-contiguous blocks
*
* then this code just gives up and calls the buffer_head-based read function.
The actual code for that is:
args->bio = mpage_alloc(bdev, blocks[0] << (blkbits - 9),
min_t(int, args->nr_pages,
BIO_MAX_PAGES),
gfp);
if (args->bio == NULL)
goto confused;
...
confused:
if (args->bio)
args->bio = mpage_bio_submit(REQ_OP_READ, op_flags, args->bio);
if (!PageUptodate(page))
block_read_full_page(page, args->get_block);
else
unlock_page(page);
As the comment implies, there are a lot of 'goto confused' cases in
do_mpage_readpage().
Ideally, yes, we'd just give up on reading this page because it's
only readahead, and we shouldn't stall actual work in order to reclaim
memory so we can finish doing readahead. However, handling a partial
page read is painful. Allocating a bio big enough for a single page is
much easier on the mm than allocating a larger bio (for a start, it's a
single allocation, not a pair of allocations), so this is a reasonable
compromise between simplicity of code and quality of implementation.
next prev parent reply other threads:[~2020-04-01 11:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-01 3:04 [PATCH] iomap: Handle memory allocation failure in readahead Matthew Wilcox
2020-04-01 4:31 ` Darrick J. Wong
2020-04-01 11:23 ` Matthew Wilcox [this message]
2020-04-01 16:48 ` Darrick J. Wong
2020-04-01 16:58 ` Matthew Wilcox
2020-04-01 15:50 ` Christoph Hellwig
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=20200401112321.GF21484@bombadil.infradead.org \
--to=willy@infradead.org \
--cc=darrick.wong@oracle.com \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@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).