Skip to content

Commit c7cc0cc

Browse files
Fenghua YuKAGA-KOKO
authored andcommitted
x86/intel_rdt: Reset per cpu closids on unmount
All CPUs in a rdtgroup are given back to the default rdtgroup before the rdtgroup is removed during umount. After umount, the default rdtgroup contains all online CPUs, but the per cpu closids are not cleared. As a result the stale closid value will be used immediately after the next mount. Move all cpus to the default group and update the percpu closid storage. [ tglx: Massaged changelong ] Signed-off-by: Fenghua Yu <[email protected]> Cc: "Ravi V Shankar" <[email protected]> Cc: "Tony Luck" <[email protected]> Cc: "Sai Prakhya" <[email protected]> Cc: "Vikas Shivappa" <[email protected]> Cc: "Ingo Molnar" <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Thomas Gleixner <[email protected]>
1 parent 59fe5a7 commit c7cc0cc

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

arch/x86/kernel/cpu/intel_rdt_rdtgroup.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,7 @@ static void rmdir_all_sub(void)
799799
{
800800
struct rdtgroup *rdtgrp, *tmp;
801801
struct task_struct *p, *t;
802+
int cpu;
802803

803804
/* move all tasks to default resource group */
804805
read_lock(&tasklist_lock);
@@ -813,14 +814,29 @@ static void rmdir_all_sub(void)
813814
smp_call_function_many(cpu_online_mask, rdt_reset_pqr_assoc_closid,
814815
NULL, 1);
815816
put_cpu();
817+
816818
list_for_each_entry_safe(rdtgrp, tmp, &rdt_all_groups, rdtgroup_list) {
817819
/* Remove each rdtgroup other than root */
818820
if (rdtgrp == &rdtgroup_default)
819821
continue;
822+
823+
/*
824+
* Give any CPUs back to the default group. We cannot copy
825+
* cpu_online_mask because a CPU might have executed the
826+
* offline callback already, but is still marked online.
827+
*/
828+
cpumask_or(&rdtgroup_default.cpu_mask,
829+
&rdtgroup_default.cpu_mask, &rdtgrp->cpu_mask);
830+
820831
kernfs_remove(rdtgrp->kn);
821832
list_del(&rdtgrp->rdtgroup_list);
822833
kfree(rdtgrp);
823834
}
835+
836+
/* Reset all per cpu closids to the default value */
837+
for_each_cpu(cpu, &rdtgroup_default.cpu_mask)
838+
per_cpu(cpu_closid, cpu) = 0;
839+
824840
kernfs_remove(kn_info);
825841
}
826842

0 commit comments

Comments
 (0)