Skip to content

Commit 6f06aee

Browse files
James Morsebp3tk0v
authored andcommitted
x86/resctrl: Remove rdtgroup from update_cpu_closid_rmid()
update_cpu_closid_rmid() takes a struct rdtgroup as an argument, which it uses to update the local CPUs default pqr values. This is a problem once the resctrl parts move out to /fs/, as the arch code cannot poke around inside struct rdtgroup. Rename update_cpu_closid_rmid() as resctrl_arch_sync_cpus_defaults() to be used as the target of an IPI, and pass the effective CLOSID and RMID in a new struct. Co-developed-by: Dave Martin <Dave.Martin@arm.com> Signed-off-by: Dave Martin <Dave.Martin@arm.com> Signed-off-by: James Morse <james.morse@arm.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Reviewed-by: Tony Luck <tony.luck@intel.com> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Reviewed-by: Fenghua Yu <fenghuay@nvidia.com> Reviewed-by: Babu Moger <babu.moger@amd.com> Tested-by: Carl Worth <carl@os.amperecomputing.com> # arm64 Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Tested-by: Peter Newman <peternewman@google.com> Tested-by: Amit Singh Tomar <amitsinght@marvell.com> # arm64 Tested-by: Shanker Donthineni <sdonthineni@nvidia.com> # arm64 Tested-by: Babu Moger <babu.moger@amd.com> Link: https://lore.kernel.org/r/20250311183715.16445-11-james.morse@arm.com
1 parent aebd535 commit 6f06aee

2 files changed

Lines changed: 35 additions & 4 deletions

File tree

arch/x86/kernel/cpu/resctrl/rdtgroup.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,13 @@ static int rdtgroup_cpus_show(struct kernfs_open_file *of,
355355
* from update_closid_rmid() is protected against __switch_to() because
356356
* preemption is disabled.
357357
*/
358-
static void update_cpu_closid_rmid(void *info)
358+
void resctrl_arch_sync_cpu_closid_rmid(void *info)
359359
{
360-
struct rdtgroup *r = info;
360+
struct resctrl_cpu_defaults *r = info;
361361

362362
if (r) {
363363
this_cpu_write(pqr_state.default_closid, r->closid);
364-
this_cpu_write(pqr_state.default_rmid, r->mon.rmid);
364+
this_cpu_write(pqr_state.default_rmid, r->rmid);
365365
}
366366

367367
/*
@@ -376,11 +376,20 @@ static void update_cpu_closid_rmid(void *info)
376376
* Update the PGR_ASSOC MSR on all cpus in @cpu_mask,
377377
*
378378
* Per task closids/rmids must have been set up before calling this function.
379+
* @r may be NULL.
379380
*/
380381
static void
381382
update_closid_rmid(const struct cpumask *cpu_mask, struct rdtgroup *r)
382383
{
383-
on_each_cpu_mask(cpu_mask, update_cpu_closid_rmid, r, 1);
384+
struct resctrl_cpu_defaults defaults, *p = NULL;
385+
386+
if (r) {
387+
defaults.closid = r->closid;
388+
defaults.rmid = r->mon.rmid;
389+
p = &defaults;
390+
}
391+
392+
on_each_cpu_mask(cpu_mask, resctrl_arch_sync_cpu_closid_rmid, p, 1);
384393
}
385394

386395
static int cpus_mon_write(struct rdtgroup *rdtgrp, cpumask_var_t newmask,

include/linux/resctrl.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,28 @@ struct resctrl_schema {
266266
u32 num_closid;
267267
};
268268

269+
struct resctrl_cpu_defaults {
270+
u32 closid;
271+
u32 rmid;
272+
};
273+
274+
/**
275+
* resctrl_arch_sync_cpu_closid_rmid() - Refresh this CPU's CLOSID and RMID.
276+
* Call via IPI.
277+
* @info: If non-NULL, a pointer to a struct resctrl_cpu_defaults
278+
* specifying the new CLOSID and RMID for tasks in the default
279+
* resctrl ctrl and mon group when running on this CPU. If NULL,
280+
* this CPU is not re-assigned to a different default group.
281+
*
282+
* Propagates reassignment of CPUs and/or tasks to different resctrl groups
283+
* when requested by the resctrl core code.
284+
*
285+
* This function records the per-cpu defaults specified by @info (if any),
286+
* and then reconfigures the CPU's hardware CLOSID and RMID for subsequent
287+
* execution based on @current, in the same way as during a task switch.
288+
*/
289+
void resctrl_arch_sync_cpu_closid_rmid(void *info);
290+
269291
/**
270292
* resctrl_get_default_ctrl() - Return the default control value for this
271293
* resource.

0 commit comments

Comments
 (0)