@@ -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;
@@ -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;
@@ -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);
@@ -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);
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@arm.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(-)