netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org
Subject: Re: [PATCH 2/2] macvlan: Move broadcasts into a work queue
Date: Tue, 08 Apr 2014 10:14:12 -0700	[thread overview]
Message-ID: <1396977252.5212.12.camel@joe-AO722> (raw)
In-Reply-To: <20140408095523.2d4e14bd@nehalam.linuxnetplumber.net>

On Tue, 2014-04-08 at 09:55 -0700, Stephen Hemminger wrote:
> On Mon, 07 Apr 2014 15:55:36 +0800
> Herbert Xu <herbert@gondor.apana.org.au> wrote:
> 
> > +static void macvlan_broadcast_enqueue(struct macvlan_port *port,
> > +				      struct sk_buff *skb)
> > +{
> > +	int err = -ENOMEM;
> > +
> > +	skb = skb_clone(skb, GFP_ATOMIC);
> > +	if (unlikely(!skb))
> > +		goto err;
> > +
> > +	spin_lock(&port->bc_queue.lock);
> > +	if (skb_queue_len(&port->bc_queue) < skb->dev->tx_queue_len) {
> > +		__skb_queue_tail(&port->bc_queue, skb);
> > +		err = 0;
> > +	}
> > +	spin_unlock(&port->bc_queue.lock);
> > +
> > +	if (unlikely(err)) {
> > +err:
> > +		atomic_long_inc(&skb->dev->rx_dropped);
> > +		return;
> > +	}
> > +
> 
> unlikely() with goto is redundant and unnecessary.
> 
> IMHO jumping into a block is bad code style
> 
> Why not just move err: to the end as in:
> 
> 
> 	skb = skb_clone(skb, GFP_ATOMIC);
> 	if (unlikely(!skb))
> 		goto err;
> 
> 	spin_lock(&port->bc_queue.lock);
> 	if (skb_queue_len(&port->bc_queue) < skb->dev->tx_queue_len) {
> 		__skb_queue_tail(&port->bc_queue, skb);
> 		err = 0;
> 	}
> 	spin_unlock(&port->bc_queue.lock);
> 
> 	if (err)
> 		goto err;
> 
> 	schedule_work(&port->bc_work);
> 	return;
> err:
> 
> 	atomic_long_inc(&skb->dev->rx_dropped);
> }

Perhaps the spin_unlock should be duplicated instead
and the "int err" removed.

static void macvlan_broadcast_enqueue(struct macvlan_port *port,
				      struct sk_buff *skb)
{
	skb = skb_clone(skb, GFP_ATOMIC);
	if (!skb)
		goto err;

	spin_lock(&port->bc_queue.lock);
	if (skb_queue_len(&port->bc_queue) >= skb->dev->tx_queue_len)
		goto err_unlock;

	__skb_queue_tail(&port->bc_queue, skb);
	spin_unlock(&port->bc_queue.lock);
	schedule_work(&port->bc_work);

	return;

err_unlock:
	spin_unlock(&port->bc_queue.lock);
err:
	atomic_long_inc(&skb->dev->rx_dropped);
}

  reply	other threads:[~2014-04-08 17:14 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <<20140407075347.GA26461@gondor.apana.org.au>
2014-04-07  7:55 ` [PATCH 1/2] net: Add __dev_forward_skb Herbert Xu
2014-04-07 18:48   ` Stephen Hemminger
2014-04-08  7:15     ` Herbert Xu
2014-04-08 16:27       ` David Miller
2014-04-07  7:55 ` [PATCH 2/2] macvlan: Move broadcasts into a work queue Herbert Xu
2014-04-07 14:07   ` Eric Dumazet
2014-04-07 14:23     ` Herbert Xu
2014-04-08 16:48       ` Ben Greear
2014-04-08 17:23         ` Herbert Xu
2014-04-11  1:40           ` David Miller
2014-04-11  1:59             ` Herbert Xu
2014-04-11  2:09               ` Eric Dumazet
2014-04-11  2:13                 ` Herbert Xu
2014-04-11  8:45                   ` David Laight
2014-04-11 16:11                     ` Ben Greear
2014-04-11 16:20                       ` Ben Greear
2014-04-11 16:17                   ` Ben Greear
2014-04-08 16:55   ` Stephen Hemminger
2014-04-08 17:14     ` Joe Perches [this message]
2014-04-09  8:50     ` Herbert Xu
2014-04-09 10:10       ` David Laight
2014-04-10 12:59         ` Herbert Xu
2014-04-10 14:50           ` David Laight
2014-04-07  7:53 [0/2] macvlan: Handle broadcasts in " Herbert Xu
2014-04-17  5:45 ` [PATCH 1/2] net: Add __dev_forward_skb Herbert Xu
2014-04-20 22:19   ` David Miller
2014-04-17  5:45 ` [PATCH 2/2] macvlan: Move broadcasts into a work queue Herbert Xu
2014-04-20 22:20   ` David Miller

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=1396977252.5212.12.camel@joe-AO722 \
    --to=joe@perches.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.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;
as well as URLs for NNTP newsgroup(s).