Index: linux-2.6-work/lib/percpu_counter.c
===================================================================
--- linux-2.6-work.orig/lib/percpu_counter.c	2011-08-29 19:50:44.482008591 +1000
+++ linux-2.6-work/lib/percpu_counter.c	2011-08-29 21:21:10.026779139 +1000
@@ -153,7 +153,14 @@ static void compute_batch_value(void)
 {
 	int nr = num_online_cpus();
 
-	percpu_counter_batch = max(32, nr*2);
+	/*
+	 * The cutoff point for the percpu_counter_compare() fast path grows
+	 * at num_online_cpus^2 and on a big enough machine it will be
+	 * unlikely to hit.
+	 * We clamp the batch value to 1024 so the cutoff point only grows
+	 * linearly past 512 CPUs.
+	 */
+	percpu_counter_batch = clamp(nr*2, 32, 1024);
 }
 
 static int __cpuinit percpu_counter_hotcpu_callback(struct notifier_block *nb,
