@@ -98,9 +98,16 @@ s64 __percpu_counter_sum(struct percpu_counter *fbc)
s64 ret;
int cpu;
+ /*
+ * CPU hotplug synchronization is explicitly handled via the
+ * hotplug callback, which synchronizes through fbc->lock.
+ * So it is safe to use the _nocheck() version of
+ * for_each_online_cpu() here (to avoid false-positive warnings
+ * from the CPU hotplug debug code).
+ */
raw_spin_lock(&fbc->lock);
ret = fbc->count;
- for_each_online_cpu(cpu) {
+ for_each_online_cpu_nocheck(cpu) {
s32 *pcount = per_cpu_ptr(fbc->counters, cpu);
ret += *pcount;
}
The percpu-counter-sum code does a for_each_online_cpu() protected by a spinlock, which makes it look like it needs to use get/put_online_cpus_atomic(), going forward. However, the code has adequate synchronization with CPU hotplug, via a hotplug callback and the fbc->lock. So use for_each_online_cpu_nocheck() to avoid false-positive warnings from the hotplug locking validator. And add a comment justifying the same. Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Tejun Heo <tj@kernel.org> Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> --- lib/percpu_counter.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html