Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp764312pxb; Mon, 16 Aug 2021 17:38:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNpGXDIC4VH8XO6OvVEL8NQqWXilucz9t5awMfyR/rJa9KJto6562e/OyrVZ3LhMwbdH3z X-Received: by 2002:a17:907:990d:: with SMTP id ka13mr862851ejc.392.1629160722051; Mon, 16 Aug 2021 17:38:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629160722; cv=none; d=google.com; s=arc-20160816; b=PG4De3iesicXu++YZRzLI6QovVLlupS8rU+LXgBEkKzkMD4XPBmKD/ezw/Y7X/5+mT Cirx2PHFpwyQfuQfdLRcZb1niQgEC4pFGbsk/yPkpbsIIkS2Ipudxg15L8DB4dhh6FXv TEWgmz+t0D7L7NPgYI4VGgH0FJ7E57+s/+rhnrCpqROuOaF9A9ne0h5ORHm+gfsvlUy6 C5Qy3gssBiTVuHCB16P2dNwSMXPdyXNu1AaHEoidHs3mbh+UQA2yOWM5MViA+rFVCQ+X d99vo7rN4R3TTcmbCSoc98QKOKOOcQdxUiNJwyCOmDgA3Z+4ojMRcqkDm2u7QImcFFYB r8og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Fzxgy1FlduYbRJk/UwQDNPM48ZruaNxmuExaoxbqfXg=; b=KCaR2x98nBNousGAJ5KXQBqW5j+HFXvNudlrZRcTqYQSE6I5rkV3OHzckx1y8ATrq1 BbXAzA+jXqd8GNJYyQyFeHgRGNjUJ4RZHJfBDIYLHphcbOpbswFsi0lrwnWx/LUTdxxE dHIjprn+XHdRUTFcsCHIv9GMU9D2VYV3ckRugoroMf0vf93j7SAUfrx/nuRuNqSktEZM IUXxmYjh6dBgKNVyDvFQikbxzrrSNoNZbIpZs91a+t6AVK68Vuutrt1RhgOzIyW5i9Ax qE8thu0+CzCs/UzyYahfvv4fGiAyxYIyLfURSvsdLKCP4qJfF8JoXHVFIVqbES4RFTu7 I/Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HsKtiItl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dd5si536479ejc.375.2021.08.16.17.38.19; Mon, 16 Aug 2021 17:38:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HsKtiItl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236490AbhHQAgm (ORCPT + 99 others); Mon, 16 Aug 2021 20:36:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:35328 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235999AbhHQAgX (ORCPT ); Mon, 16 Aug 2021 20:36:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8D4C160F55; Tue, 17 Aug 2021 00:35:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629160551; bh=qGPaQj73xkmgPoSQwd6WKS5+iUqYTWAl4B6wMKaSzwQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HsKtiItlJGLXPoqmvNUyauEy0c8ybg068usodItQUG0OVE3VYbHUa2Ln/81qljRL/ Xx+NXaeZiOCZzJKZ0aDb5g44daIYmMkyA4Qbzwiuiwb14vrh00cGi+H1EhttByx5im mOwt8OThnl6FIYjpa5BV0X9mKlaLyEqIL7BaWq1PW+xvCYWaPJmGPWv2cqVNpyl1uY +HI92Gzb1sgxoe9d3smQdHDha4j71xnWBGj1dR3hakJTHTbZPvUJGpQDuIgOUegwVY MVfaMmroJF7CJ2BJUfAchhI7EFDgGfIgV/hmklaDllfRVcsUhhaPp0Tdlkaha8bHZs KyxwWy7483YaA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ming Lei , Tejun Heo , Bruno Goncalves , Jens Axboe , Sasha Levin , linux-block@vger.kernel.org Subject: [PATCH AUTOSEL 5.13 10/12] blk-iocost: fix lockdep warning on blkcg->lock Date: Mon, 16 Aug 2021 20:35:34 -0400 Message-Id: <20210817003536.83063-10-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210817003536.83063-1-sashal@kernel.org> References: <20210817003536.83063-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ming Lei [ Upstream commit 11431e26c9c43fa26f6b33ee1a90989f57b86024 ] blkcg->lock depends on q->queue_lock which may depend on another driver lock required in irq context, one example is dm-thin: Chain exists of: &pool->lock#3 --> &q->queue_lock --> &blkcg->lock Possible interrupt unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&blkcg->lock); local_irq_disable(); lock(&pool->lock#3); lock(&q->queue_lock); lock(&pool->lock#3); Fix the issue by using spin_lock_irq(&blkcg->lock) in ioc_weight_write(). Cc: Tejun Heo Reported-by: Bruno Goncalves Link: https://lore.kernel.org/linux-block/CA+QYu4rzz6079ighEanS3Qq_Dmnczcf45ZoJoHKVLVATTo1e4Q@mail.gmail.com/T/#u Signed-off-by: Ming Lei Acked-by: Tejun Heo Link: https://lore.kernel.org/r/20210803070608.1766400-1-ming.lei@redhat.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/blk-iocost.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index 5fac3757e6e0..0e56557cacf2 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -3061,19 +3061,19 @@ static ssize_t ioc_weight_write(struct kernfs_open_file *of, char *buf, if (v < CGROUP_WEIGHT_MIN || v > CGROUP_WEIGHT_MAX) return -EINVAL; - spin_lock(&blkcg->lock); + spin_lock_irq(&blkcg->lock); iocc->dfl_weight = v * WEIGHT_ONE; hlist_for_each_entry(blkg, &blkcg->blkg_list, blkcg_node) { struct ioc_gq *iocg = blkg_to_iocg(blkg); if (iocg) { - spin_lock_irq(&iocg->ioc->lock); + spin_lock(&iocg->ioc->lock); ioc_now(iocg->ioc, &now); weight_updated(iocg, &now); - spin_unlock_irq(&iocg->ioc->lock); + spin_unlock(&iocg->ioc->lock); } } - spin_unlock(&blkcg->lock); + spin_unlock_irq(&blkcg->lock); return nbytes; } -- 2.30.2