Re: [PATCH] percpu_counter: Put a reasonable upper bound onpercpu_counter_batch

From: Anton Blanchard
Date: Wed Sep 07 2011 - 13:05:22 EST



Hi Ted,

> Um, this was an ext4 patch and I pointed out it could cause
> problems. (Specifically, data lossâ)

I'm a bit confused. While the comment mentions ext4, the patch is just
putting an upper bound on the size of percpu_counter_batch and it is
useful for percpu_counter_compare() too:

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);
}

The batch value should be opaque to the rest of the kernel. If ext4
requires a specific batch value we can use the functions that take
an explicit one (eg __percpu_counter_add).

Anton
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/