From: Changli Gao <xiaosuo@gmail.com>
To: David Miller <davem@davemloft.net>
Cc: eric.dumazet@gmail.com, therbert@google.com,
netdev@vger.kernel.org, netfilter-devel@vger.kernel.org
Subject: Re: [PATCH v5] rps: Receive Packet Steering
Date: Thu, 21 Jan 2010 15:04:13 +0800 [thread overview]
Message-ID: <412e6f7f1001202304n5e34aaebu6c052687ce355582@mail.gmail.com> (raw)
In-Reply-To: <20100115.012613.223485835.davem@davemloft.net>
On Fri, Jan 15, 2010 at 5:26 PM, David Miller <davem@davemloft.net> wrote:
> From: Changli Gao <xiaosuo@gmail.com>
> Date: Fri, 15 Jan 2010 17:20:43 +0800
>
> Calling a function is expensive.
>
> What was now a leaf function deep in the call chain, will no longer
> be, so GCC will need to push all live registers onto the stack,
> then reload them back into registers when ipv6_skip_exthdr() returns.
>
> And that function is expensive, it's a lot of code that %99 of the
> time serves no purpose at all.
>
> This will be executed for every single packet we process, and Linux
> can process millions of packets per second, so every cycle and every
> memory reference matters.
>
We can write a new inline function like this:
static inline int ipv6_get_ports(const struct sk_buff *skb, u16 *port1,
u16 *port2)
{
u8 nexthdr;
int hdrlen;
nexthdr = ipv6_hdr(skb)->nexthdr;
hdrlen = sizeof(struct ipv6hdr);
while (1) {
switch (nexthdr) {
case IPPROTO_TCP:
case IPPROTO_UDP:
case IPPROTO_DCCP:
case IPPROTO_ESP:
case IPPROTO_AH:
case IPPROTO_SCTP:
case IPPROTO_UDPLITE:
skb_copy_bits(skb, hdrlen, port1, 2);
skb_copy_bits(skb, hdrlen + 2, port2, 2);
return 0;
case NEXTHDR_HOP:
case NEXTHDR_ROUTING:
case NEXTHDR_FRAGMENT:
case NEXTHDR_AUTH:
case NEXTHDR_DEST:
// some code like ipv6_skip_exthdr()
....
break;
case NEXTHDR_NONE:
return -1;
default:
return -1;
}
}
}
--
Regards,
Changli Gao(xiaosuo@gmail.com)
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2010-01-21 7:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <alpine.DEB.1.00.1001141353140.19018@pokey.mtv.corp.google.com>
2010-01-15 2:22 ` [PATCH v5] rps: Receive Packet Steering Changli Gao
2010-01-15 6:19 ` Eric Dumazet
2010-01-15 6:39 ` Changli Gao
2010-01-15 6:57 ` Eric Dumazet
2010-01-15 8:49 ` David Miller
2010-01-15 9:20 ` Changli Gao
2010-01-15 9:26 ` David Miller
2010-01-21 7:04 ` Changli Gao [this message]
2010-01-15 9:45 ` David Miller
2010-01-15 8:50 ` David Miller
2010-01-15 9:05 ` Changli Gao
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=412e6f7f1001202304n5e34aaebu6c052687ce355582@mail.gmail.com \
--to=xiaosuo@gmail.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=therbert@google.com \
/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).