Re: [PATCH] arp_queue: serializing unlink + kfree_skb

David S. Miller
2005-02-04T01:20:31Z

On Fri, 4 Feb 2005 10:50:44 +1100
Herbert Xu <herbert@gondor.apana.org.au> wrote:

> So the problem isn't as big as I thought which is good. sk_buff
> is only in trouble because of the atomic_read optimisation which
> really needs a memory barrier.
>
> However, instead of adding a memory barrier which makes the optimisation
> less useful, let's just get rid of the atomic_read.

See my other email, the atomic_read() should function just fine.

If we see the count dropped to "1", whoever set it to "1" made
sure that all outstanding memory operations (including things
like __skb_unlink()) are globally visible before the
atomic_dec_and_test() which put the thing to "1" from "2".
(and we did use atomic_dec_and_test() since the refcount was
not "1") Example, assuming skb->users is "2":

cpu 0 cpu 1
__skb_unlink()
kfree_skb()
kfree_skb()

If cpu 0 sees the count at "1", it will always see the
__skb_unlink() as well.

Either my logic is flawed (very possible, I am a pinhead) or something
is amiss in the PPC atomic ops.

I describe all of this more explicitly in my other email.
I'm actually going through all the sparc64 chip manuals to make
sure I have things correct in that implementation :-)))