Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp109253rdh; Tue, 13 Feb 2024 10:49:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVDpGnIcIcNwG3GNMwPw4czzQ+hZjnnhaEcon3ZI0TErcK64m3lvjAIX5/0BHy67CvyhB2UQ8qLKrTFExg8tre0gv7Y3RR4V0FRWZf20A== X-Google-Smtp-Source: AGHT+IF7NRJURtT2mAxL60yIasWCcAunCqi8j8r+j3GQ9+QifXqdF8KEuj6GeWgEFVuCRoYAGuzx X-Received: by 2002:a17:906:b249:b0:a3d:224:2c56 with SMTP id ce9-20020a170906b24900b00a3d02242c56mr173754ejb.10.1707850177418; Tue, 13 Feb 2024 10:49:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707850177; cv=pass; d=google.com; s=arc-20160816; b=HogGIPsIJlNMwxCFpHArpbc3NxWMKGlNyysNquukDi+fzd5KuEbYNU3IJUrQTGoQG2 zWIdJ8h/lpDzvak+nTEgGi8nUAvWYelnfr5nYS5aE+cemltt4+B7/dCTId2rCJFakEcY zQYE3/moTLUuibu98UL9RqFRs/6FDrv7rwIyk1ZVIux1iFuv/Qbr2iJaUOeY6pNTlMmW 3Te5TZkfbDBDrfysDt0CSk75zasH4tPwaRxj7ws20LXp4NVGasGBsrSDBgp9Zm8dBrRX q8OHd4nN9AdAzFcLfOlKs58VtLOkL89FT1UIeHr8qDbwLkhAaXRLPT/vHsuzTdly1XKf 4Grg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=dyg1PQBXjzOurYsqs4MsUkQbyNLjRgUYb1TxLj6nCEU=; fh=Bo44D+BEd8EwkcvHKc3IXHhc11Z2xJswAKgxGeO2ba8=; b=nLe7eSMvKA26H1GqY1Z4qHflE2LfGWxWeqK40O7+gdCjtur/a1qCsKr1+jN20D2z2f p9s/ya+9MA6RkIP2frQJhQrnOSUFnX+IS/pFrYyv6p5Ln0+5EwM4e/PKsXeYnKPJNaXt ZQesXahL5Av2zAwoMurez9aoeyupeqRUhOC97yGqb01tqKrGpKR6bt/eflW60wNKnz/N OEdBYOD4C2Rjyjvp9EjwphL0mu9BhibNiAdeOU4H/iNxSeL9kQzR0nbPdIzR56G0N1cz FT8iKbdEJFh+8tZfr6OW1eA2YcjnwKSeyyKoLjOT4pkDEnq/NpVmkmj+EQKXu+7UTE/M x9NA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-64109-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64109-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCWj0e79V4upktUu7iejSub2BJdVwQO1N6lQ//MsvI9vf6zFgXpypt9027j/fHspQoqGK9xJtu+oYLMWtLlEqDHQA2KRDlUNOZBwcncwug== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id o12-20020a170906358c00b00a38c319921asi1464616ejb.631.2024.02.13.10.49.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 10:49:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64109-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-64109-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64109-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id F296B1F21DE3 for ; Tue, 13 Feb 2024 18:49:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9B40760879; Tue, 13 Feb 2024 18:46:04 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 94C955FB88 for ; Tue, 13 Feb 2024 18:46:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707849964; cv=none; b=upvH4ghxjxXfH2VP4hUYdl9Pbw50ZGGuUGB6Px140XTw5LY5QC0AdNaCZNOZHLWwDRPMU+5OfNUToEQHoYqiQ1BGmzq2/GMrMAar30zqToMRWvdwVjuBG684UsnYloUcsHI653K2jnU/RqxaIrRQphd6YSduFYMRrM4tRD9+lHA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707849964; c=relaxed/simple; bh=GBgK+HKsOLOZBaUQG/gKw1CrHgLc7JCW+Za9mnYk4R8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=c3jZQS4xYpHp2JKT4mO5XPhsSGHWW57R1EF6vHQ5TdHCs0nvVSUALnsFdvEABr8orfgm5Upr51IUOzUwDJgsq2/bVJZQn1ubVDTlVtyoHwSmqEKPXoZl8CzsXpdn/y1VFUWgRAjKpuojrFL/9kLzIzG2HCnrjkCxqzd0jLBpt40= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 4C52B15A1; Tue, 13 Feb 2024 10:46:43 -0800 (PST) Received: from merodach.members.linode.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E8A6D3F766; Tue, 13 Feb 2024 10:45:58 -0800 (PST) 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, baolin.wang@linux.alibaba.com, Jamie Iles , Xin Hao , peternewman@google.com, dfustini@baylibre.com, amitsinght@marvell.com, David Hildenbrand , Babu Moger Subject: [PATCH v9 18/24] x86/resctrl: Make rdt_enable_key the arch's decision to switch Date: Tue, 13 Feb 2024 18:44:32 +0000 Message-Id: <20240213184438.16675-19-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240213184438.16675-1-james.morse@arm.com> References: <20240213184438.16675-1-james.morse@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 there are helpers for enabling 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 Tested-by: Shaopeng Tan Tested-by: Peter Newman Tested-by: Babu Moger Tested-by: Carl Worth # arm64 Reviewed-by: Shaopeng Tan Reviewed-by: Reinette Chatre Reviewed-by: Babu Moger --- 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 3c9137b6ad4f..b74aa34dc9e8 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -45,21 +45,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 231207f09e04..7e57ac9d81f7 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2672,10 +2672,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; @@ -2946,9 +2944,10 @@ static void rdt_kill_sb(struct super_block *sb) rdtgroup_default.mode = RDT_MODE_SHAREABLE; schemata_list_destroy(); rdtgroup_destroy_root(); - 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); -- 2.39.2