mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexandre Ghiti <alex@ghiti.fr>
To: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
	cgroups@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	david@kernel.org, Johannes Weiner <hannes@cmpxchg.org>,
	Yosry Ahmed <yosry@kernel.org>, Nhat Pham <nphamcs@gmail.com>,
	Chengming Zhou <chengming.zhou@linux.dev>,
	Jens Axboe <axboe@kernel.dk>, Tejun Heo <tj@kernel.org>,
	Josef Bacik <josef@toxicpanda.com>, Chris Li <chrisl@kernel.org>,
	Kairui Song <kasong@tencent.com>,
	Kemeng Shi <shikemeng@huaweicloud.com>,
	Baoquan He <baoquan.he@linux.dev>, Barry Song <baohua@kernel.org>,
	Youngjun Park <youngjun.park@lge.com>,
	Alexandre Ghiti <alex@ghiti.fr>
Subject: [RFC PATCH 1/4] block: do not issue background swap bios as root
Date: Mon, 28 Sep 2026 10:18:36 +0200	[thread overview]
Message-ID: <20260928081900.4187482-2-alex@ghiti.fr> (raw)
In-Reply-To: <20260928081900.4187482-1-alex@ghiti.fr>

bio_issue_as_root_blkg() issues every REQ_SWAP bio as root, bypassing
the cgroup IO controllers, because reclaim cannot stall indefinitely on
swap writes. Some swap writes are not urgent though: zswap writeback is
best effort.

Such a bio cannot simply drop REQ_SWAP: dm-crypt and dm-thin rely on it
for limit_swap_bios, which caps in-flight swap bios to avoid a memory
deadlock, see commit a666e5c05e7c ("dm: fix deadlock when swapping to
encrypted device").

So let REQ_BACKGROUND, which already marks IO that is not urgent, opt a
swap bio out of being issued as root. No swap bio sets it today, so
nothing changes until a caller does.

Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
---
 block/blk-cgroup.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h
index e67c69839129..02009cb45495 100644
--- a/block/blk-cgroup.h
+++ b/block/blk-cgroup.h
@@ -242,10 +242,16 @@ void blkg_conf_close_bdev(struct blkg_conf_ctx *ctx)
  * the bio and attach the appropriate blkg to the bio.  Then we call this helper
  * and if it is true run with the root blkg for that queue and then do any
  * backcharging to the originating cgroup once the io is complete.
+ *
+ * A REQ_SWAP bio is issued as root because reclaim waits on it, unless it is
+ * also REQ_BACKGROUND, which marks it as not urgent.
  */
 static inline bool bio_issue_as_root_blkg(struct bio *bio)
 {
-	return (bio->bi_opf & (REQ_META | REQ_SWAP)) != 0;
+	blk_opf_t opf = bio->bi_opf;
+
+	return (opf & REQ_META) ||
+	       (opf & (REQ_SWAP | REQ_BACKGROUND)) == REQ_SWAP;
 }
 
 /**
-- 
2.53.0-Meta


  reply	other threads:[~2026-09-28  8:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-28  8:18 [RFC PATCH 0/4] mm/zswap: make shrinker writeback work with iocost Alexandre Ghiti
2026-09-28  8:18 ` Alexandre Ghiti [this message]
2026-09-28  9:44   ` [RFC PATCH 1/4] block: do not issue background swap bios as root Christoph Hellwig
2026-09-29  9:16     ` Alexandre Ghiti
2026-10-05  8:23       ` Christoph Hellwig
2026-09-28  8:18 ` [RFC PATCH 2/4] mm/zswap: turn shrink_memcg_cb()'s argument into a flags word Alexandre Ghiti
2026-09-28  8:18 ` [RFC PATCH 3/4] mm/zswap: allow writeback to be throttled by the cgroup IO controllers Alexandre Ghiti
2026-09-28  8:18 ` [RFC PATCH 4/4] mm/zswap: move reclaim-driven writeback to a kworker Alexandre Ghiti
2026-09-29 13:42   ` Nhat Pham
2026-09-30  8:57     ` Alexandre Ghiti
2026-09-29 13:14 ` [RFC PATCH 0/4] mm/zswap: make shrinker writeback work with iocost Nhat Pham

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=20260928081900.4187482-2-alex@ghiti.fr \
    --to=alex@ghiti.fr \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=baohua@kernel.org \
    --cc=baoquan.he@linux.dev \
    --cc=cgroups@vger.kernel.org \
    --cc=chengming.zhou@linux.dev \
    --cc=chrisl@kernel.org \
    --cc=david@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=josef@toxicpanda.com \
    --cc=kasong@tencent.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nphamcs@gmail.com \
    --cc=shikemeng@huaweicloud.com \
    --cc=tj@kernel.org \
    --cc=yosry@kernel.org \
    --cc=youngjun.park@lge.com \
    /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

all inboxes | Powered by JetHome®