Message ID | 20221208024303.11191-1-linyunsheng@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp525531wrr; Wed, 7 Dec 2022 18:45:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf4Ul3HE5CSD4yZLi8yU1GP2NFngcnAYWv3sBGEfIz8HANKIL7SykxAZVShEEiUF8pB1xC4p X-Received: by 2002:a17:90a:5787:b0:218:8398:5846 with SMTP id g7-20020a17090a578700b0021883985846mr98857787pji.241.1670467517578; Wed, 07 Dec 2022 18:45:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670467517; cv=none; d=google.com; s=arc-20160816; b=XPz9rWwx2p+E5vz6Q7dL3BzU0RJ6YxiF9zVxpOFw/toEgJik7vv1+ng+Oxj/4BICW0 I3wTod9xcyyELzN1B41by6KBV9MZyRWEK7SG2YM1TbWw3I/ewOFH2OC14p0qi3xosP/Z lL/fkGuxbBDYfX+z+d8dLNDocI8Yzl9Pej2u7PFyHe+l5oAku5FEMWj1qYiq7EGhWbDL szmPCnQiqFZGOSCafvgPnbPamNa1RhE5ZvkDNBKXGPdE3ljxvXE8eutmT8HMbPKuoGLj /jy85FPSj1T2dsWYFHO4LlvFVQdwXaN8KLpON0fxTxIeye3XhHwvCnV8aWxicpcF+E74 xD2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=WAme4aqDB8ORodtyGNky5I8CRm9/eZTEH18v0v1Bxf0=; b=a7fRRY5mJLoj9EPvpJjTivqriYz7UIUjMXyz72xaO+GcSnjHr9ixZbXZBbJ73DqD8g SHkOAzy04oijwdeVP1fkhRqW+PvVLRoctPDmrQYpKAPTTx3WG/8L9pkIVBArwmh8cM5e 8EUTioMJ9gMGJJO0Z/00M3tYbgQH4QSMBBnjnOsmnkYcINUD1mHheGWqxjusfQ8CUQIM kufAVEPQPNWdXzY30yOCR2LUPgYgffYlpZltUBD8YC8yC9iil/LBtzruOTMNwege6IdM oQSgvYmtKgbXPz9qbHlZo3lZ832QTtTmJHVumLeUnj/ofCh3JgxOexLSrEAIbM7T4TKQ xbvg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t18-20020a1709028c9200b00186ba4ba494si20402608plo.475.2022.12.07.18.45.02; Wed, 07 Dec 2022 18:45:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229812AbiLHCnA (ORCPT <rfc822;foxyelen666@gmail.com> + 99 others); Wed, 7 Dec 2022 21:43:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229724AbiLHCm6 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 7 Dec 2022 21:42:58 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 868E256566; Wed, 7 Dec 2022 18:42:56 -0800 (PST) Received: from dggpemm500005.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NSJMb1zzlzRprN; Thu, 8 Dec 2022 10:42:03 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by dggpemm500005.china.huawei.com (7.185.36.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 8 Dec 2022 10:42:54 +0800 From: Yunsheng Lin <linyunsheng@huawei.com> To: <davem@davemloft.net>, <kuba@kernel.org>, <pabeni@redhat.com>, <edumazet@google.com> CC: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <linuxarm@openeuler.org> Subject: [PATCH net-next] net: tso: inline tso_count_descs() Date: Thu, 8 Dec 2022 10:43:03 +0800 Message-ID: <20221208024303.11191-1-linyunsheng@huawei.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500005.china.huawei.com (7.185.36.74) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751612147852380414?= X-GMAIL-MSGID: =?utf-8?q?1751612147852380414?= |
Series |
[net-next] net: tso: inline tso_count_descs()
|
|
Commit Message
Yunsheng Lin
Dec. 8, 2022, 2:43 a.m. UTC
tso_count_descs() is a small function doing simple calculation,
and tso_count_descs() is used in fast path, so inline it to
reduce the overhead of calls.
Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
---
include/net/tso.h | 8 +++++++-
net/core/tso.c | 8 --------
2 files changed, 7 insertions(+), 9 deletions(-)
Comments
On Thu, 8 Dec 2022 10:43:03 +0800 Yunsheng Lin wrote: > tso_count_descs() is a small function doing simple calculation, > and tso_count_descs() is used in fast path, so inline it to > reduce the overhead of calls. TSO frames are large, the overhead is fine. I'm open to other opinions but I'd rather keep the code as is than deal with the influx with similar sloppily automated changes. > diff --git a/include/net/tso.h b/include/net/tso.h > index 62c98a9c60f1..ab6bbf56d984 100644 > --- a/include/net/tso.h > +++ b/include/net/tso.h > @@ -16,7 +16,13 @@ struct tso_t { > u32 tcp_seq; > }; no include for skbuff.h here > -int tso_count_descs(const struct sk_buff *skb); > +/* Calculate expected number of TX descriptors */ > +static inline int tso_count_descs(const struct sk_buff *skb) > +{ > + /* The Marvell Way */ these comments should be rewritten as we move the function clearly calculates the worst case buffer count > + return skb_shinfo(skb)->gso_segs * 2 + skb_shinfo(skb)->nr_frags; > +}
On Thu, 8 Dec 2022 19:57:21 -0800 Jakub Kicinski wrote: > On Thu, 8 Dec 2022 10:43:03 +0800 Yunsheng Lin wrote: > > tso_count_descs() is a small function doing simple calculation, > > and tso_count_descs() is used in fast path, so inline it to > > reduce the overhead of calls. > > TSO frames are large, the overhead is fine. > I'm open to other opinions but I'd rather keep the code as is than > deal with the influx with similar sloppily automated changes. Oh, wait, you're not one of the bot people. Sorry, please just address my comments and post a v2. There is a lot of poorly written patches coming from @huawei addresses which are giving the company a bad name :(
On 2022/12/9 11:57, Jakub Kicinski wrote: > On Thu, 8 Dec 2022 10:43:03 +0800 Yunsheng Lin wrote: >> tso_count_descs() is a small function doing simple calculation, >> and tso_count_descs() is used in fast path, so inline it to >> reduce the overhead of calls. > > TSO frames are large, the overhead is fine. > I'm open to other opinions but I'd rather keep the code as is than > deal with the influx with similar sloppily automated changes. > >> diff --git a/include/net/tso.h b/include/net/tso.h >> index 62c98a9c60f1..ab6bbf56d984 100644 >> --- a/include/net/tso.h >> +++ b/include/net/tso.h >> @@ -16,7 +16,13 @@ struct tso_t { >> u32 tcp_seq; >> }; > > no include for skbuff.h here Do you mean including skbuff.h explicitly in tso.h? It seems ip.h included in tso.h has included skbuff.h. > >> -int tso_count_descs(const struct sk_buff *skb); >> +/* Calculate expected number of TX descriptors */ >> +static inline int tso_count_descs(const struct sk_buff *skb) >> +{ >> + /* The Marvell Way */ > > these comments should be rewritten as we move > the function clearly calculates the worst case buffer count Will change to below: /* Calculate the worst case buffer count */ > >> + return skb_shinfo(skb)->gso_segs * 2 + skb_shinfo(skb)->nr_frags; >> +} > . >
On 2022/12/9 11:59, Jakub Kicinski wrote: > On Thu, 8 Dec 2022 19:57:21 -0800 Jakub Kicinski wrote: >> On Thu, 8 Dec 2022 10:43:03 +0800 Yunsheng Lin wrote: >>> tso_count_descs() is a small function doing simple calculation, >>> and tso_count_descs() is used in fast path, so inline it to >>> reduce the overhead of calls. >> >> TSO frames are large, the overhead is fine. >> I'm open to other opinions but I'd rather keep the code as is than >> deal with the influx with similar sloppily automated changes. > > Oh, wait, you're not one of the bot people. Sorry, please just address > my comments and post a v2. > Sure. My job has shifted a little bit in huawei, and has not contributed to the community much as used to be. but I still look for similar pattern in the kernel when dealing with problem, when there is some improvement to the related code, I will contribute back:) > . >
On Fri, 9 Dec 2022 16:48:57 +0800 Yunsheng Lin wrote: > >> diff --git a/include/net/tso.h b/include/net/tso.h > >> index 62c98a9c60f1..ab6bbf56d984 100644 > >> --- a/include/net/tso.h > >> +++ b/include/net/tso.h > >> @@ -16,7 +16,13 @@ struct tso_t { > >> u32 tcp_seq; > >> }; > > > > no include for skbuff.h here > > Do you mean including skbuff.h explicitly in tso.h? > It seems ip.h included in tso.h has included skbuff.h. Yes, we need the definition of skb_shinfo() so let's include the header. Let's not depend on second-order includes, it makes refactoring harder. > >> -int tso_count_descs(const struct sk_buff *skb); > >> +/* Calculate expected number of TX descriptors */ > >> +static inline int tso_count_descs(const struct sk_buff *skb) > >> +{ > >> + /* The Marvell Way */ > > > > these comments should be rewritten as we move > > the function clearly calculates the worst case buffer count > > Will change to below: > /* Calculate the worst case buffer count */ Thanks, you can replace the comment about the function with this comment. No need to have two comments, and mentioning descriptors is slightly confusing because descriptor is not always equivalent to a buffer.
diff --git a/include/net/tso.h b/include/net/tso.h index 62c98a9c60f1..ab6bbf56d984 100644 --- a/include/net/tso.h +++ b/include/net/tso.h @@ -16,7 +16,13 @@ struct tso_t { u32 tcp_seq; }; -int tso_count_descs(const struct sk_buff *skb); +/* Calculate expected number of TX descriptors */ +static inline int tso_count_descs(const struct sk_buff *skb) +{ + /* The Marvell Way */ + return skb_shinfo(skb)->gso_segs * 2 + skb_shinfo(skb)->nr_frags; +} + void tso_build_hdr(const struct sk_buff *skb, char *hdr, struct tso_t *tso, int size, bool is_last); void tso_build_data(const struct sk_buff *skb, struct tso_t *tso, int size); diff --git a/net/core/tso.c b/net/core/tso.c index 4148f6d48953..e00796e3b146 100644 --- a/net/core/tso.c +++ b/net/core/tso.c @@ -5,14 +5,6 @@ #include <net/tso.h> #include <asm/unaligned.h> -/* Calculate expected number of TX descriptors */ -int tso_count_descs(const struct sk_buff *skb) -{ - /* The Marvell Way */ - return skb_shinfo(skb)->gso_segs * 2 + skb_shinfo(skb)->nr_frags; -} -EXPORT_SYMBOL(tso_count_descs); - void tso_build_hdr(const struct sk_buff *skb, char *hdr, struct tso_t *tso, int size, bool is_last) {