From patchwork Tue Feb 7 13:54:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 53913 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2864170wrn; Tue, 7 Feb 2023 06:01:25 -0800 (PST) X-Google-Smtp-Source: AK7set/JxS9pl8K7DNR65XEix3L+ThKu2Ode4Z176OFJkn0EeRBo+mLXZMgdopwRtCSkO8jCV0zl X-Received: by 2002:a17:906:2a0b:b0:887:d0e6:fa24 with SMTP id j11-20020a1709062a0b00b00887d0e6fa24mr3286569eje.76.1675778485526; Tue, 07 Feb 2023 06:01:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675778485; cv=pass; d=google.com; s=arc-20160816; b=IbOceduHUXivt+J3YreuM1xQdpi+4nnmsA9XE58C+aX6SWj1AAA5MYzdm3LJsThyno UE2ZID6ns6XqrLNR1jE/OBCewIExrkWg6X6afS9GtKRr/4M2+eMEanTTiB6NkwA7Dwo3 H3FKKhTERzM3svShhjAByNoqxtCMVZ68NmVgoL3kgtAIcZz6jemR9R8c7/ov1zixQlHf N67CjExnQBSK/SbMBJJYjbDMTZv43MF3WICyqwc8hkdd6MO6zsvVjDOn/wd7bBhKoAfV XOmZZGNu5x2AWHzGhrVR8j48vGDTZHQNUDZmf2S5qZy3J3oAHRHo4r5yjfBzzkbtGnPj W3hg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EeDbZNGeWgvML5Hp8qKyu92dq/8PagPxjbc5NDdh5jw=; b=Q2jI/j+AajS/3IYq32l6zJTPhqB6duNjRJfeyD2gCfy7mB3IiaBwRa9ahKXhtCKQj2 e/ZUtOx5H/RFP1fgf/TKsKRG3qSV3ee1XL8VYboV/bvz2Jm/BIcHldOxdFEeCnJhzNQG DR6/7jVcEL/lBWcLz4kQhSrWHcX2k6J+NmUUTQ8sfiyL4SAWvPPbdy2ZFJ8isOV+G4Du 9vLch3QFoSt/1tCV5uSAUCxsRsy0T6Zvn7L43ayScmCi0XHw0AEVFaPeelWZu4CmA9s3 IQwBr7Uqu4h85HVkpQDtkLEGPfwPuTo2Q4Zsa6nstJDIBSjXGUtGitVNtOSQxwrfbPIM a6LA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=KvA+bv4O; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.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=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 17-20020a17090601d100b0088b9c1de4f9si21827054ejj.9.2023.02.07.06.01.00; Tue, 07 Feb 2023 06:01:25 -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; dkim=pass header.i=@nxp.com header.s=selector2 header.b=KvA+bv4O; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.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=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229991AbjBGN60 (ORCPT + 99 others); Tue, 7 Feb 2023 08:58:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230356AbjBGN6E (ORCPT ); Tue, 7 Feb 2023 08:58:04 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2081.outbound.protection.outlook.com [40.107.7.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B92F0CA27; Tue, 7 Feb 2023 05:57:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IGjGcAkTY8vDIWgQr9AVlpv1j/vRHM2vtJInp5aSrKBuZ3guxl6ioGNBQW/zhuteKuzz+MWEAbsjcZj76z6qNbP3E6M/844l3dIpBiJd2DOnFFEWqGAfYhkB85bokl6OFyYblC9HVLe562UiQOUiqcd9N6svhEgLvtAC8qqHacXu1uY9Yvr/Rh8XxzduZI4oLP3/JXtQHzcvpce63xb8ZmDPAcn3nndLxhrpg0Rw6KbHuovAX44OtV+8EucbH74rOrCZgGEI5Dtd+sMhN4divu/LfFXqws053+AGD0+LrcHbn0Ygy9v8AVu7Z/zcT5tSRc79AMWyyB4K0HN9MRXihA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EeDbZNGeWgvML5Hp8qKyu92dq/8PagPxjbc5NDdh5jw=; b=jq9+EqSiv/mIt/LG6xIjp6uviFbU74oaPWqRc8fe7PFMcm19xPR3gv//nFBsOKCsiH+paZX3R8YDWssWW9zHuZbLO3G5mpZIHd3OnSdFFNI/VkG4lsp4Jt4smMryDCSGul2Gll27Yo6iXRi2P6PyLekJ1Jl9cdQ+ykAldMCTGpcmoLEmE5g17RepFO3PuI2DgNRrJTkTFUzE9Jy7IxL1ol8PMd4oIe3BhmB3wFq/rNJI9Yd13UffbRG8fQnx+63KPLwjo7bQ7k9VIZhDTSQa6XVk1YiRdoAtM+aFevFl21RJppegnhd4Ia4HT/GitnEg5JzpC6kiOEmw9X+td+V3WA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EeDbZNGeWgvML5Hp8qKyu92dq/8PagPxjbc5NDdh5jw=; b=KvA+bv4OOmmIcTjiFR+S8BJxM2IjU3nqQ8lG1ODT7OvsLJvYHMF8lQ/zXKIYRKeERXcXco0uJU471NwldyvuLtSZtBUkoABCqe41nL/2M61l0BYXv+xqmDCLj+vvTbNych058w7o0T3oW95xl5LqVOdpcdiUHyqkMECD+IGfMAM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by AM9PR04MB8115.eurprd04.prod.outlook.com (2603:10a6:20b:3e8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.36; Tue, 7 Feb 2023 13:55:33 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%5]) with mapi id 15.20.6064.034; Tue, 7 Feb 2023 13:55:32 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Gerhard Engleder , Jesse Brandeburg , Tony Nguyen , intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 net-next 14/15] net/sched: taprio: split segmentation logic from qdisc_enqueue() Date: Tue, 7 Feb 2023 15:54:39 +0200 Message-Id: <20230207135440.1482856-15-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230207135440.1482856-1-vladimir.oltean@nxp.com> References: <20230207135440.1482856-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AS4PR10CA0023.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:5d8::15) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|AM9PR04MB8115:EE_ X-MS-Office365-Filtering-Correlation-Id: 90aec37d-a53d-4815-6164-08db0912facf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DIiH2Vq3XrhK+JB7Lfb8N4DE2RuCBgvhl7AMH3WmI6F9BtQxOlIO6vCExrDKxA2dt+mX0sOtORJr3lhNr+N1QAoBbaVg9H5vK72LTZT/DNGiTVKaVqB/EwFJ9BlwcmSC2Qig7TriHIckAWaxtq4lg/OQCchvUTYFd4FdVXRiRLTwhe7OVnuesCQ19qSF6QEmiIF0rYh2VJRugztAaUhdS+jVLhKniQqMnzrFNjla3TsNuXjgomu/UqK36qEG0A20hQegGlsG8JCxurH+sPtnuGvY3RjsJYRCj7oETIRjrzAK+Lv4z8e3cEJEYHVAvaDyTsX78T0H9DPorEmyc7gbkTNqmIf/z1Qo7YRTQYdaCAvk51Jq1NIBf4qGK1n2DuPEfC8fezG+ycCr3gKbFXTly3PXLndwXFYctroyIFhQNu7HWwKZkm+vmPZwYen/cBktWexzneF2/Q8fmimrXoVILfDFxcceufRC3FkIOlAn1Px5BvEIctj+Paq/P3dL7d2CmfLBdtRvP7jRWzuPT/cCX+jEv+aF1RbB1EQ/jmoh7weqRf43dpOchCh52w7ZGX9GKGzGB6XdHCIV/yl8/6+T3KQD91sSTF+Fh92ZEaQEnf0uqVixMvpY8aINA7JPehLFmJppA37t8xRbXoo5Ye14uqybV0qeuhgGX3sdKXON85hrWJVtsHv376v8ZF2dXN984Ra+srRhQEd4DcR8VkuH5w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(39860400002)(396003)(346002)(366004)(136003)(376002)(451199018)(2906002)(8676002)(38350700002)(38100700002)(316002)(83380400001)(6916009)(66556008)(66476007)(8936002)(4326008)(41300700001)(44832011)(5660300002)(7416002)(66946007)(2616005)(1076003)(6506007)(478600001)(6486002)(186003)(26005)(6512007)(86362001)(54906003)(52116002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hsSHk5V4Hcpd35RXkW9iux5IaR3caKsEzf7+ancpMhUCQtOCv10htbQahbXzPaA0P1urI1HBl8nVVCDyfuih3jH3E6qZ5TevdfLS+AJJR5XuxXjwrLOoqEZTJD5Exf67KeJgV3Ztau+OTaswajR5W1Z6O29pYSpwPMhDqlbR7gMeEzg/0xABERXxFC+RIl6YfZ2TnN8nR2QWs6qcZQ/UpSBPdYcclTSLb/gH9mX35dFQp1orVP2pspeF/A+/NNJBKQw929OjzbXPK4kBFdMYL7+y2gapAARoUjd6zV+6GpV7nI6vAJDfJTBxWGpiijGPY6GdnF6Pbrilf9kzxD0gdwn+oUQXHT2J+Ps9MgqR1jcdxsC1L0GxbBAnFDH9+hje1ORYOBUbeoC0lWs3zNptYWKIp3RhLPS5Hv1h3iUPsfChpVFEKhhbpqlmDX9ReGsmV/pNDKYgk0sREXSxCilkpIgnUk8vo+x/Nm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VsDUIYOwoH4p9MNLD9DrgJ+7UKPDLLDzffMEAiwC4xybOruEFZ4pWafpvLu+Ls6UkwEA952VRb5pAykAWioFew== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 90aec37d-a53d-4815-6164-08db0912facf X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2023 13:55:32.8606 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jxU7qpqsV/8X1tMDWJN4NoTPOOCdTOYZ2UfwPdMl201UwDULUbOfbW1cc2JPU4BzKczYy9kVn7+DQhnQ2yvm9w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8115 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757181101024137085?= X-GMAIL-MSGID: =?utf-8?q?1757181101024137085?= The majority of the taprio_enqueue()'s function is spent doing TCP segmentation, which doesn't look right to me. Compilers shouldn't have a problem in inlining code no matter how we write it, so move the segmentation logic to a separate function. Signed-off-by: Vladimir Oltean Reviewed-by: Kurt Kanzenbach --- v1->v2: none net/sched/sch_taprio.c | 66 +++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index e7163d6fab77..839beb599f55 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -575,6 +575,40 @@ static int taprio_enqueue_one(struct sk_buff *skb, struct Qdisc *sch, return qdisc_enqueue(skb, child, to_free); } +static int taprio_enqueue_segmented(struct sk_buff *skb, struct Qdisc *sch, + struct Qdisc *child, + struct sk_buff **to_free) +{ + unsigned int slen = 0, numsegs = 0, len = qdisc_pkt_len(skb); + netdev_features_t features = netif_skb_features(skb); + struct sk_buff *segs, *nskb; + int ret; + + segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK); + if (IS_ERR_OR_NULL(segs)) + return qdisc_drop(skb, sch, to_free); + + skb_list_walk_safe(segs, segs, nskb) { + skb_mark_not_on_list(segs); + qdisc_skb_cb(segs)->pkt_len = segs->len; + slen += segs->len; + + ret = taprio_enqueue_one(segs, sch, child, to_free); + if (ret != NET_XMIT_SUCCESS) { + if (net_xmit_drop_count(ret)) + qdisc_qstats_drop(sch); + } else { + numsegs++; + } + } + + if (numsegs > 1) + qdisc_tree_reduce_backlog(sch, 1 - numsegs, len - slen); + consume_skb(skb); + + return numsegs > 0 ? NET_XMIT_SUCCESS : NET_XMIT_DROP; +} + /* Will not be called in the full offload case, since the TX queues are * attached to the Qdisc created using qdisc_create_dflt() */ @@ -596,36 +630,8 @@ static int taprio_enqueue(struct sk_buff *skb, struct Qdisc *sch, * smaller chunks. Drivers with full offload are expected to handle * this in hardware. */ - if (skb_is_gso(skb)) { - unsigned int slen = 0, numsegs = 0, len = qdisc_pkt_len(skb); - netdev_features_t features = netif_skb_features(skb); - struct sk_buff *segs, *nskb; - int ret; - - segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK); - if (IS_ERR_OR_NULL(segs)) - return qdisc_drop(skb, sch, to_free); - - skb_list_walk_safe(segs, segs, nskb) { - skb_mark_not_on_list(segs); - qdisc_skb_cb(segs)->pkt_len = segs->len; - slen += segs->len; - - ret = taprio_enqueue_one(segs, sch, child, to_free); - if (ret != NET_XMIT_SUCCESS) { - if (net_xmit_drop_count(ret)) - qdisc_qstats_drop(sch); - } else { - numsegs++; - } - } - - if (numsegs > 1) - qdisc_tree_reduce_backlog(sch, 1 - numsegs, len - slen); - consume_skb(skb); - - return numsegs > 0 ? NET_XMIT_SUCCESS : NET_XMIT_DROP; - } + if (skb_is_gso(skb)) + return taprio_enqueue_segmented(skb, sch, child, to_free); return taprio_enqueue_one(skb, sch, child, to_free); }