From patchwork Tue Feb 13 18:44:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 200559 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp740135dyb; Tue, 13 Feb 2024 10:49:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW8JlOVucmG+XH2aJcH7+YesO6GwTlH7xk0pFORI0C94lGp8M3v2TLZOvTecfGswRDFg3zEMYKZa9T7U9XG2/zc0Dq3vw== X-Google-Smtp-Source: AGHT+IGjiMkfv/1cFNgNtNO1vMSw5VYXkmFsyH7+V35yfQM+ur7XWsQGnmvC3LCAp+hpLjeqt2JX X-Received: by 2002:a17:906:68c5:b0:a3d:2762:71f7 with SMTP id y5-20020a17090668c500b00a3d276271f7mr129478ejr.66.1707850171026; Tue, 13 Feb 2024 10:49:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707850171; cv=pass; d=google.com; s=arc-20160816; b=BymBV39EQ+YDQUOEanJdEsiQcXRQYx/77PyKxNhfONGQSooGdsZj5KkZsGP5z5wDFf pwrptKqfJJ0C1QqGxDuTE6X3Hmvjm3oUPtG9oThPFfKZUOObEl5plaNNfM5vdtO44Hqz hqEAtQZGH7Me+arK0bcvFN273Oc05VP6JIdRZFAs2LZ7737cIi4WV3zLmSDKXqR2+y3e 4LidMr1CvezKfHSAVAUOXGAfOwYDP5nOqcP/skhM+b76Oa4Lk6Jiuk16WvACYw+jw3Ov f1JaWfSKHt5oZ0cWz7Hb3g47Ygxs+Fi0OZCskemy4wfjXqr4jHgaLchCxnX8xm7bl2CS GQ/A== 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=wG4cjF+ek8oNyKmwd2VRUpXWDhBfri9YzY3svl5gssg=; b=tvEFU8402wyYWBQi1kHSEQISgBM1zb0wq3SjlNs3qfBpatwaw6H0GwQyoIAbKBrtnT /1wuohtRRAOtaMvvvzWrolYzhPSdARxBO9iph3H2XdIM15X954PM/1A39uGNQFltT8/2 7u2NnGXRphHUhQYpvjkybd8ViAQq5zHIVFhVJm8DUhu5hqGwfw1bGoaIdxGFTGyWTuyh hy0wINBJAUlurA6q/rNrS13s4xx5pM0za8RnEZC0c1/izM3lvMEuoWY001hnGDa70W48 t7UT4m8Tc5KqPSDlu4ktvcr6YUr5jcwyaa4t9lkzuBDgW31Qx2eMWYpihlrgtYiFPeJk C3GA==; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64108-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCWMW0Ru4dK2wuPyloPVH9+WV3Lv7kRuNtIW4pv1srQscXHc0La+PgDKEecXqFqVz+1G8E1U5KeIcdsVCCRJaSTD2HBmlA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id s17-20020a170906455100b00a3d19189d73si466601ejq.810.2024.02.13.10.49.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 10:49:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64108-ouuuleilei=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-64108-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64108-ouuuleilei=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 98B0B1F24D81 for ; Tue, 13 Feb 2024 18:49:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 12EBF605C6; Tue, 13 Feb 2024 18:46:03 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790810700828864938 X-GMAIL-MSGID: 1790810700828864938 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);