[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250117151033.1517882-17-Dave.Martin@arm.com>
Date: Fri, 17 Jan 2025 15:10:26 +0000
From: Dave Martin <Dave.Martin@....com>
To: linux-kernel@...r.kernel.org
Cc: linux-arm-kernel@...ts.infradead.org,
Zeng Heng <zengheng4@...wei.com>,
Shaopeng Tan <tan.shaopeng@...itsu.com>,
James Morse <james.morse@....com>
Subject: [RFC PATCH v2 04/11] fs/resctrl: Add arch hook to set up the default CLOSID
Currently, the resctrl core code assumes that CLOSID 0 requires no
special initialisation before use.
This is true on x86, but may not be true on other architectures
(including Arm MPAM, in certain configurations).
Since the allocation of CLOSIDs can depend on parameters such as
resctrl filesystem mount options that are not available at arch driver
init time, an arch hook is needed to set up the default CLOSID when
the resctrl filesystem is mounted.
Add a suitable arch hook resctrl_arch_init_domains().
Wire it up to arch stubs that do nothing, for now.
(This is also the right thing for x86.)
No functional change.
Signed-off-by: Dave Martin <Dave.Martin@....com>
---
arch/x86/include/asm/resctrl.h | 12 ++++++++++++
fs/resctrl/rdtgroup.c | 26 ++++++++++++++++++++++++--
include/linux/arm_mpam.h | 10 ++++++++++
include/linux/resctrl.h | 2 ++
4 files changed, 48 insertions(+), 2 deletions(-)
diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h
index 332b0617d728..b5fbb94e756a 100644
--- a/arch/x86/include/asm/resctrl.h
+++ b/arch/x86/include/asm/resctrl.h
@@ -50,6 +50,18 @@ DECLARE_STATIC_KEY_FALSE(rdt_enable_key);
DECLARE_STATIC_KEY_FALSE(rdt_alloc_enable_key);
DECLARE_STATIC_KEY_FALSE(rdt_mon_enable_key);
+/* The default CLOSID needs no special setup on x86: */
+static inline bool resctrl_arch_default_closid_needs_init(void)
+{
+ return false;
+}
+
+/* ... so this won't be needed either: */
+static inline int resctrl_arch_init_domains(struct rdt_resource *r, u32 closid)
+{
+ return 0;
+}
+
static inline bool resctrl_arch_alloc_capable(void)
{
return rdt_alloc_capable;
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index 30f1dd05e10b..200f92e8f619 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -65,6 +65,8 @@ static struct seq_buf last_cmd_status;
static char last_cmd_status_buf[512];
+static int rdtgroup_init_first_alloc(struct rdtgroup *rdtgrp);
+
static int rdtgroup_setup_root(struct rdt_fs_context *ctx);
static void rdtgroup_destroy_root(void);
@@ -2542,6 +2544,9 @@ static int rdt_get_tree(struct fs_context *fc)
}
closid_init();
+ ret = rdtgroup_init_first_alloc(&rdtgroup_default);
+ if (ret)
+ goto out_schemata_free;
if (resctrl_arch_mon_capable())
flags |= RFTYPE_MON;
@@ -3230,7 +3235,7 @@ static void rdtgroup_init_mba(struct rdt_resource *r, u32 closid)
}
/* Initialize the RDT group's allocations. */
-static int rdtgroup_init_alloc(struct rdtgroup *rdtgrp)
+static int __rdtgroup_init_alloc(struct rdtgroup *rdtgrp, bool first_time_init)
{
struct resctrl_schema *s;
struct rdt_resource *r;
@@ -3251,7 +3256,11 @@ static int rdtgroup_init_alloc(struct rdtgroup *rdtgrp)
goto out;
}
- ret = resctrl_arch_update_domains(r, rdtgrp->closid);
+ if (first_time_init)
+ ret = resctrl_arch_init_domains(r, rdtgrp->closid);
+ else
+ ret = resctrl_arch_update_domains(r, rdtgrp->closid);
+
if (ret < 0) {
rdt_last_cmd_puts("Failed to initialize allocations\n");
goto out;
@@ -3265,6 +3274,19 @@ static int rdtgroup_init_alloc(struct rdtgroup *rdtgrp)
return ret;
}
+static int rdtgroup_init_alloc(struct rdtgroup *rdtgrp)
+{
+ return __rdtgroup_init_alloc(rdtgrp, false);
+}
+
+static int rdtgroup_init_first_alloc(struct rdtgroup *rdtgrp)
+{
+ if (!resctrl_arch_default_closid_needs_init())
+ return 0;
+
+ return __rdtgroup_init_alloc(rdtgrp, true);
+}
+
static int mkdir_rdt_prepare_rmid_alloc(struct rdtgroup *rdtgrp)
{
int ret;
diff --git a/include/linux/arm_mpam.h b/include/linux/arm_mpam.h
index c00b5fc1d235..dd5f18474846 100644
--- a/include/linux/arm_mpam.h
+++ b/include/linux/arm_mpam.h
@@ -45,6 +45,16 @@ static inline unsigned int resctrl_arch_round_mon_val(unsigned int val)
return val;
}
+static inline bool resctrl_arch_default_closid_needs_init(void)
+{
+ return false;
+}
+
+static inline int resctrl_arch_init_domains(struct rdt_resource *r, u32 closid)
+{
+ return 0;
+}
+
bool resctrl_arch_alloc_capable(void);
bool resctrl_arch_mon_capable(void);
bool resctrl_arch_is_llc_occupancy_enabled(void);
diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index be9d9f4c7b81..fc00b080f1a1 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -371,6 +371,8 @@ u32 resctrl_arch_system_num_rmid_idx(void);
struct rdt_domain_hdr *resctrl_arch_find_domain(struct list_head *domain_list,
int id);
+bool resctrl_arch_default_closid_needs_init(void);
+int resctrl_arch_init_domains(struct rdt_resource *r, u32 closid);
int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid);
bool resctrl_arch_is_evt_configurable(enum resctrl_event_id evt);
--
2.34.1
Powered by blists - more mailing lists