Re: [PATCH] percpu_counter : add percpu_counter_add_fast()

From: Christoph Lameter
Date: Mon Oct 18 2010 - 11:24:21 EST


On Sat, 16 Oct 2010, Eric Dumazet wrote:

> I based following patch against linux-2.6, I dont know if previous
> Christoph patch is in a git tree. I'll respin it eventually.

The prior patch was accepted by Andrew.

> + * - It is preempt safe, but not IRQ safe (on UP)

The IRQ safeness depends on the arch. this_cpu_add() in general only
guarantees safety against preemption. It so happens that the x86
implementation is irq safe as well.

The IRQ safety for UP is therefore not an issue if you use this_cpu_add().

If you want to guarantee irqsafeness then use irqsafe_cpu_add() instead.
It generates the same code on x86 for SMP but takes care of the UP issues.

> +static inline void percpu_counter_add_fast(struct percpu_counter *fbc, long amount)
> +{
> + this_cpu_add(*fbc->counters, amount);
> +}

What happens in case of counter overflow?

--
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/