From: Johannes Weiner <hannes@cmpxchg.org>
To: Christoph Hellwig <hch@infradead.org>
Cc: Pavel Begunkov <asml.silence@gmail.com>,
Matthew Wilcox <willy@infradead.org>,
Ming Lei <ming.lei@redhat.com>, Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] block: add bio_iov_iter_nvecs for figuring out nr_vecs
Date: Thu, 10 Dec 2020 08:18:26 -0500 [thread overview]
Message-ID: <20201210131826.GC264602@cmpxchg.org> (raw)
In-Reply-To: <20201204124849.GA8768@infradead.org>
Sorry, I'm only now getting back to this.
On Fri, Dec 04, 2020 at 12:48:49PM +0000, Christoph Hellwig wrote:
> On Thu, Dec 03, 2020 at 05:36:07PM -0500, Johannes Weiner wrote:
> > Correct, it's only interesting for pages under LRU management - page
> > cache and swap pages. It should not matter for direct IO.
> >
> > The VM uses the page flag to tell the difference between cold faults
> > (empty cache startup e.g.), and thrashing pages which are being read
> > back not long after they have been reclaimed. This influences reclaim
> > behavior, but can also indicate a general lack of memory.
>
> I really wonder if we should move setting the flag out of bio_add_page
> and into the writeback code, as it will do the wrong things for
> non-writeback I/O, that is direct I/O or its in-kernel equivalents.
Good point. When somebody does direct IO reads into a user page that
happens to have the flag set, we misattribute submission delays.
There is some background discussion from when I first submitted the
patch, which did the annotations on the writeback/page cache side:
https://lore.kernel.org/lkml/20190722201337.19180-1-hannes@cmpxchg.org/
Fragility is a concern, as this is part of the writeback code that is
spread out over several fs-specific implementations, and it's somewhat
easy to get the annotation wrong.
Some possible options I can think of:
1 open-coding the submit_bio() annotations in writeback code, like the original patch
pros: no bio layer involvement at all - no BIO_WORKINGSET flag
cons: lots of copy-paste code & comments
2 open-coding if (PageWorkingset()) bio_set_flag(BIO_WORKINGSET) in writeback code
pros: slightly less complex callsite code, eliminates read check in submit_bio()
cons: still somewhat copy-pasty (but the surrounding code is as well)
3 adding a bio_add_page_memstall() as per Dave in the original patch thread
pros: minimal churn and self-documenting (may need a better name)
cons: easy to incorrectly use raw bio_add_page() in writeback code
4 writeback & direct-io versions for bio_add_page()
pros: hard to misuse
cons: awkward interface/layering
5 flag bio itself as writeback or direct-io (BIO_BUFFERED?)
pros: single version of bio_add_page()
cons: easy to miss setting the flag, similar to 3
Personally, I'm torn between 2 and 5. What do you think?
next prev parent reply other threads:[~2020-12-10 13:21 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-01 12:06 [PATCH] block: add bio_iov_iter_nvecs for figuring out nr_vecs Ming Lei
2020-12-01 12:52 ` Matthew Wilcox
2020-12-01 12:59 ` Christoph Hellwig
2020-12-01 13:17 ` Pavel Begunkov
2020-12-01 13:32 ` Christoph Hellwig
2020-12-01 13:36 ` Pavel Begunkov
2020-12-01 13:45 ` Christoph Hellwig
2020-12-01 13:48 ` Pavel Begunkov
2020-12-02 2:10 ` Ming Lei
2020-12-02 8:02 ` Christoph Hellwig
2020-12-03 22:36 ` Johannes Weiner
2020-12-03 23:43 ` Pavel Begunkov
2020-12-04 12:48 ` Christoph Hellwig
2020-12-10 13:18 ` Johannes Weiner [this message]
2020-12-11 13:22 ` Pavel Begunkov
2020-12-02 1:46 ` Ming Lei
2020-12-02 14:06 ` Pavel Begunkov
2020-12-02 15:02 ` Christoph Hellwig
2020-12-02 16:56 ` Jens Axboe
2020-12-07 18:07 ` Pavel Begunkov
2020-12-08 1:21 ` Ming Lei
2020-12-08 1:50 ` Ming Lei
2020-12-08 2:54 ` Pavel Begunkov
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=20201210131826.GC264602@cmpxchg.org \
--to=hannes@cmpxchg.org \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=hch@infradead.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=ming.lei@redhat.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.