x86/intel_rdt/mbm: Fix MBM overflow handler during CPU hotplug

When a CPU is dying, the overflow worker is canceled and rescheduled on a
different CPU in the same domain. But if the timer is already about to
expire this essentially doubles the interval which might result in a non
detected overflow.

Cancel the overflow worker and reschedule it immediately on a different CPU
in same domain. The work could be flushed as well, but that would
reschedule it on the same CPU.

[ tglx: Rewrote changelog once again ]

Reported-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Vikas Shivappa <vikas.shivappa@linux.intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: ravi.v.shankar@intel.com
Cc: tony.luck@intel.com
Cc: fenghua.yu@intel.com
Cc: peterz@infradead.org
Cc: eranian@google.com
Cc: vikas.shivappa@intel.com
Cc: ak@linux.intel.com
Cc: davidcc@google.com
Link: http://lkml.kernel.org/r/1502845243-20454-2-git-send-email-vikas.shivappa@linux.intel.com

authored by

Vikas Shivappa and committed by
Thomas Gleixner
bbc4615e a9110b55

+6 -6
+2 -2
arch/x86/kernel/cpu/intel_rdt.c
··· 447 447 448 448 if (is_mbm_enabled()) { 449 449 INIT_DELAYED_WORK(&d->mbm_over, mbm_handle_overflow); 450 - mbm_setup_overflow_handler(d); 450 + mbm_setup_overflow_handler(d, MBM_OVERFLOW_INTERVAL); 451 451 } 452 452 453 453 return 0; ··· 540 540 } else if (r == &rdt_resources_all[RDT_RESOURCE_L3] && 541 541 cpu == d->mbm_work_cpu && is_mbm_enabled()) { 542 542 cancel_delayed_work(&d->mbm_over); 543 - mbm_setup_overflow_handler(d); 543 + mbm_setup_overflow_handler(d, 0); 544 544 } 545 545 } 546 546
+1 -1
arch/x86/kernel/cpu/intel_rdt.h
··· 422 422 struct rdt_domain *d); 423 423 void mon_event_read(struct rmid_read *rr, struct rdt_domain *d, 424 424 struct rdtgroup *rdtgrp, int evtid, int first); 425 - void mbm_setup_overflow_handler(struct rdt_domain *dom); 425 + void mbm_setup_overflow_handler(struct rdt_domain *dom, unsigned long delay_ms); 426 426 void mbm_handle_overflow(struct work_struct *work); 427 427 428 428 #endif /* _ASM_X86_INTEL_RDT_H */
+2 -2
arch/x86/kernel/cpu/intel_rdt_monitor.c
··· 417 417 mutex_unlock(&rdtgroup_mutex); 418 418 } 419 419 420 - void mbm_setup_overflow_handler(struct rdt_domain *dom) 420 + void mbm_setup_overflow_handler(struct rdt_domain *dom, unsigned long delay_ms) 421 421 { 422 - unsigned long delay = msecs_to_jiffies(MBM_OVERFLOW_INTERVAL); 422 + unsigned long delay = msecs_to_jiffies(delay_ms); 423 423 int cpu; 424 424 425 425 if (!static_branch_likely(&rdt_enable_key))
+1 -1
arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
··· 1140 1140 if (is_mbm_enabled()) { 1141 1141 r = &rdt_resources_all[RDT_RESOURCE_L3]; 1142 1142 list_for_each_entry(dom, &r->domains, list) 1143 - mbm_setup_overflow_handler(dom); 1143 + mbm_setup_overflow_handler(dom, MBM_OVERFLOW_INTERVAL); 1144 1144 } 1145 1145 1146 1146 goto out;