Re: sock_hold and sock_put

ratheesh kannoth <[email protected]> Wed, 24 Jun 2015 19:44:49 +0530
Newsgroups org.kernel.vger.linux-newbie,org.kernel.vger.netdev
Message-ID <CAGZFCEFQju581PDF3QpyX-s8vvdxPrZTwS85CP3rTu4wUfEHBg@mail.gmail.com>
On Wed, Jun 24, 2015 at 6:16 PM, Eric Dumazet <[email protected]> wrote:
> You misunderstood the comment.
>
> Comment only stated that sock_hold() must be used in contexts where
> caller owns a reference (and will eventually release it later with
> sock_put().
>
> There is nothing about having a lock here.

Thanks. I think, i did not put the question right.

I understood the comment perfectly. Suppose i need to use the
sock_hold in some callbacks ( say netdev_notifier chain callback)
function. How can i gurantee race won't happen at the point where i
call sock_hold().
 If i put the question  in another way - say kernel is doing a
sock_put() on a socket, and at the same time  the   netdev_callback
function( that i implemented ) is called on another core ( in smp
machine ). and the  callback is  holding (sock_hold()) on the same
sock.

Thanks,
Ratheesh