From patchwork Wed Sep 13 11:10:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 138791 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1072931vqx; Wed, 13 Sep 2023 06:08:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHCpoE5UFBvPA3EsrHwLKfy1GfScrmwSDJhC4VQxGjcd9UKm4JP9pF44YXE6aIi6cETcRRT X-Received: by 2002:a05:6a21:7988:b0:153:616c:7ca4 with SMTP id bh8-20020a056a21798800b00153616c7ca4mr2036909pzc.61.1694610520055; Wed, 13 Sep 2023 06:08:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694610520; cv=none; d=google.com; s=arc-20160816; b=U2iTrkKa6aTn2m/B2t+40JCQwaB3Dp7sO0yUsSadoHdBku2cd2bxT8RN6SuprqpXMv xQQAED0D4WqwX7VAuy+UGxxERJHFls8EyEnbJqM+4NjmC6AQ2IFsHx/FAzHAWGYy/2CT WghgDThi/fv02x66+LiQcqO77o1ZM8Y2WU8U3tMDmKf/2GyZsdN4ElnHuiGcAwl0C05i +cN8uAs9iq/LZL6KYAFHHqr8COXee1DrXbdkcd8BxOFMJvgosSSmmruI8bX3Gx149phJ Mbq2RqfDC72ZctnQLDr8b4DiX6f16SaKhlZD53HSCZtHdxT8AGT0JTfLtDmRfdpS2egY tVsw== 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=Q2VwcKDbn0sssCtg/tKvOFfISdo7sbQlCa3jWeP0g5o=; fh=BKhaubn3NgfOFdJuURkVVw5laQp2qzBZJf/ffKnJtu8=; b=HnuHvxQp8Rbu/cIk6NoiZtY0tgZ6/zwsiYe1AbOQHp0VW7FYHbYtS8T7yuZ7iiNxwB uTdaaQlKHK9nGuQQ8JAUSofXl3ouG3V0OGU0mm04vwGJ+xJdn2H0xagGdmDfJxL1nS+o FwZgzSqizouJfKgUu01Osc67u2QI3mhRi9b4gpc5xnZcpF41NghD0Ooa/T5/knn3FNdq 3kXKpjpSnWhp02YJH/ualifMud8zPP/55tM4ZWhnPLc0iZsHd+LLmQt+a92KjogjREVO pjAptwv8WXf2K1POPm+Sm+1X80vtB8cW8yw3yGVyCmHWPcL3C2Zf2afVjRaxxaVVrG9I Sxbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=U9maC0r9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id k184-20020a636fc1000000b005702c84e4c2si9741455pgc.508.2023.09.13.06.08.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 06:08:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=U9maC0r9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 681038411D67; Wed, 13 Sep 2023 04:12:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240244AbjIMLMK (ORCPT + 36 others); Wed, 13 Sep 2023 07:12:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240247AbjIMLLp (ORCPT ); Wed, 13 Sep 2023 07:11:45 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9376270C; Wed, 13 Sep 2023 04:11:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=Q2VwcKDbn0sssCtg/tKvOFfISdo7sbQlCa3jWeP0g5o=; b=U9maC0r9MMAGiR+QOYQXHrPmxl hylGpcYyRZf8wlnfYzYJRGZ+ePuUrLXyBiCBj233USe8FtvXKcesNUnc6ymEuNNxot0H1zdTdIqxD 4nZemSt5Xe+moQ3awKBJ0JWFY7hKqY5a8qTbBzA4Chr1Z80FIM12zzh+M3AcEb9HxFS5iSZondHRZ WQoy1PvwkQqXEgFPHOyK0Z5obK/hYR6g0WWqUFEQshG2lS0WzKwVP/zoNBlJqjuwTFZxNoSSi1ufm 2tnBrbQ85MVzRjetu64lwiuth4qM5dROCJK8uHKhfCxDaBwLEfj6vTmeG7EfaLoILEr/TxmwYoAQM bOsLTfDQ==; Received: from [190.210.221.22] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qgNmA-005i9E-0r; Wed, 13 Sep 2023 11:11:18 +0000 From: Christoph Hellwig To: Christian Brauner , Al Viro Cc: Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Fenghua Yu , Reinette Chatre , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Dennis Dalessandro , Tejun Heo , Trond Myklebust , Anna Schumaker , Kees Cook , Damien Le Moal , Naohiro Aota , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, linux-rdma@vger.kernel.org, linux-nfs@vger.kernel.org, linux-hardening@vger.kernel.org, cgroups@vger.kernel.org Subject: [PATCH 16/19] x86/resctrl: release rdtgroup_mutex and the CPU hotplug lock in rdt_shutdown_sb Date: Wed, 13 Sep 2023 08:10:10 -0300 Message-Id: <20230913111013.77623-17-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230913111013.77623-1-hch@lst.de> References: <20230913111013.77623-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 13 Sep 2023 04:12:19 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776927920151986437 X-GMAIL-MSGID: 1776927920151986437 While the resctl code is a bit confusing, I can't find anything protected by rdtgroup_mutex or the CPU hotplug lock in generic_shutdown_super or kernfs_free_sb. Drop the locks at the end of rdt_shutdown_sb to avoid holding locks over method calls and VFS code which itself already has a rather complicated locking hierarchy. Signed-off-by: Christoph Hellwig --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index 8db767fd80df6b..e87de519493021 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2793,11 +2793,6 @@ static void rdt_shutdown_sb(struct super_block *sb) static_branch_disable_cpuslocked(&rdt_mon_enable_key); static_branch_disable_cpuslocked(&rdt_enable_key); kernfs_shutdown_sb(sb); -} - -static void rdt_free_sb(struct super_block *sb) -{ - kernfs_free_sb(sb); mutex_unlock(&rdtgroup_mutex); cpus_read_unlock(); } @@ -2807,7 +2802,7 @@ static struct file_system_type rdt_fs_type = { .init_fs_context = rdt_init_fs_context, .parameters = rdt_fs_parameters, .shutdown_sb = rdt_shutdown_sb, - .free_sb = rdt_free_sb, + .free_sb = kernfs_free_sb, }; static int mon_addfile(struct kernfs_node *parent_kn, const char *name,