Skip to content

Commit 258c91e

Browse files
James Morsebp3tk0v
authored andcommitted
x86/resctrl: Add CPU offline callback for resctrl work
The resctrl architecture specific code may need to free a domain when a CPU goes offline, it also needs to reset the CPUs PQR_ASSOC register. Amongst other things, the resctrl filesystem code needs to clear this CPU from the cpu_mask of any control and monitor groups. Currently, this is all done in core.c and called from resctrl_offline_cpu(), making the split between architecture and filesystem code unclear. Move the filesystem work to remove the CPU from the control and monitor groups into a filesystem helper called resctrl_offline_cpu(), and rename the one in core.c resctrl_arch_offline_cpu(). Signed-off-by: James Morse <james.morse@arm.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Shaopeng Tan <tan.shaopeng@fujitsu.com> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Reviewed-by: Babu Moger <babu.moger@amd.com> Tested-by: Shaopeng Tan <tan.shaopeng@fujitsu.com> Tested-by: Peter Newman <peternewman@google.com> Tested-by: Babu Moger <babu.moger@amd.com> Tested-by: Carl Worth <carl@os.amperecomputing.com> # arm64 Link: https://lore.kernel.org/r/20240213184438.16675-23-james.morse@arm.com Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
1 parent 978fcca commit 258c91e

File tree

3 files changed

+30
-20
lines changed

3 files changed

+30
-20
lines changed

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

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -625,31 +625,15 @@ static int resctrl_arch_online_cpu(unsigned int cpu)
625625
return 0;
626626
}
627627

628-
static void clear_childcpus(struct rdtgroup *r, unsigned int cpu)
628+
static int resctrl_arch_offline_cpu(unsigned int cpu)
629629
{
630-
struct rdtgroup *cr;
631-
632-
list_for_each_entry(cr, &r->mon.crdtgrp_list, mon.crdtgrp_list) {
633-
if (cpumask_test_and_clear_cpu(cpu, &cr->cpu_mask)) {
634-
break;
635-
}
636-
}
637-
}
638-
639-
static int resctrl_offline_cpu(unsigned int cpu)
640-
{
641-
struct rdtgroup *rdtgrp;
642630
struct rdt_resource *r;
643631

644632
mutex_lock(&rdtgroup_mutex);
633+
resctrl_offline_cpu(cpu);
634+
645635
for_each_capable_rdt_resource(r)
646636
domain_remove_cpu(cpu, r);
647-
list_for_each_entry(rdtgrp, &rdt_all_groups, rdtgroup_list) {
648-
if (cpumask_test_and_clear_cpu(cpu, &rdtgrp->cpu_mask)) {
649-
clear_childcpus(rdtgrp, cpu);
650-
break;
651-
}
652-
}
653637
clear_closid_rmid(cpu);
654638
mutex_unlock(&rdtgroup_mutex);
655639

@@ -971,7 +955,8 @@ static int __init resctrl_late_init(void)
971955

972956
state = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,
973957
"x86/resctrl/cat:online:",
974-
resctrl_arch_online_cpu, resctrl_offline_cpu);
958+
resctrl_arch_online_cpu,
959+
resctrl_arch_offline_cpu);
975960
if (state < 0)
976961
return state;
977962

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4017,6 +4017,30 @@ void resctrl_online_cpu(unsigned int cpu)
40174017
cpumask_set_cpu(cpu, &rdtgroup_default.cpu_mask);
40184018
}
40194019

4020+
static void clear_childcpus(struct rdtgroup *r, unsigned int cpu)
4021+
{
4022+
struct rdtgroup *cr;
4023+
4024+
list_for_each_entry(cr, &r->mon.crdtgrp_list, mon.crdtgrp_list) {
4025+
if (cpumask_test_and_clear_cpu(cpu, &cr->cpu_mask))
4026+
break;
4027+
}
4028+
}
4029+
4030+
void resctrl_offline_cpu(unsigned int cpu)
4031+
{
4032+
struct rdtgroup *rdtgrp;
4033+
4034+
lockdep_assert_held(&rdtgroup_mutex);
4035+
4036+
list_for_each_entry(rdtgrp, &rdt_all_groups, rdtgroup_list) {
4037+
if (cpumask_test_and_clear_cpu(cpu, &rdtgrp->cpu_mask)) {
4038+
clear_childcpus(rdtgrp, cpu);
4039+
break;
4040+
}
4041+
}
4042+
}
4043+
40204044
/*
40214045
* rdtgroup_init - rdtgroup initialization
40224046
*

include/linux/resctrl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_domain *d,
226226
int resctrl_online_domain(struct rdt_resource *r, struct rdt_domain *d);
227227
void resctrl_offline_domain(struct rdt_resource *r, struct rdt_domain *d);
228228
void resctrl_online_cpu(unsigned int cpu);
229+
void resctrl_offline_cpu(unsigned int cpu);
229230

230231
/**
231232
* resctrl_arch_rmid_read() - Read the eventid counter corresponding to rmid

0 commit comments

Comments
 (0)