mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tao Yu <tao1.yu@intel.com>
To: tj@kernel.org, josef@toxicpanda.com, axboe@kernel.dk
Cc: cgroups@vger.kernel.org, linux-block@vger.kernel.org,
	linux-kernel@vger.kernel.org, Tao Yu <tao1.yu@intel.com>,
	syzbot+144a1c0e22e53a08ef5a@syzkaller.appspotmail.com,
	stable@vger.kernel.org
Subject: [PATCH] blk-cgroup: use GFP_NOIO for radix tree preload in blkg_conf_prep
Date: Mon, 31 Aug 2026 13:57:16 +0800	[thread overview]
Message-ID: <20260831055716.773354-1-tao1.yu@intel.com> (raw)

blkg_conf_prep() allocates a new blkg with GFP_NOIO after dropping
queue_lock, but still preloads the radix tree node with GFP_KERNEL while
q->blkcg_mutex is held.

GFP_KERNEL may enter direct reclaim and acquire fs_reclaim, which adds
the dependency

  q->blkcg_mutex -> fs_reclaim

This completes a circular locking dependency with the existing path

  fs_reclaim -> q->q_usage_counter -> q->blkcg_mutex

and triggers a lockdep warning when configuring blkcg policies.

Use GFP_NOIO for radix_tree_preload() so that the preload context matches
the rest of this allocation path and does not recurse into reclaim while
q->blkcg_mutex is held.

Reported-by: syzbot+144a1c0e22e53a08ef5a@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=144a1c0e22e53a08ef5a
Fixes: f255c19b3ab46 ("blk-cgroup: Pre-allocate tree node on blkg_conf_prep")
Cc: stable@vger.kernel.org
Signed-off-by: Tao Yu <tao1.yu@intel.com>
---
 block/blk-cgroup.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 2b5c29434e426..27e00180e4cc1 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -873,7 +873,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
 			parent = blkcg_parent(parent);
 		}
 
-		/* Drop locks to do new blkg allocation with GFP_KERNEL. */
+		/* Drop queue_lock to do new blkg allocation with GFP_NOIO. */
 		spin_unlock_irq(&q->queue_lock);
 
 		new_blkg = blkg_alloc(pos, disk, GFP_NOIO);
@@ -882,7 +882,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
 			goto fail_exit;
 		}
 
-		if (radix_tree_preload(GFP_KERNEL)) {
+		if (radix_tree_preload(GFP_NOIO)) {
 			blkg_free(new_blkg);
 			ret = -ENOMEM;
 			goto fail_exit;
-- 
2.34.1


             reply	other threads:[~2026-08-31  5:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31  5:57 Tao Yu [this message]
2026-08-31 11:00 ` yu kuai

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=20260831055716.773354-1-tao1.yu@intel.com \
    --to=tao1.yu@intel.com \
    --cc=axboe@kernel.dk \
    --cc=cgroups@vger.kernel.org \
    --cc=josef@toxicpanda.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=syzbot+144a1c0e22e53a08ef5a@syzkaller.appspotmail.com \
    --cc=tj@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

all inboxes | Powered by JetHome®