Re: [PATCH] netfilter: use per-cpu spinlock rather than RCU

From: Linus Torvalds
Date: Mon Apr 13 2009 - 15:28:11 EST




On Mon, 13 Apr 2009, Martin Josefsson wrote:
>
> Doesn't spin_lock() result in a pipeline flush on x86?

It's about 20-40 cycles when cached and uncontended, with some outliers
(50+ cycles on P4, 12 cycles on some AMD opterons).

So it's not a big deal if you actually hit that case.

> iirc there was a benchmark in an RCU paper that tested using per cpu
> spin_locks and the result was that it didn't scale well at all.

Spinlocks scale wonderfully well if you only touch them on one CPU.

Of course, if you truly only touch them on one CPU they are pointless, but
a "all normal code only touches the local CPU spinlock, the really odd
cases take all locks" approach works fine. It makes the uncommon case
really quite slow, but if it truly is uncommon, that's fine.

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