[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <412e6f7f1001202304n5e34aaebu6c052687ce355582@mail.gmail.com>
Date: Thu, 21 Jan 2010 15:04:13 +0800
From: Changli Gao <xiaosuo@...il.com>
To: David Miller <davem@...emloft.net>
Cc: eric.dumazet@...il.com, therbert@...gle.com,
netdev@...r.kernel.org, netfilter-devel@...r.kernel.org
Subject: Re: [PATCH v5] rps: Receive Packet Steering
On Fri, Jan 15, 2010 at 5:26 PM, David Miller <davem@...emloft.net> wrote:
> From: Changli Gao <xiaosuo@...il.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@...il.com)
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists