smp_rmb() in consume_skb

Mulyadi Santosa mulyadi.santosa at gmail.com
Thu Oct 11 12:09:32 EDT 2012


Hi :)

On Thu, Oct 11, 2012 at 7:20 PM, Kshemendra KP <kshemendra at suphalaam.com> wrote:
>      void consume_skb(struct sk_buff * skb)
>      {
>          if (unlikely(!skb))
>               return;
>          if (likley (atomic_read (&skb->users) == 1))
>               smp_rmb()
> --------------------------------------------------------> need for this
> barrier
>
>             ......
>           __kfree_skb();
>      }

In most cases, read barrier is needed to make sure all
cores/processors see the latest data updates

Specificly, in this case, i think it is done to prevent memory free
race. Which..if not well prevented, could lead to double free. And
that's bad.

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com



More information about the Kernelnewbies mailing list