Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2957984imm; Mon, 28 May 2018 20:57:00 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKXCBQyukWyADXEFUdu9FHFvLTDMlY8WJ1xipSu7/U8Tn07vncULKNv++H9XI02Lo2HaPZM X-Received: by 2002:a62:4a0c:: with SMTP id x12-v6mr3616127pfa.142.1527566220364; Mon, 28 May 2018 20:57:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527566220; cv=none; d=google.com; s=arc-20160816; b=hu3wxfDvupgHy4uQjkYeTTwXtIb9caj62Mzs3Z0416xzszZ12bo9mOOFMmdAVMOoIQ 37ruEL6WPqyEwUZnrKx/9/Wz0QyRfoUO+Q3XXXyDdHs0HmbSx06zhsXChAINAPi2wPGw v3GVRKygBCvOesBoheKBSSA9y6BN+rkDZ/sGgesVMk+X/3dmbJnJ6r+NsnimKdywMSVy +fC5zi9Um88poPmq+FkJUhNng9LSyh3P96LFAz72DMDhOsKwoGvYptIqkyOdv8dQdK9/ s4Jhj+//LnfHYLAKcuyaS5WD4G8/qqhjYe7LqR5urvXvgF4L9AB1oEFA0aJFfn7ddshR lfZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=SCTVjiN1TsaBnvcxFBKLRv7tzw+WmLd1hJTUV/G2l2A=; b=Y1chP8v+bxWbpEAYMITSjPw0nNG1E9seC66m88qICL4SF6QrJTt93SvSCuWXJZ/Mw9 QqedeA61cfc4Dx4N42mK8LpAio0/NbW9mjH72uQcQ+3W255iqyK6JBhImFQNxIWFE/9k 9kcd7MlL9y2HY34j4dLaJHgnI4jhiegyfqgot0vwPdTXmPQ9G2j2PFRC0z1A0eb/odZ7 xVZXpKlv5HEi2YZuYL3RRgX/utY9KSqKnB9hGUEnCR653DxpI9+nuzs2VG1ePUxpN0i8 u9DmlmD1Z/3dTd0ze4l/Sa4K6Sph/hkYUM/oVnxI11tE+NRGlVNSMLpqgNpja07kz4na 8xug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=t2jKNYOI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a10-v6si3498599plm.248.2018.05.28.20.56.45; Mon, 28 May 2018 20:57:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=t2jKNYOI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754901AbeE2AmG (ORCPT + 99 others); Mon, 28 May 2018 20:42:06 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:36130 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754471AbeE2AmE (ORCPT ); Mon, 28 May 2018 20:42:04 -0400 Received: by mail-io0-f196.google.com with SMTP id d73-v6so15705948iog.3; Mon, 28 May 2018 17:42:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=SCTVjiN1TsaBnvcxFBKLRv7tzw+WmLd1hJTUV/G2l2A=; b=t2jKNYOIGYSTAn8Z0XnhM5NnclTc9I/46R8CZ98d+GD1tE6L3DY3X0Tj/PSVMU0PUc tOW/YWI5pvlqBRYELEOPEUyLpwneFDOR53BvP3QxH0AGMHpGZ5OX4NdOBRdjyQK6wnZz GczcmhpJGihHSmxAbtjhd8Swyv0BqVoEsZs718lVGQSxIQHrXnWAOuNXbN3iPqOaNsmX TaaaYj6MnKtIE/3wJ4CMqz7pnTawfv2ANJLfE5zR0tBiIAf+EA71iCDZSToVGQgCr0um 5edt/EGTJ66ib5AbF79K+o8o/55l/QZVsVWedip+CQ4JEvygcgQFwQXXG+G6uJk/oWOH bPaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=SCTVjiN1TsaBnvcxFBKLRv7tzw+WmLd1hJTUV/G2l2A=; b=olQfgSCSbua3AJ2PlGOhlBHh6as6V8g4RvHQcNqWrBmgGGzV0nuUag88RaWqgZCK0b Ze8GbMePlNZfn0jrSEvqB75O0XDAJ/BlWxKkx/4Ps4jPIR71P8libmDq58mEx6i7LENg bPeWL16htETF4dSXF8rHPEap4yjzApfQakkeaMEdDecBVkNEKKTPxlQa1OfQzS0rjpjB Y3QchpZ/Wc/CurVDOFrw8A4W702d1GF9ItuqBea0EeQzhT8U0mQ69WJ5PRKwVHQBxkBR VZk3atvOPP5UweRja/2WjqX46odA8YD5MNDEOdnAiPIAHhauESwHK49ZMPyviCngYcXK 9zcg== X-Gm-Message-State: ALKqPwer2cvAxtusfOgFQEKzM1W3VbFDqprW+hKouvZIPDA6z/+nCNL4 2RL41REVFA08RM+CwK2JsYDdlLRAp2RL/TfIR68= X-Received: by 2002:a6b:9a05:: with SMTP id c5-v6mr12029519ioe.142.1527554523839; Mon, 28 May 2018 17:42:03 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:ef03:0:0:0:0:0 with HTTP; Mon, 28 May 2018 17:41:23 -0700 (PDT) In-Reply-To: References: <1527521753-17963-1-git-send-email-laoar.shao@gmail.com> <1527521753-17963-2-git-send-email-laoar.shao@gmail.com> From: Yafang Shao Date: Tue, 29 May 2018 08:41:23 +0800 Message-ID: Subject: Re: [PATCH v3 net-next 2/2] tcp: minor optimization around tcp_hdr() usage in tcp receive path To: Eric Dumazet Cc: Song Liu , David Miller , netdev , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 29, 2018 at 12:36 AM, Eric Dumazet wrote: > On Mon, May 28, 2018 at 8:36 AM Yafang Shao wrote: > >> This is additional to the commit ea1627c20c34 ("tcp: minor optimizations > around tcp_hdr() usage"). >> At this point, skb->data is same with tcp_hdr() as tcp header has not >> been pulled yet. > >> Cc: Eric Dumazet >> Signed-off-by: Yafang Shao >> --- >> net/ipv4/tcp_ipv4.c | 2 +- >> net/ipv6/tcp_ipv6.c | 2 +- >> 2 files changed, 2 insertions(+), 2 deletions(-) > >> diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c >> index adbdb50..d179386 100644 >> --- a/net/ipv4/tcp_ipv4.c >> +++ b/net/ipv4/tcp_ipv4.c >> @@ -1486,7 +1486,7 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff > *skb) >> sk->sk_rx_dst = NULL; >> } >> } >> - tcp_rcv_established(sk, skb, tcp_hdr(skb)); >> + tcp_rcv_established(sk, skb, (const struct tcphdr > *)skb->data); >> return 0; >> } > >> diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c >> index 7d47c2b..1c633ff 100644 >> --- a/net/ipv6/tcp_ipv6.c >> +++ b/net/ipv6/tcp_ipv6.c >> @@ -1322,7 +1322,7 @@ static int tcp_v6_do_rcv(struct sock *sk, struct > sk_buff *skb) >> } >> } > >> - tcp_rcv_established(sk, skb, tcp_hdr(skb)); >> + tcp_rcv_established(sk, skb, (const struct tcphdr > *)skb->data); >> if (opt_skb) >> goto ipv6_pktoptions; >> return 0; >> -- >> 1.8.3.1 > > > I would rather remove the third parameter of tcp_rcv_established() instead > of duplicating the cast. OK. And what about introducing a new helper tcp_hdr_fast() ? /* use it when tcp header has not been pulled yet */ static inline struct tcphdr *tcp_hdr_fast(const struct sk_buff *skb) { return (const struct tcphdr *)skb->data; } That could help us to use this optimized one instead of the original one if possilbe. Thanks Yafang