From: James Morse <james.morse@arm.com>
To: x86@kernel.org, linux-kernel@vger.kernel.org
Cc: Fenghua Yu <fenghua.yu@intel.com>,
Reinette Chatre <reinette.chatre@intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
H Peter Anvin <hpa@zytor.com>, Babu Moger <Babu.Moger@amd.com>,
James Morse <james.morse@arm.com>,
shameerali.kolothum.thodi@huawei.com,
D Scott Phillips OS <scott@os.amperecomputing.com>,
carl@os.amperecomputing.com, lcherian@marvell.com,
bobo.shaobowang@huawei.com, tan.shaopeng@fujitsu.com,
baolin.wang@linux.alibaba.com,
Jamie Iles <quic_jiles@quicinc.com>,
Xin Hao <xhao@linux.alibaba.com>,
peternewman@google.com, dfustini@baylibre.com,
amitsinght@marvell.com, David Hildenbrand <david@redhat.com>,
Rex Nie <rex.nie@jaguarmicro.com>,
Dave Martin <dave.martin@arm.com>,
Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Subject: [PATCH v5 29/40] x86/resctrl: Claim get_{mon,ctrl}_domain_from_cpu() helpers for resctrl
Date: Fri, 4 Oct 2024 18:03:36 +0000 [thread overview]
Message-ID: <20241004180347.19985-30-james.morse@arm.com> (raw)
In-Reply-To: <20241004180347.19985-1-james.morse@arm.com>
get_{mon,ctrl}_domain_from_cpu() are handy helpers that both the arch
code and resctrl need to use. Rename them to have a resctrl_ prefix
and move them to a header file.
Signed-off-by: James Morse <james.morse@arm.com>
Tested-by: Carl Worth <carl@os.amperecomputing.com> # arm64
Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
---
arch/x86/kernel/cpu/resctrl/core.c | 30 ---------------------
arch/x86/kernel/cpu/resctrl/internal.h | 2 --
arch/x86/kernel/cpu/resctrl/monitor.c | 2 +-
arch/x86/kernel/cpu/resctrl/rdtgroup.c | 2 +-
include/linux/resctrl.h | 37 ++++++++++++++++++++++++++
5 files changed, 39 insertions(+), 34 deletions(-)
diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
index 0da7314195af..f484726a2588 100644
--- a/arch/x86/kernel/cpu/resctrl/core.c
+++ b/arch/x86/kernel/cpu/resctrl/core.c
@@ -349,36 +349,6 @@ static void cat_wrmsr(struct msr_param *m)
wrmsrl(hw_res->msr_base + i, hw_dom->ctrl_val[i]);
}
-struct rdt_ctrl_domain *get_ctrl_domain_from_cpu(int cpu, struct rdt_resource *r)
-{
- struct rdt_ctrl_domain *d;
-
- lockdep_assert_cpus_held();
-
- list_for_each_entry(d, &r->ctrl_domains, hdr.list) {
- /* Find the domain that contains this CPU */
- if (cpumask_test_cpu(cpu, &d->hdr.cpu_mask))
- return d;
- }
-
- return NULL;
-}
-
-struct rdt_mon_domain *get_mon_domain_from_cpu(int cpu, struct rdt_resource *r)
-{
- struct rdt_mon_domain *d;
-
- lockdep_assert_cpus_held();
-
- list_for_each_entry(d, &r->mon_domains, hdr.list) {
- /* Find the domain that contains this CPU */
- if (cpumask_test_cpu(cpu, &d->hdr.cpu_mask))
- return d;
- }
-
- return NULL;
-}
-
u32 resctrl_arch_get_num_closid(struct rdt_resource *r)
{
return resctrl_to_arch_res(r)->num_closid;
diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index 30de95e59129..e939a0a28a49 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -468,8 +468,6 @@ unsigned int rdtgroup_cbm_to_size(struct rdt_resource *r, struct rdt_ctrl_domain
unsigned long cbm);
enum rdtgrp_mode rdtgroup_mode_by_closid(int closid);
int rdtgroup_tasks_assigned(struct rdtgroup *r);
-struct rdt_ctrl_domain *get_ctrl_domain_from_cpu(int cpu, struct rdt_resource *r);
-struct rdt_mon_domain *get_mon_domain_from_cpu(int cpu, struct rdt_resource *r);
int closids_supported(void);
void closid_free(int closid);
int alloc_rmid(u32 closid);
diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
index 175fd7dbf34f..39c450624ed0 100644
--- a/arch/x86/kernel/cpu/resctrl/monitor.c
+++ b/arch/x86/kernel/cpu/resctrl/monitor.c
@@ -767,7 +767,7 @@ static void update_mba_bw(struct rdtgroup *rgrp, struct rdt_mon_domain *dom_mbm)
idx = resctrl_arch_rmid_idx_encode(closid, rmid);
pmbm_data = &dom_mbm->mbm_local[idx];
- dom_mba = get_ctrl_domain_from_cpu(smp_processor_id(), r_mba);
+ dom_mba = resctrl_get_ctrl_domain_from_cpu(smp_processor_id(), r_mba);
if (!dom_mba) {
pr_warn_once("Failure to get domain for MBA update\n");
return;
diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index 596f5f087834..ee9c3e4ee889 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -4235,7 +4235,7 @@ void resctrl_offline_cpu(unsigned int cpu)
if (!l3->mon_capable)
goto out_unlock;
- d = get_mon_domain_from_cpu(cpu, l3);
+ d = resctrl_get_mon_domain_from_cpu(cpu, l3);
if (d) {
if (resctrl_is_mbm_enabled() && cpu == d->mbm_work_cpu) {
cancel_delayed_work(&d->mbm_over);
diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index 653d7cf41e64..bbce79190b13 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -3,6 +3,7 @@
#define _RESCTRL_H
#include <linux/cacheinfo.h>
+#include <linux/cpu.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/pid.h>
@@ -397,6 +398,42 @@ static inline u32 resctrl_get_config_index(u32 closid,
}
}
+/*
+ * Caller must hold the cpuhp read lock to prevent the struct rdt_domain being
+ * freed.
+ */
+static inline struct rdt_ctrl_domain *
+resctrl_get_ctrl_domain_from_cpu(int cpu, struct rdt_resource *r)
+{
+ struct rdt_ctrl_domain *d;
+
+ lockdep_assert_cpus_held();
+
+ list_for_each_entry(d, &r->ctrl_domains, hdr.list) {
+ /* Find the domain that contains this CPU */
+ if (cpumask_test_cpu(cpu, &d->hdr.cpu_mask))
+ return d;
+ }
+
+ return NULL;
+}
+
+static inline struct rdt_mon_domain *
+resctrl_get_mon_domain_from_cpu(int cpu, struct rdt_resource *r)
+{
+ struct rdt_mon_domain *d;
+
+ lockdep_assert_cpus_held();
+
+ list_for_each_entry(d, &r->mon_domains, hdr.list) {
+ /* Find the domain that contains this CPU */
+ if (cpumask_test_cpu(cpu, &d->hdr.cpu_mask))
+ return d;
+ }
+
+ return NULL;
+}
+
/*
* Update the ctrl_val and apply this config right now.
* Must be called on one of the domain's CPUs.
--
2.39.2
next prev parent reply other threads:[~2024-10-04 18:06 UTC|newest]
Thread overview: 102+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-04 18:03 [PATCH v5 00/40] x86/resctrl: Move the resctrl filesystem code to /fs/resctrl James Morse
2024-10-04 18:03 ` [PATCH v5 01/40] x86/resctrl: Fix allocation of cleanest CLOSID on platforms with no monitors James Morse
2024-10-04 18:03 ` [PATCH v5 02/40] x86/resctrl: Add a helper to avoid reaching into the arch code resource list James Morse
2024-10-15 22:57 ` Tony Luck
2024-10-18 17:07 ` James Morse
2024-10-18 17:14 ` Luck, Tony
2024-10-23 21:03 ` Reinette Chatre
2024-10-04 18:03 ` [PATCH v5 03/40] x86/resctrl: Remove fflags from struct rdt_resource James Morse
2024-10-23 21:03 ` Reinette Chatre
2024-12-20 18:10 ` James Morse
2024-10-04 18:03 ` [PATCH v5 04/40] x86/resctrl: Use schema type to determine how to parse schema values James Morse
2024-10-15 23:15 ` Tony Luck
2024-10-18 17:07 ` James Morse
2024-10-23 21:14 ` Reinette Chatre
2024-12-20 18:10 ` James Morse
2024-10-04 18:03 ` [PATCH v5 05/40] x86/resctrl: Use schema type to determine the schema format string James Morse
2024-10-21 17:39 ` Reinette Chatre
2024-10-04 18:03 ` [PATCH v5 06/40] x86/resctrl: Remove data_width and the tabular format James Morse
2024-10-15 23:29 ` Tony Luck
2024-10-18 17:07 ` James Morse
2024-10-04 18:03 ` [PATCH v5 07/40] x86/resctrl: Add max_bw to struct resctrl_membw James Morse
2024-10-09 18:02 ` Tony Luck
2024-10-23 21:14 ` Reinette Chatre
2024-12-20 18:10 ` James Morse
2024-10-04 18:03 ` [PATCH v5 08/40] x86/resctrl: Generate default_ctrl instead of sharing it James Morse
2024-10-23 21:15 ` Reinette Chatre
2025-02-07 15:42 ` James Morse
2024-10-04 18:03 ` [PATCH v5 09/40] x86/resctrl: Add helper for setting CPU default properties James Morse
2024-10-04 18:03 ` [PATCH v5 10/40] x86/resctrl: Remove rdtgroup from update_cpu_closid_rmid() James Morse
2024-10-04 18:03 ` [PATCH v5 11/40] x86/resctrl: Export resctrl fs's init function James Morse
2024-10-16 16:20 ` Tony Luck
2024-10-04 18:03 ` [PATCH v5 12/40] x86/resctrl: Wrap resctrl_arch_find_domain() around rdt_find_domain() James Morse
2024-10-23 21:16 ` Reinette Chatre
2025-02-07 15:42 ` James Morse
2024-10-04 18:03 ` [PATCH v5 13/40] x86/resctrl: Move resctrl types to a separate header James Morse
2024-10-04 18:03 ` [PATCH v5 14/40] x86/resctrl: Add a resctrl helper to reset all the resources James Morse
2024-10-23 21:32 ` Reinette Chatre
2025-02-07 15:43 ` James Morse
2025-02-13 23:52 ` Reinette Chatre
2024-10-04 18:03 ` [PATCH v5 15/40] x86/resctrl: Move monitor exit work to a resctrl exit call James Morse
2024-10-04 18:03 ` [PATCH v5 16/40] x86/resctrl: Move monitor init work to a resctrl init call James Morse
2024-10-04 18:03 ` [PATCH v5 17/40] x86/resctrl: Rewrite and move the for_each_*_rdt_resource() walkers James Morse
2024-10-08 0:00 ` Tony Luck
2024-10-08 16:40 ` Reinette Chatre
2024-10-18 17:07 ` James Morse
2024-10-23 21:51 ` Reinette Chatre
2025-02-07 15:44 ` James Morse
2024-10-04 18:03 ` [PATCH v5 18/40] x86/resctrl: Export the is_mbm_*_enabled() helpers to asm/resctrl.h James Morse
2024-10-23 22:00 ` Reinette Chatre
2025-02-07 15:44 ` James Morse
2024-10-04 18:03 ` [PATCH v5 19/40] x86/resctrl: Add resctrl_arch_is_evt_configurable() to abstract BMEC James Morse
2024-10-23 22:04 ` Reinette Chatre
2025-02-07 15:44 ` James Morse
2024-10-04 18:03 ` [PATCH v5 20/40] x86/resctrl: Slightly clean-up mbm_config_show() James Morse
2024-10-16 16:50 ` Tony Luck
2024-10-04 18:03 ` [PATCH v5 21/40] x86/resctrl: Change mon_event_config_{read,write}() to be arch helpers James Morse
2024-10-23 22:19 ` Reinette Chatre
2025-02-07 15:45 ` James Morse
2024-10-04 18:03 ` [PATCH v5 22/40] x86/resctrl: Move mbm_cfg_mask to struct rdt_resource James Morse
2024-10-23 22:42 ` Reinette Chatre
2024-10-04 18:03 ` [PATCH v5 23/40] x86/resctrl: Add resctrl_arch_ prefix to pseudo lock functions James Morse
2024-10-23 22:44 ` Reinette Chatre
2025-02-07 15:45 ` James Morse
2024-10-04 18:03 ` [PATCH v5 24/40] x86/resctrl: Allow an architecture to disable pseudo lock James Morse
2024-10-04 18:03 ` [PATCH v5 25/40] x86/resctrl: Make prefetch_disable_bits belong to the arch code James Morse
2024-10-23 22:53 ` Reinette Chatre
2025-02-07 15:46 ` James Morse
2024-10-04 18:03 ` [PATCH v5 26/40] x86/resctrl: Make resctrl_arch_pseudo_lock_fn() take a plr James Morse
2024-10-04 18:03 ` [PATCH v5 27/40] x86/resctrl: Move thread_throttle_mode_init() to be managed by resctrl James Morse
2024-10-23 22:59 ` Reinette Chatre
2025-02-10 13:22 ` James Morse
2024-10-04 18:03 ` [PATCH v5 28/40] x86/resctrl: Move get_config_index() to a header James Morse
2024-10-04 18:03 ` James Morse [this message]
2024-10-23 23:02 ` [PATCH v5 29/40] x86/resctrl: Claim get_{mon,ctrl}_domain_from_cpu() helpers for resctrl Reinette Chatre
2024-10-04 18:03 ` [PATCH v5 30/40] x86/resctrl: Describe resctrl's bitmap size assumptions James Morse
2024-10-08 18:50 ` Tony Luck
2025-02-07 15:46 ` James Morse
2024-10-04 18:03 ` [PATCH v5 31/40] x86/resctrl: Rename resctrl_sched_in() to begin with "resctrl_arch_" James Morse
2024-10-04 18:03 ` [PATCH v5 32/40] x86/resctrl: resctrl_exit() teardown resctrl but leave the mount point James Morse
2024-10-23 23:50 ` Reinette Chatre
2025-02-07 15:54 ` James Morse
2024-10-04 18:03 ` [PATCH v5 33/40] x86/resctrl: Drop __init/__exit on assorted symbols James Morse
2024-10-23 23:56 ` Reinette Chatre
2025-02-07 15:54 ` James Morse
2024-10-04 18:03 ` [PATCH v5 34/40] x86/resctrl: Move is_mba_sc() out of core.c James Morse
2024-10-04 18:03 ` [PATCH v5 35/40] x86/resctrl: Add end-marker to the resctrl_event_id enum James Morse
2024-10-04 18:03 ` [PATCH v5 36/40] x86/resctrl: Remove a newline to avoid confusing the code move script James Morse
2024-10-04 18:03 ` [PATCH v5 37/40] x86/resctrl: Split trace.h James Morse
2024-10-04 18:03 ` [PATCH v5 38/40] fs/resctrl: Add boiler plate for external resctrl code James Morse
2024-10-08 23:03 ` Tony Luck
2024-10-24 0:08 ` Reinette Chatre
2025-02-07 15:54 ` James Morse
2024-10-04 18:03 ` [PATCH v5 39/40] x86/resctrl: Move the filesystem bits to headers visible to fs/resctrl James Morse
2024-10-04 18:03 ` [PATCH v5 40/40] x86/resctrl: Add python script to move resctrl code to /fs/resctrl James Morse
2024-10-08 23:08 ` Tony Luck
2024-10-24 0:17 ` Reinette Chatre
2025-02-07 15:55 ` James Morse
2024-10-04 21:18 ` [PATCH v5 00/40] x86/resctrl: Move the resctrl filesystem " Reinette Chatre
2024-10-07 17:29 ` James Morse
2024-10-08 23:24 ` Tony Luck
2024-10-17 17:43 ` Tony Luck
2024-12-06 7:17 ` Shaopeng Tan (Fujitsu)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241004180347.19985-30-james.morse@arm.com \
--to=james.morse@arm.com \
--cc=Babu.Moger@amd.com \
--cc=amitsinght@marvell.com \
--cc=baolin.wang@linux.alibaba.com \
--cc=bobo.shaobowang@huawei.com \
--cc=bp@alien8.de \
--cc=carl@os.amperecomputing.com \
--cc=dave.martin@arm.com \
--cc=david@redhat.com \
--cc=dfustini@baylibre.com \
--cc=fenghua.yu@intel.com \
--cc=hpa@zytor.com \
--cc=lcherian@marvell.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peternewman@google.com \
--cc=quic_jiles@quicinc.com \
--cc=reinette.chatre@intel.com \
--cc=rex.nie@jaguarmicro.com \
--cc=scott@os.amperecomputing.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=tan.shaopeng@fujitsu.com \
--cc=tan.shaopeng@jp.fujitsu.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=xhao@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).