Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2266972pxb; Thu, 11 Feb 2021 08:16:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJz/e5mCbKtQ2r1eGUmYHLEJxM310mR3MIykw7SXqs4eLxfjWlmEL3S5hw33vtBljsLcPRVQ X-Received: by 2002:a17:906:3850:: with SMTP id w16mr9428113ejc.286.1613060206639; Thu, 11 Feb 2021 08:16:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613060206; cv=none; d=google.com; s=arc-20160816; b=vGyfXd3llpDHDuVtKgpiMWdsDorZYclOfQs+vFoPLJ/BOLmkBcJAN657HXZlitINvu V3SD+sOj+0HaSqiPYziLxtIhr8QMq/fyPOYD10VV9skuVWna4BW+U/3LUTH/WjHGXCn/ ZB8JLjhmphzOrZPkh5YCPHEUJTHuNRRzlP2Uq3NeF16UW8wS3n3fo0v/xbmnKdlS6Fjk jggMmhYuk9ZxTIAWYOd05wNbpmQtYjdaYLorAcZoMPLDODtfMK/QjSAAhIU0zF2K3oEp wcEi5KnmE/mXNDHGgZjXqzE9HK2otF+SNmbrwLmZ7VcaicUZ4hX3OVc4bZRpTySmU+tY dkmw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=w6g86ivJOqCuGKHM/XEnYVOVqLXa6CIGmQJWMJiiBeo=; b=A7v8oDzXsW7KteYHC8w3m8mtLmSgVFc07ImC8KiNszY/DrmhVbl++2XyIQPjJ6sn0c gc50h1CPIqSUZG1d9NGauHP+tl/+/y0o1k0KLk36Ee0U+r4rlW0d9mGGiZCH7ZXa5b/r Ep7/0TLQL9GgiyvTOclAAMdTrdGGKjz6mwgDu6B3ubWy1AqNjvcMijGH2v+oGpiibBwR xQFnoFMwX06DJAiAMBDd50ux7oQaUGx/ono+8V/XYJMVaT8VpkIuDbIKvNKOA9wc4Qzj eKJ16ht5oPMq6LwmAS5Rr52dAlYZfGMZcDbVqmNm8A82ha7vJ/j0E9STYqeKYlREqYVw jimA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fsYiuLuN; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bd14si1299546edb.174.2021.02.11.08.16.13; Thu, 11 Feb 2021 08:16:46 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=fsYiuLuN; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231624AbhBKQMn (ORCPT + 99 others); Thu, 11 Feb 2021 11:12:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:53510 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230418AbhBKPWh (ORCPT ); Thu, 11 Feb 2021 10:22:37 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0E74E64F32; Thu, 11 Feb 2021 15:07:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1613056028; bh=/nF6qPipkgNN+AGt8o6n3NFN/weCxFIubucELHp2D2I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fsYiuLuNcYkl289j+cDte0rnXPiqpYjWyQffiQH46wIQjPeHa479gA74qKWz9pBRS zAm1CxKQzDbAOWVxjJFw2+b4JqQ88QDMa97mLTAz5aOsTP45EimiYN11aKRVdxRnhp 1mK6aLnwUEcK4CMVLKSS70m6A9rCYM2bcvDXR8pY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christoph Hellwig , Hannes Reinecke , Mike Snitzer , Bart Van Assche , Ming Lei , Jens Axboe , Jack Wang Subject: [PATCH 4.19 21/24] blk-mq: dont hold q->sysfs_lock in blk_mq_map_swqueue Date: Thu, 11 Feb 2021 16:02:55 +0100 Message-Id: <20210211150148.681811267@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210211150147.743660073@linuxfoundation.org> References: <20210211150147.743660073@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ming Lei commit c6ba933358f0d7a6a042b894dba20cc70396a6d3 upstream. blk_mq_map_swqueue() is called from blk_mq_init_allocated_queue() and blk_mq_update_nr_hw_queues(). For the former caller, the kobject isn't exposed to userspace yet. For the latter caller, hctx sysfs entries and debugfs are un-registered before updating nr_hw_queues. On the other hand, commit 2f8f1336a48b ("blk-mq: always free hctx after request queue is freed") moves freeing hctx into queue's release handler, so there won't be race with queue release path too. So don't hold q->sysfs_lock in blk_mq_map_swqueue(). Cc: Christoph Hellwig Cc: Hannes Reinecke Cc: Greg KH Cc: Mike Snitzer Cc: Bart Van Assche Reviewed-by: Bart Van Assche Signed-off-by: Ming Lei Signed-off-by: Jens Axboe Signed-off-by: Jack Wang Signed-off-by: Greg Kroah-Hartman --- block/blk-mq.c | 7 ------- 1 file changed, 7 deletions(-) --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2324,11 +2324,6 @@ static void blk_mq_map_swqueue(struct re struct blk_mq_ctx *ctx; struct blk_mq_tag_set *set = q->tag_set; - /* - * Avoid others reading imcomplete hctx->cpumask through sysfs - */ - mutex_lock(&q->sysfs_lock); - queue_for_each_hw_ctx(q, hctx, i) { cpumask_clear(hctx->cpumask); hctx->nr_ctx = 0; @@ -2362,8 +2357,6 @@ static void blk_mq_map_swqueue(struct re hctx->ctxs[hctx->nr_ctx++] = ctx; } - mutex_unlock(&q->sysfs_lock); - queue_for_each_hw_ctx(q, hctx, i) { /* * If no software queues are mapped to this hardware queue,