Netdev List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Ben Greear <greearb@candelatech.com>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH 1/2 v2] af-packet:  Use existing netdev reference for bound sockets.
Date: Fri, 27 May 2011 22:08:41 +0200	[thread overview]
Message-ID: <1306526921.2533.7.camel@edumazet-laptop> (raw)
In-Reply-To: <4DDF2463.3020001@candelatech.com>

Le jeudi 26 mai 2011 à 21:11 -0700, Ben Greear a écrit :
> On 05/26/2011 08:42 PM, Eric Dumazet wrote:
> > Le jeudi 26 mai 2011 à 16:55 -0700, greearb@candelatech.com a écrit :
> 
> >>   out_free:
> >>   	kfree_skb(skb);
> >>   out_unlock:
> >> -	if (dev)
> >> +	if (dev&&  need_rls_dev)
> >>   		dev_put(dev);
> >>   out:
> >>   	return err;
> >
> > Hmmm, I wonder why you want this Ben.
> >
> > IMHO this is buggy, because we can sleep in this function.
> >
> > We must take a ref on device (its really cheap these days, now we have a
> > percpu device refcnt)
> 
> Why must you take the reference?  And if we must, why isn't the
> current code that assigns the prot_hook.dev without taking a
> reference OK?
> 

If we sleep, device can disappear under us.

The only way to not take a reference is to hold rcu_read_lock(), but
you're not allowed to sleep under rcu_read_lock().


> It seems a waste to do the lookup and free if we don't have to,
> and with thousands of devices, the lookup might take a reasonable
> amount of effort?

I understand you want to avoid the lookup, this part is fine for me, but
you need to take a reference on the device before eventual sleep.

Nowadays its a single "inc" instruction on x86, without even a lock
prefix (this on a percpu integer)




  reply	other threads:[~2011-05-27 20:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-26 23:55 [PATCH 1/2 v2] af-packet: Use existing netdev reference for bound sockets greearb
2011-05-26 23:55 ` [PATCH 2/2 v2] af-packet: Add flag to distinguish VID 0 from no-vlan greearb
2011-05-27  3:46   ` Eric Dumazet
2011-05-27  3:42 ` [PATCH 1/2 v2] af-packet: Use existing netdev reference for bound sockets Eric Dumazet
2011-05-27  4:11   ` Ben Greear
2011-05-27 20:08     ` Eric Dumazet [this message]
2011-05-27 20:15       ` David Miller
2011-05-27 20:18         ` Ben Greear
2011-05-28  6:20           ` Eric Dumazet
2011-05-28 17:01             ` Ben Greear

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1306526921.2533.7.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=greearb@candelatech.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox