public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>,
	Christoph Hellwig <[email protected]>,
	Matthew Wilcox <[email protected]>,
	Ming Lei <[email protected]>,
	Johannes Weiner <[email protected]>,
	Alexander Viro <[email protected]>,
	"Darrick J . Wong" <[email protected]>,
	"Martin K . Petersen" <[email protected]>,
	Jonathan Corbet <[email protected]>,
	[email protected], [email protected],
	[email protected], [email protected],
	[email protected], [email protected],
	[email protected]
Subject: [PATCH v1 4/6] block/psi: remove PSI annotations from direct IO
Date: Tue, 15 Dec 2020 00:20:23 +0000	[thread overview]
Message-ID: <1d3cf86668e44b3a3d35b5dbe759a086a157e434.1607976425.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

As reported, we must not do pressure stall information accounting for
direct IO, because otherwise it tells that it's thrashing a page when
actually doing IO on hot data.

Apparently, bio_iov_iter_get_pages() is used only by paths doing direct
IO, so just make it avoid setting BIO_WORKINGSET, it also saves us CPU
cycles on doing that. For fs/direct-io.c just clear the flag before
submit_bio(), it's not of much concern performance-wise.

Reported-by: Christoph Hellwig <[email protected]>
Suggested-by: Christoph Hellwig <[email protected]>
Suggested-by: Johannes Weiner <[email protected]>
Signed-off-by: Pavel Begunkov <[email protected]>
---
 block/bio.c    | 25 ++++++++++++++++---------
 fs/direct-io.c |  2 ++
 2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/block/bio.c b/block/bio.c
index 4a8f77bb3956..3192358c411f 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -963,18 +963,22 @@ EXPORT_SYMBOL_GPL(bio_release_pages);
 static int __bio_iov_bvec_add_pages(struct bio *bio, struct iov_iter *iter)
 {
 	const struct bio_vec *bv = iter->bvec;
-	unsigned int len;
-	size_t size;
+	struct page *page = bv->bv_page;
+	bool same_page = false;
+	unsigned int off, len;
 
 	if (WARN_ON_ONCE(iter->iov_offset > bv->bv_len))
 		return -EINVAL;
 
 	len = min_t(size_t, bv->bv_len - iter->iov_offset, iter->count);
-	size = bio_add_page(bio, bv->bv_page, len,
-				bv->bv_offset + iter->iov_offset);
-	if (unlikely(size != len))
-		return -EINVAL;
-	iov_iter_advance(iter, size);
+	off = bv->bv_offset + iter->iov_offset;
+
+	if (!__bio_try_merge_page(bio, page, len, off, &same_page)) {
+		if (bio_full(bio, len))
+			return -EINVAL;
+		bio_add_page_noaccount(bio, page, len, off);
+	}
+	iov_iter_advance(iter, len);
 	return 0;
 }
 
@@ -1023,8 +1027,8 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
 				put_page(page);
 		} else {
 			if (WARN_ON_ONCE(bio_full(bio, len)))
-                                return -EINVAL;
-			__bio_add_page(bio, page, len, offset);
+				return -EINVAL;
+			bio_add_page_noaccount(bio, page, len, offset);
 		}
 		offset = 0;
 	}
@@ -1099,6 +1103,9 @@ static int __bio_iov_append_get_pages(struct bio *bio, struct iov_iter *iter)
  * fit into the bio, or are requested in @iter, whatever is smaller. If
  * MM encounters an error pinning the requested pages, it stops. Error
  * is returned only if 0 pages could be pinned.
+ *
+ * It also doesn't set BIO_WORKINGSET, so is intended for direct IO. If used
+ * otherwise the caller is responsible to do that to keep PSI happy.
  */
 int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
 {
diff --git a/fs/direct-io.c b/fs/direct-io.c
index d53fa92a1ab6..914a7f600ecd 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -426,6 +426,8 @@ static inline void dio_bio_submit(struct dio *dio, struct dio_submit *sdio)
 	unsigned long flags;
 
 	bio->bi_private = dio;
+	/* PSI is only for paging IO */
+	bio_clear_flag(bio, BIO_WORKINGSET);
 
 	spin_lock_irqsave(&dio->bio_lock, flags);
 	dio->refcount++;
-- 
2.24.0


  parent reply	other threads:[~2020-12-15  0:28 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-15  0:20 [PATCH v1 0/6] no-copy bvec Pavel Begunkov
2020-12-15  0:20 ` [PATCH v1 1/6] target/file: allocate the bvec array as part of struct target_core_file_cmd Pavel Begunkov
2020-12-15  0:20 ` [PATCH v1 2/6] iov_iter: optimise bvec iov_iter_advance() Pavel Begunkov
2020-12-15  9:37   ` David Laight
2020-12-15 11:23     ` Pavel Begunkov
2020-12-15 13:54       ` David Laight
2020-12-15 13:56         ` Pavel Begunkov
2020-12-22 14:03   ` Christoph Hellwig
2020-12-15  0:20 ` [PATCH v1 3/6] bio: deduplicate adding a page into bio Pavel Begunkov
2020-12-22 14:04   ` Christoph Hellwig
2020-12-15  0:20 ` Pavel Begunkov [this message]
2020-12-15  0:56   ` [PATCH v1 4/6] block/psi: remove PSI annotations from direct IO Dave Chinner
2020-12-15  1:03     ` Pavel Begunkov
2020-12-15  1:33       ` Dave Chinner
2020-12-15 11:41         ` Pavel Begunkov
2020-12-22 14:07   ` Christoph Hellwig
2020-12-15  0:20 ` [PATCH v1 5/6] bio: add a helper calculating nr segments to alloc Pavel Begunkov
2020-12-15  1:00   ` Dave Chinner
2020-12-15  1:07     ` Pavel Begunkov
2020-12-15  1:09     ` Dave Chinner
2020-12-22 14:07   ` Christoph Hellwig
2020-12-15  0:20 ` [PATCH v1 6/6] block/iomap: don't copy bvec for direct IO Pavel Begunkov
2020-12-15  1:09   ` Dave Chinner
2020-12-15  1:15     ` Pavel Begunkov
2020-12-22 14:15   ` Christoph Hellwig
2020-12-15  1:41 ` [PATCH v1 0/6] no-copy bvec Ming Lei
2020-12-15 11:14   ` Pavel Begunkov
2020-12-15 12:03     ` Ming Lei
2020-12-15 14:05       ` Pavel Begunkov
2020-12-22 14:11         ` Christoph Hellwig
2020-12-23 12:52           ` Pavel Begunkov
2020-12-23 15:51             ` Christoph Hellwig
2020-12-23 16:04               ` James Bottomley
2020-12-23 20:23                 ` Douglas Gilbert
2020-12-23 20:32                   ` Pavel Begunkov
2020-12-24  6:41                     ` Christoph Hellwig
2020-12-24 16:45                       ` Douglas Gilbert
2020-12-24 17:30                   ` James Bottomley

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=1d3cf86668e44b3a3d35b5dbe759a086a157e434.1607976425.git.asml.silence@gmail.com \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /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