Re: [PATCH] x86/perf/intel/cqm: Get rid of the silly for_each_cpu lookups
From: Vikas Shivappa
Date: Wed Feb 17 2016 - 13:47:59 EST
On Wed, 17 Feb 2016, Thomas Gleixner wrote:
On Wed, 17 Feb 2016, Vikas Shivappa wrote:
Yes, please resend the rapl one. perf_uncore is a different trainwreck which I
fixed already:
lkml.kernel.org/r/20160217132903.767990400@xxxxxxxxxxxxx
Ok , will resend the rapl separately.
the fix i sent however was a little different in that it uses a static
tmp_cpumask to avoid the loop in the cpumask_and_any below -
while ((n = cpumask_next(n, src1p)) < nr_cpu_ids)
if (cpumask_test_cpu(n, src2p))
But we have an extra static - static to avoid having it in the
stack..
copy below -
+/*
+ * Temporary cpumask used during hot cpu notificaiton handling. The usage
+ * is serialized by hot cpu locks.
+ */
+static cpumask_t tmp_cpumask;
+
static void rapl_cpu_init(int cpu)
{
- int i, phys_id = topology_physical_package_id(cpu);
-
- /* check if phys_is is already covered */
- for_each_cpu(i, &rapl_cpu_mask) {
- if (phys_id == topology_physical_package_id(i))
- return;
- }
- /* was not found, so add it */
- cpumask_set_cpu(cpu, &rapl_cpu_mask);
+ /* check if cpu's package is already covered.If not, add it.*/
+ cpumask_and(&tmp_cpumask, &rapl_cpu_mask, topology_core_cpumask(cpu));
+ if (cpumask_empty(&tmp_cpumask))
+ cpumask_set_cpu(cpu, &rapl_cpu_mask);
}
Thanks,
Vikas
Thanks,
tglx