Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp123074rdh; Tue, 13 Feb 2024 11:13:50 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUv+C3HRDf29CL87momBLQqx49G7+f2lkpxBTvTeK5UvqE143VvL0H6+BozNdHiLyz4F90nFQ/Q1qPxLUajcuwc3TyZP38FaveWxeiyyg== X-Google-Smtp-Source: AGHT+IFxJHUWNjzVmMji7GLP6ALL7n6LtSIT6OOvYsmkCyTLQJYNCWslHRSth+0xL04u8cfuzLn2 X-Received: by 2002:a17:90a:e295:b0:296:930:8792 with SMTP id d21-20020a17090ae29500b0029609308792mr562041pjz.9.1707851629969; Tue, 13 Feb 2024 11:13:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707851629; cv=pass; d=google.com; s=arc-20160816; b=vwko7CvBLrF6xvoNGcy3U5obHFlJVCAGRS013I6kBa1tO/XvfO4SvxbA12gd33HQoj DWXMtyJREfPY4DgjJJiJrsO9ZJqFMO5DiAuD0oTzKAlltyb5v0yWnQGV4qjaX7m7BBQr FLu7O6AAyAnS4XLHfoVuXNHZqOaIBcswKaK83eyr7lbFs4gPnzfbpWZ9r20idFzlmIzh 5720zK8Y+hBUtIo85FZBeAlZD7yJwefEKhfB4T6etDNkCdAc1zSwYg0y4EyMG/M5WFZL DjfkZtA6VALhUVBbDQo7EmintTZ8NboHzsNvCNbjHz1YNYQs8w9v5sxrca8hQEjyWHo9 bVLQ== 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=0xSLpzHEYb4dnRSqP8O6AV1o/h86rsyj77f2d4QllGo=; fh=ktQLta/MWUdLTHZZsPLr5k+qZJzpeF5cvNmi4Kagsf4=; b=Za72lziak/011GzEnRz7mcPkklxRBY8kkUBHmxQ8xnfLO9JWHRr5qHxMBaJex/j8S5 vDLCbSoaaWdxqgthAmUeUiFkK5MUHNDyewR+/LRr5SmW+s4LZRe9XA2DhhCHbGtRfgwP OfXngDrviCX8RArzG/ZRGszP12UtZTpBxhJDnStTlu+2Z8Xh1NSYJQmtvhNTJjsgOTa+ /sO2mdjeoKeCWWbAt4AktCq3NrvaR57ACRp4+elQfmTsnxhNQ7w/HjWI8Fafj3BVpiXM huEASTPuQSZIbcNhIJxer6eR34+x/PnV6SuwaEvD5bo0zcOUhuDQ/Lg/3OCucn12IHvX w2HA==; 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-64108-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64108-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; AJvYcCUrgM/WDR0IroR3vBl1OpSNmgt8718YZSP+k7DAJgGtbLcKn9h3QcW6khx2EAhNtpi2W6W1iSkArvWcNevaD0MSi/b0E6v+97MiYR16bg== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id qj6-20020a17090b28c600b00297315d3f7bsi2529282pjb.26.2024.02.13.11.13.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 11:13:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64108-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; 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-64108-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64108-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 7965BB20AB9 for ; Tue, 13 Feb 2024 18:49:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0048C111A9; Tue, 13 Feb 2024 18:46:02 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1BFF562157 for ; Tue, 13 Feb 2024 18:45:59 +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=1707849961; cv=none; b=i+MGT9QwshAXBC3H5eTVDaG4fDM0r6k4uzuJybiAs51gtDVV3ud8b9Z5gCsNGHsL4e/GM2vofHpPMavPb/eWG9za7aQNg7WPnkROPplGYZDXgaF2pPtOXjXSnSS/LHJG3MKtSwfRlabiHp9eLPa3PTcvRl7vmeWzna7k5NeIwGo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707849961; c=relaxed/simple; bh=UTm+/uA3DbKSZsz9TADTmie/tQ3Sskf0znguZ3b19zQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=enBk/c3ynC8r9yEIN4DK+xAHJGZWpbZilAqo90CI3QxYUYSvHWZmUZtuFnukDSFk2JbL2P6jcmnVi4pIhsZCLxrRGvxaL/k4PzBn3/hXnRM7tx4ZzHd5hLR06jGai9bpeqchbPB7sPiWO/A57y6GOwTS1KOFTQYAoKxE58e3aLQ= 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 080201576; Tue, 13 Feb 2024 10:46:40 -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 A21E93F766; Tue, 13 Feb 2024 10:45:55 -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 17/24] x86/resctrl: Move alloc/mon static keys into helpers Date: Tue, 13 Feb 2024 18:44:31 +0000 Message-Id: <20240213184438.16675-18-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 resctrl enables three static keys depending on the features it has enabled. Another architecture's context switch code may look different, any static keys that control it should be buried behind helpers. Move the alloc/mon logic into arch-specific helpers as a preparatory step for making the rdt_enable_key's status something the arch code decides. This means other architectures don't have to mirror the static keys. 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 | 20 ++++++++++++++++++++ arch/x86/kernel/cpu/resctrl/internal.h | 5 ----- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 8 ++++---- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index 29c4cc343787..3c9137b6ad4f 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -42,6 +42,26 @@ DECLARE_STATIC_KEY_FALSE(rdt_enable_key); DECLARE_STATIC_KEY_FALSE(rdt_alloc_enable_key); 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 inline void resctrl_arch_disable_alloc(void) +{ + static_branch_disable_cpuslocked(&rdt_alloc_enable_key); +} + +static inline void resctrl_arch_enable_mon(void) +{ + static_branch_enable_cpuslocked(&rdt_mon_enable_key); +} + +static inline void resctrl_arch_disable_mon(void) +{ + static_branch_disable_cpuslocked(&rdt_mon_enable_key); +} + /* * __resctrl_sched_in() - Writes the task's CLOSid/RMID to IA32_PQR_MSR * diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h index 9bfda6963794..78580855139d 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -94,9 +94,6 @@ static inline struct rdt_fs_context *rdt_fc2context(struct fs_context *fc) return container_of(kfc, struct rdt_fs_context, kfc); } -DECLARE_STATIC_KEY_FALSE(rdt_enable_key); -DECLARE_STATIC_KEY_FALSE(rdt_mon_enable_key); - /** * struct mon_evt - Entry in the event list of a resource * @evtid: event id @@ -452,8 +449,6 @@ extern struct mutex rdtgroup_mutex; extern struct rdt_hw_resource rdt_resources_all[]; extern struct rdtgroup rdtgroup_default; -DECLARE_STATIC_KEY_FALSE(rdt_alloc_enable_key); - extern struct dentry *debugfs_resctrl; enum resctrl_res_level { diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index 857fbbc3c839..231207f09e04 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2668,9 +2668,9 @@ static int rdt_get_tree(struct fs_context *fc) goto out_psl; if (rdt_alloc_capable) - static_branch_enable_cpuslocked(&rdt_alloc_enable_key); + resctrl_arch_enable_alloc(); if (rdt_mon_capable) - static_branch_enable_cpuslocked(&rdt_mon_enable_key); + resctrl_arch_enable_mon(); if (rdt_alloc_capable || rdt_mon_capable) { static_branch_enable_cpuslocked(&rdt_enable_key); @@ -2946,8 +2946,8 @@ static void rdt_kill_sb(struct super_block *sb) rdtgroup_default.mode = RDT_MODE_SHAREABLE; schemata_list_destroy(); rdtgroup_destroy_root(); - static_branch_disable_cpuslocked(&rdt_alloc_enable_key); - static_branch_disable_cpuslocked(&rdt_mon_enable_key); + resctrl_arch_disable_alloc(); + resctrl_arch_disable_mon(); static_branch_disable_cpuslocked(&rdt_enable_key); resctrl_mounted = false; kernfs_kill_sb(sb); -- 2.39.2