From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796385223; b=aqc0q3E8uxSEpPh1wLQVAAOly4OaakKpFbe8X7pGCA+eTBqOXgybCx91p7jtBPJB1N84 zjPULtJzXrTV+b0RSVTXgkKHl1jw89Q7URCYC37BdoubyCVNpHnXQPHzbBpJb2oLW3A9f x1Kh4Dl5dN22GRdxnrzTjinGsn8SQR4l1SdJBWb0k53liw8cy2f3nF956HipUY4x2juQA fruWQqD4VpthCj7fdtb5pB8EvgjHwHxs1PLiWlUtS++FQOEIGlYoZ5zV4cnrJPgLcqDLX kI7HgAPYd1fPrO64wntOeK7tNrggi13M3kR2GTfL0iw7PqVNLq4eEl1sP/gz7zwC9Qg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385223; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=fDDLAjr1YOt+jbXrQQY2FVraNERJuTHHQyL3azg5NeA=; b=l+TqKAooq9w+wrJCilg4ENfgtBBNt/Qv228h65UxsdvU3sT48jhoIVjsHuQhIIC8rr74 dj7WYtf5tZKjShss7LmQKiJcadZAlobLExlL+A45XRlEsqYt67ji/MAOdObXX9CggMN64 qfvD0PvuB/BoqUeHlFy7wRGqm5Qo0OvalDX+9NiNFVm5PY8eEMzvlFiNMwGFV5GI99WqC K+9iqKo5mb3GLYbSZEUoydOpsrxEmb57hpIgeDiitorsgqhY9uXUjws5A2hNLamQanCg3 1H4r/Wtssn34WWW+4WOGbtEaIf73KKqjaMx/mqQH1ZsH7HrusNo6oskk4wmVss0wDpg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Eb+uR0zx; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B497606A32C; Fri, 4 Dec 2026 11:53:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Eb+uR0zx Received: by smtp.kernel.org (Postfix) with ESMTPSA id 242C51F000CE; Fri, 4 Dec 2026 11:53:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385222; bh=fDDLAjr1YOt+jbXrQQY2FVraNERJuTHHQyL3azg5NeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Eb+uR0zxmvETEo8rEwuDv8wBvJBiJjrrxFO8BDOrCTeP4pUFm4qRqb97qbjQs+xB1 68VJNLIp5R89k4I1arY9i/r2FGMh88xxoXNiFZZGsGBh0unstKiV5FO2L3wPuARsPS JqYerFKisqTZMAl6GW0Qvi5IwAa8viCUbbxskLtE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Tejun Heo , Josef Bacik , Jens Axboe , Sasha Levin Subject: [PATCH 6.6 0470/1167] block: dont enter reclaim under rq_qos_mutex Date: Fri, 4 Dec 2026 18:58:17 +0900 Message-ID: <20261204100714.261557309@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Josef Bacik [ Upstream commit 045cbfc369f5929ed473f7c200dc2e8146569ce5 ] ioc_qos_write() and the wbt_lat_usec writers take rq_qos_mutex with the queue frozen, blkcg_deactivate_policy() does the same with blkcg_mutex, so nothing holding either may wait for IO. blkg_conf_prep() got GFP_NOIO for the blkg in commit 5d726c4dbeed, but the radix_tree_preload() right after it, the policy init functions and the GFP_KERNEL fallback in blkcg_activate_policy() can still enter reclaim there. lockdep reports the cycle on the first write to io.max. Use GFP_NOIO for all of them. Fixes: 9730763f4756 ("block: correct locking order for protecting blk-wbt parameters") Fixes: 5d726c4dbeed ("blk-cgroup: fix possible deadlock while configuring policy") Cc: Tejun Heo Signed-off-by: Josef Bacik Acked-by: Tejun Heo Link: https://patch.msgid.link/20261028164415.1262013-35-axboe@kernel.dk Signed-off-by: Jens Axboe [ sashal: Dropped the blk_throtl_init() GFP_NOIO hunk as unneeded here, and converted kzalloc_obj() calls to kzalloc(sizeof(*x), GFP_NOIO). ] Signed-off-by: Sasha Levin --- block/blk-cgroup.c | 13 +++++++++---- block/blk-iocost.c | 5 +++-- block/blk-iolatency.c | 3 ++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 98f2b3b968a3d..a660be846b091 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -891,7 +891,11 @@ 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 the spinlock to allocate the new blkg. rq_qos_mutex and + * blkcg_mutex stay held, and both are taken with the queue + * frozen elsewhere: GFP_NOIO. + */ spin_unlock_irq(&q->queue_lock); new_blkg = blkg_alloc(pos, disk, GFP_NOIO); @@ -900,7 +904,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; @@ -1611,7 +1615,8 @@ int blkcg_activate_policy(struct gendisk *disk, const struct blkcg_policy *pol) if (!pd) { /* * GFP_NOWAIT failed. Free the existing one and - * prealloc for @blkg w/ GFP_KERNEL. + * prealloc for @blkg w/ GFP_NOIO: blkcg_mutex is held, + * and a bio based queue has not been frozen above. */ if (pinned_blkg) blkg_put(pinned_blkg); @@ -1623,7 +1628,7 @@ int blkcg_activate_policy(struct gendisk *disk, const struct blkcg_policy *pol) if (pd_prealloc) pol->pd_free_fn(pd_prealloc); pd_prealloc = pol->pd_alloc_fn(disk, blkg->blkcg, - GFP_KERNEL); + GFP_NOIO); if (pd_prealloc) goto retry; else diff --git a/block/blk-iocost.c b/block/blk-iocost.c index bea08873a080c..61741e76c66f5 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -2892,11 +2892,12 @@ static int blk_iocost_init(struct gendisk *disk) struct ioc *ioc; int i, cpu, ret; - ioc = kzalloc(sizeof(*ioc), GFP_KERNEL); + /* The caller holds rq_qos_mutex, which is taken with the queue frozen */ + ioc = kzalloc(sizeof(*ioc), GFP_NOIO); if (!ioc) return -ENOMEM; - ioc->pcpu_stat = alloc_percpu(struct ioc_pcpu_stat); + ioc->pcpu_stat = alloc_percpu_gfp(struct ioc_pcpu_stat, GFP_NOIO); if (!ioc->pcpu_stat) { kfree(ioc); return -ENOMEM; diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c index 1fd2025ea8b6a..fa9ec4e5776b1 100644 --- a/block/blk-iolatency.c +++ b/block/blk-iolatency.c @@ -761,7 +761,8 @@ static int blk_iolatency_init(struct gendisk *disk) struct blk_iolatency *blkiolat; int ret; - blkiolat = kzalloc(sizeof(*blkiolat), GFP_KERNEL); + /* The caller holds rq_qos_mutex, which is taken with the queue frozen */ + blkiolat = kzalloc(sizeof(*blkiolat), GFP_NOIO); if (!blkiolat) return -ENOMEM; -- 2.53.0