[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1411556068.15395.10.camel@edumazet-glaptop2.roam.corp.google.com>
Date: Wed, 24 Sep 2014 03:54:28 -0700
From: Eric Dumazet <eric.dumazet@...il.com>
To: Weiping Pan <panweiping3@...il.com>
Cc: netdev@...r.kernel.org, edumazet@...gle.com
Subject: Re: [PATCH net-next] tcp: use tcp_flags in tcp_data_queue()
On Wed, 2014-09-24 at 18:35 +0800, Weiping Pan wrote:
> Follow the idea in commit e11ecddf5128 (tcp: use TCP_SKB_CB(skb)->tcp_flags in
> input path), we can use tcp_flags to avoid cache miss.
>
> Signed-off-by: Weiping Pan <panweiping3@...il.com>
> ---
> net/ipv4/tcp_input.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> index 13f3da4..85298c9 100644
> --- a/net/ipv4/tcp_input.c
> +++ b/net/ipv4/tcp_input.c
> @@ -4392,7 +4392,7 @@ queue_and_out:
> tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq;
> if (skb->len)
> tcp_event_data_recv(sk, skb);
> - if (th->fin)
> + if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)
> tcp_fin(sk);
>
> if (!skb_queue_empty(&tp->out_of_order_queue)) {
I thought of this, but my reasoning was that we needed th anyway, and
th->fin had the same cost.
But thinking more about this, its possible compiler can generate better
code, as tcp_hdr() will only be needed at the very beginning of the
function, and compiler no longer has to keep around th value.
Could you go one step further maybe ?
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index f3f016a15c5a..1a399737802b 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -4344,7 +4344,6 @@ err:
static void tcp_data_queue(struct sock *sk, struct sk_buff *skb)
{
- const struct tcphdr *th = tcp_hdr(skb);
struct tcp_sock *tp = tcp_sk(sk);
int eaten = -1;
bool fragstolen = false;
@@ -4353,7 +4352,7 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb)
goto drop;
skb_dst_drop(skb);
- __skb_pull(skb, th->doff * 4);
+ __skb_pull(skb, tcp_hdr(skb)->doff * 4);
TCP_ECN_accept_cwr(tp, skb);
@@ -4397,7 +4396,7 @@ queue_and_out:
tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq;
if (skb->len)
tcp_event_data_recv(sk, skb);
- if (th->fin)
+ if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)
tcp_fin(sk);
if (!skb_queue_empty(&tp->out_of_order_queue)) {
--
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