netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Antonio Quartulli <antonio@meshcoding.com>
To: David Laight <David.Laight@ACULAB.COM>
Cc: David Miller <davem@davemloft.net>, netdev@vger.kernel.org
Subject: Re: [PATCHv2 net] netpoll: fix rx_hook() interface by passing the skb
Date: Thu, 24 Oct 2013 14:01:52 +0200	[thread overview]
Message-ID: <20131024120152.GO929@neomailbox.net> (raw)
In-Reply-To: <AE90C24D6B3A694183C094C60CF0A2F6026B73A5@saturn3.aculab.com>

[-- Attachment #1: Type: text/plain, Size: 1520 bytes --]

On Thu, Oct 24, 2013 at 09:43:38AM +0100, David Laight wrote:
> > Subject: [PATCHv2 net] netpoll: fix rx_hook() interface by passing the skb
> > @@ -820,7 +823,10 @@ int __netpoll_rx(struct sk_buff *skb, struct netpoll_info *npinfo)
> > 
> >  		len -= iph->ihl*4;
> >  		uh = (struct udphdr *)(((char *)iph) + iph->ihl*4);
> > +		offset = (unsigned char *)(uh + 1) - skb->data;
> >  		ulen = ntohs(uh->len);
> > +		data_len = skb->len - offset;
> > +		source = ntohs(uh->source);
> > 
> >  		if (ulen != len)
> >  			goto out;
> > @@ -834,9 +840,7 @@ int __netpoll_rx(struct sk_buff *skb, struct netpoll_info *npinfo)
> >  			if (np->local_port && np->local_port != ntohs(uh->dest))
> >  				continue;
> > 
> > -			np->rx_hook(np, ntohs(uh->source),
> > -				       (char *)(uh+1),
> > -				       ulen - sizeof(struct udphdr));
> > +			np->rx_skb_hook(np, source, skb, offset, data_len);
> >  			hits++;
> >  		}
> >  	} else {
> 
> From a code optimisation point of view you probably don't want to be
> calculating the source, offset and length early.
> It is quite likely that the local variables will have to be written
> to the stack (because of the function calls) - so it is almost
> certainly more efficient to calculate them just before the call.

I thought that computing them once outside the loop was better than
re-computing them during each iteration.

Having them outside makes it also clear that they always have the same value.


Regards,

-- 
Antonio Quartulli

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2013-10-24 12:02 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-21 21:31 [PATCH net] netpoll: linearize skb before accessing its data Antonio Quartulli
2013-10-21 22:23 ` David Miller
2013-10-22  6:06   ` Antonio Quartulli
2013-10-22  6:25     ` David Miller
2013-10-22  6:37       ` Antonio Quartulli
2013-10-22  6:50         ` David Miller
2013-10-22  8:48           ` [PATCH net] netpoll: fix rx_hook() interface by passing the skb Antonio Quartulli
2013-10-22  9:09             ` David Laight
2013-10-22 10:11               ` Antonio Quartulli
2013-10-22 12:46                 ` David Laight
2013-10-22 17:13                   ` Antonio Quartulli
2013-10-22 19:40                     ` David Miller
2013-10-23  8:33                     ` David Laight
2013-10-23 10:28                       ` Antonio Quartulli
2013-10-23 11:18                         ` David Laight
2013-10-23 12:44                           ` Antonio Quartulli
2013-10-23 20:16                             ` David Miller
2013-10-23 21:36                               ` [PATCHv2 " Antonio Quartulli
2013-10-24  8:43                                 ` David Laight
2013-10-24 12:01                                   ` Antonio Quartulli [this message]
2013-10-24 17:53                                   ` David Miller
2013-10-25 23:27                                 ` David Miller
2013-10-21 22:25 ` [PATCH net] netpoll: linearize skb before accessing its data Eric Dumazet
2013-10-21 22:33   ` 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=20131024120152.GO929@neomailbox.net \
    --to=antonio@meshcoding.com \
    --cc=David.Laight@ACULAB.COM \
    --cc=davem@davemloft.net \
    --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;
as well as URLs for NNTP newsgroup(s).