From patchwork Fri Oct 21 13:11:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 6707 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp691658wrr; Fri, 21 Oct 2022 06:15:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4mtNO7dOpHbhV10k0HVl3Pl3TaDX1jRAvj1I1rOH6N8Z01rOzvP0CHMd8Y/OaGZuRTlvgq X-Received: by 2002:a05:6a00:9a7:b0:563:a9e0:fe50 with SMTP id u39-20020a056a0009a700b00563a9e0fe50mr18845003pfg.45.1666358110497; Fri, 21 Oct 2022 06:15:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666358110; cv=none; d=google.com; s=arc-20160816; b=IH7YkHpxH0bXQ5nQsWr10sYxKSpRSV0hW1OpaXHPZMONsrmgIHtsK0w9EXQcEA5Grj dZWm3Se57cGwuyaYxjhfpw/hYs8qa2H6wNhgLyPXFQIGPFUpRIptx8pJ5LId7e78Ir/q OSj6kq4YiuE3RBRR2p0enEUjzE4b0s8I6H4ciE/PhzGhOrp3U2cWT/DCbHYc514+RLHT CqqcVqJ8Kuzd6cRm+cvJ+YQI8lh6q8evCxZQewANtfMQuPuovK2IRqrMSy9D1TtDhPdV rw//H9HosYdxZwJqxo8Sq3LJo0ZE4QYfXqqBU08uB9/Wfwtz4pxHl+KpEfPzapqIQ4z9 QMCQ== 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; bh=kWqINNdaMdOLRCjJmjINi23LtO5gbnxhZ8cCgV69a4w=; b=vzYXbIDoTSQJ1Pk7Jj46mf3BIrlMiklelOxf68QED66KmWdaoIMNJRdp3qY1AT7SgC 3sMdGHAusL/U1aiL3Qhvc5IMbnyGQhgBlm0joiGANsSR9MAlJdNLB8zLqd7FSpqwn4J5 Z+/ZUmDpp8h28Iso0RRVjiDKfZ+x3un59uRc3P6RneOEr+0yio1StjPb4xTx4lbyN8ZX qgul3Mh01Uh3QPgCgh1TK9RmwNURUqD2uymkbBq5EWwgfecoUtM4S7HFzOzsSd3JhIeD QnVvFQZFO0rZVoxDQ5shcOmNBPRwlu100TuU8/1rA4CrSnJx0ngzvS1yfqan8eLt7uqw OGJg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bx25-20020a056a00429900b0052d9e5f07d9si22848960pfb.210.2022.10.21.06.14.57; Fri, 21 Oct 2022 06:15:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230308AbiJUNN5 (ORCPT + 99 others); Fri, 21 Oct 2022 09:13:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230401AbiJUNNX (ORCPT ); Fri, 21 Oct 2022 09:13:23 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7A10926D91F for ; Fri, 21 Oct 2022 06:13:05 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 183F51E2F; Fri, 21 Oct 2022 06:13:11 -0700 (PDT) Received: from merodach.members.linode.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6C5023F792; Fri, 21 Oct 2022 06:13:02 -0700 (PDT) From: James Morse To: x86@kernel.org, linux-kernel@vger.kernel.org Cc: Fenghua Yu , Reinette Chatre , Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , Babu Moger , James Morse , shameerali.kolothum.thodi@huawei.com, D Scott Phillips OS , carl@os.amperecomputing.com, lcherian@marvell.com, bobo.shaobowang@huawei.com, tan.shaopeng@fujitsu.com, Jamie Iles , Xin Hao , xingxin.hx@openanolis.org, baolin.wang@linux.alibaba.com, peternewman@google.com Subject: [PATCH 13/18] x86/resctrl: Make rdt_enable_key the arch's decision to switch Date: Fri, 21 Oct 2022 13:11:59 +0000 Message-Id: <20221021131204.5581-14-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20221021131204.5581-1-james.morse@arm.com> References: <20221021131204.5581-1-james.morse@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747303122292602668?= X-GMAIL-MSGID: =?utf-8?q?1747303122292602668?= rdt_enable_key is switched when resctrl is mounted. It was also previously used to prevent a second mount of the filesystem. Any other architecture that wants to support resctrl has to provide identical static keys. Now that we have helpers for enablign and disabling the alloc/mon keys, resctrl doesn't need to switch this extra key, it can be done by the arch code. Use the static-key increment and decrement helpers, and change resctrl to ensure the calls are balanced. Signed-off-by: James Morse --- arch/x86/include/asm/resctrl.h | 4 ++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 11 +++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index ae3a87100626..00cffc43eb49 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -40,21 +40,25 @@ DECLARE_STATIC_KEY_FALSE(rdt_mon_enable_key); static inline void resctrl_arch_enable_alloc(void) { static_branch_enable_cpuslocked(&rdt_alloc_enable_key); + static_branch_inc_cpuslocked(&rdt_enable_key); } static inline void resctrl_arch_disable_alloc(void) { static_branch_disable_cpuslocked(&rdt_alloc_enable_key); + static_branch_dec_cpuslocked(&rdt_enable_key); } static inline void resctrl_arch_enable_mon(void) { static_branch_enable_cpuslocked(&rdt_mon_enable_key); + static_branch_inc_cpuslocked(&rdt_enable_key); } static inline void resctrl_arch_disable_mon(void) { static_branch_disable_cpuslocked(&rdt_mon_enable_key); + static_branch_dec_cpuslocked(&rdt_enable_key); } /* diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index bd2489bae7cf..f076e516f381 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2248,10 +2248,8 @@ static int rdt_get_tree(struct fs_context *fc) if (rdt_mon_capable) resctrl_arch_enable_mon(); - if (rdt_alloc_capable || rdt_mon_capable) { - static_branch_enable_cpuslocked(&rdt_enable_key); + if (rdt_alloc_capable || rdt_mon_capable) resctrl_mounted = true; - } if (is_mbm_enabled()) { r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; @@ -2515,9 +2513,10 @@ static void rdt_kill_sb(struct super_block *sb) rdt_pseudo_lock_release(); rdtgroup_default.mode = RDT_MODE_SHAREABLE; schemata_list_destroy(); - resctrl_arch_disable_alloc(); - resctrl_arch_disable_mon(); - static_branch_disable_cpuslocked(&rdt_enable_key); + if (rdt_alloc_capable) + resctrl_arch_disable_alloc(); + if (rdt_mon_capable) + resctrl_arch_disable_mon(); resctrl_mounted = false; kernfs_kill_sb(sb); mutex_unlock(&rdtgroup_mutex);