From: Brian Foster <bfoster@redhat.com>
To: linux-xfs@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org
Subject: [PATCH v3 1/3] iomap: resched ioend completion when in non-atomic context
Date: Mon, 17 May 2021 13:17:20 -0400 [thread overview]
Message-ID: <20210517171722.1266878-2-bfoster@redhat.com> (raw)
In-Reply-To: <20210517171722.1266878-1-bfoster@redhat.com>
The iomap ioend mechanism has the ability to construct very large,
contiguous bios and/or bio chains. This has been reported to lead to
soft lockup warnings in bio completion due to the amount of page
processing that occurs. Update the ioend completion path with a
parameter to indicate atomic context and insert a cond_resched()
call to avoid soft lockups in either scenario.
Signed-off-by: Brian Foster <bfoster@redhat.com>
---
fs/iomap/buffered-io.c | 15 +++++++++------
fs/xfs/xfs_aops.c | 2 +-
include/linux/iomap.h | 2 +-
3 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index 414769a6ad11..642422775e4e 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -1061,7 +1061,7 @@ iomap_finish_page_writeback(struct inode *inode, struct page *page,
* ioend after this.
*/
static void
-iomap_finish_ioend(struct iomap_ioend *ioend, int error)
+iomap_finish_ioend(struct iomap_ioend *ioend, int error, bool atomic)
{
struct inode *inode = ioend->io_inode;
struct bio *bio = &ioend->io_inline_bio;
@@ -1084,9 +1084,12 @@ iomap_finish_ioend(struct iomap_ioend *ioend, int error)
next = bio->bi_private;
/* walk each page on bio, ending page IO on them */
- bio_for_each_segment_all(bv, bio, iter_all)
+ bio_for_each_segment_all(bv, bio, iter_all) {
iomap_finish_page_writeback(inode, bv->bv_page, error,
bv->bv_len);
+ if (!atomic)
+ cond_resched();
+ }
bio_put(bio);
}
/* The ioend has been freed by bio_put() */
@@ -1099,17 +1102,17 @@ iomap_finish_ioend(struct iomap_ioend *ioend, int error)
}
void
-iomap_finish_ioends(struct iomap_ioend *ioend, int error)
+iomap_finish_ioends(struct iomap_ioend *ioend, int error, bool atomic)
{
struct list_head tmp;
list_replace_init(&ioend->io_list, &tmp);
- iomap_finish_ioend(ioend, error);
+ iomap_finish_ioend(ioend, error, atomic);
while (!list_empty(&tmp)) {
ioend = list_first_entry(&tmp, struct iomap_ioend, io_list);
list_del_init(&ioend->io_list);
- iomap_finish_ioend(ioend, error);
+ iomap_finish_ioend(ioend, error, atomic);
}
}
EXPORT_SYMBOL_GPL(iomap_finish_ioends);
@@ -1178,7 +1181,7 @@ static void iomap_writepage_end_bio(struct bio *bio)
{
struct iomap_ioend *ioend = bio->bi_private;
- iomap_finish_ioend(ioend, blk_status_to_errno(bio->bi_status));
+ iomap_finish_ioend(ioend, blk_status_to_errno(bio->bi_status), true);
}
/*
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 9b08db45ce85..84cd6cf46b12 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -123,7 +123,7 @@ xfs_end_ioend(
if (!error && xfs_ioend_is_append(ioend))
error = xfs_setfilesize(ip, ioend->io_offset, ioend->io_size);
done:
- iomap_finish_ioends(ioend, error);
+ iomap_finish_ioends(ioend, error, false);
memalloc_nofs_restore(nofs_flag);
}
diff --git a/include/linux/iomap.h b/include/linux/iomap.h
index d202fd2d0f91..07f3f4e69084 100644
--- a/include/linux/iomap.h
+++ b/include/linux/iomap.h
@@ -232,7 +232,7 @@ struct iomap_writepage_ctx {
const struct iomap_writeback_ops *ops;
};
-void iomap_finish_ioends(struct iomap_ioend *ioend, int error);
+void iomap_finish_ioends(struct iomap_ioend *ioend, int error, bool atomic);
void iomap_ioend_try_merge(struct iomap_ioend *ioend,
struct list_head *more_ioends,
void (*merge_private)(struct iomap_ioend *ioend,
--
2.26.3
next prev parent reply other threads:[~2021-05-17 17:17 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-17 17:17 [PATCH v3 0/3] iomap: avoid soft lockup warnings on large ioends Brian Foster
2021-05-17 17:17 ` Brian Foster [this message]
2021-05-17 17:54 ` [PATCH v3 1/3] iomap: resched ioend completion when in non-atomic context Matthew Wilcox
2021-05-18 11:38 ` Brian Foster
2021-05-20 21:58 ` Darrick J. Wong
2021-05-24 11:57 ` Brian Foster
2021-05-24 16:53 ` Darrick J. Wong
2021-05-26 1:19 ` Darrick J. Wong
2021-05-22 7:45 ` Ming Lei
2021-05-24 11:57 ` Brian Foster
2021-05-24 14:11 ` Ming Lei
2021-05-17 17:17 ` [PATCH v3 2/3] xfs: kick large ioends to completion workqueue Brian Foster
2021-05-26 1:20 ` Darrick J. Wong
2021-05-17 17:17 ` [PATCH RFC v3 3/3] iomap: bound ioend size to 4096 pages Brian Foster
2021-05-19 13:28 ` Christoph Hellwig
2021-05-19 14:52 ` Brian Foster
2021-05-20 23:27 ` Darrick J. Wong
2021-05-24 12:02 ` Brian Foster
2021-05-25 4:20 ` Darrick J. Wong
2021-05-25 4:29 ` Damien Le Moal
2021-05-25 7:13 ` Dave Chinner
2021-05-25 9:07 ` Andreas Gruenbacher
2021-05-26 2:12 ` Matthew Wilcox
2021-05-26 3:32 ` Darrick J. Wong
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=20210517171722.1266878-2-bfoster@redhat.com \
--to=bfoster@redhat.com \
--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).