[Top] [All Lists]

Re: [PATCH] arp_queue: serializing unlink + kfree_skb

To: "David S. Miller" <davem@xxxxxxxxxxxxx>
Subject: Re: [PATCH] arp_queue: serializing unlink + kfree_skb
From: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 4 Feb 2005 12:20:53 +1100
Cc: anton@xxxxxxxxx, okir@xxxxxxx, netdev@xxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx
In-reply-to: <20050203164922.2627a112.davem@xxxxxxxxxxxxx>
References: <20050131102920.GC4170@xxxxxxx> <E1CvZo6-0001Bz-00@xxxxxxxxxxxxxxxxxxxxxxxx> <20050203142705.GA11318@xxxxxxxxxxxxxxxxxxxxxxxxxx> <20050203203010.GA7081@xxxxxxxxxxxxxxxxxxx> <20050203141901.5ce04c92.davem@xxxxxxxxxxxxx> <20050203235044.GA8422@xxxxxxxxxxxxxxxxxxx> <20050203164922.2627a112.davem@xxxxxxxxxxxxx>
Sender: netdev-bounce@xxxxxxxxxxx
User-agent: Mutt/1.5.6+20040722i
On Thu, Feb 03, 2005 at 04:49:22PM -0800, David S. Miller wrote:
> 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.

This is true if CPU 0 reads the count before reading skb->list.
Without a memory barrier, atomic_read and reading skb->list can
be reordered.  Put it another way, reading skb->list could return
a cached value that was read from the main memory prior to the

So in order for CPU 0 to always see an up-to-date value of skb->list,
it needs to do an smp_rmb() between the atomic_read and reading

Visit Openswan at
Email: Herbert Xu ~{PmV>HI~} <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page:
PGP Key:

<Prev in Thread] Current Thread [Next in Thread>