Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp462975rdb; Sat, 30 Sep 2023 11:20:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEe1ZjGeoWam/J/zl6rS+toECmtMgt+sXY+AXWTpxTnuNML9uoyopx60VBWqw9Eq8NRyFu6 X-Received: by 2002:a17:90a:2dc2:b0:274:cf7e:f11c with SMTP id q2-20020a17090a2dc200b00274cf7ef11cmr12095771pjm.19.1696098000090; Sat, 30 Sep 2023 11:20:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696098000; cv=none; d=google.com; s=arc-20160816; b=ny8X5Jgv7HxQJMki9C4YcKFpqNUmAdKNcyFRs2HVivq0ZPX9Bc5DiTroyRt7CQqwqi rvVmplytu6hZ3/35FOT60J8GqaZ2HGxP7btk8ZAa3lYPqKG5GxUX5ONxkuuaHyR71rvh DQ5Ea2oyCR/MuuslWk+Rm2gJ7thzXBLOJvwWMLoBu+UGOR3nfmi4504uWb4luxbKbCg7 YBgp1E7FawEmUejq/zPRDzKLtHFySLfe/VW+VroEo08fvn86SaWOyClQ4AQiVX/PM+CY 8PDFuYDCTrtMHV61462jPND6auoxDCldqj7See/s55VpJjQgbY/JhjjosNGRl4AC9jWE k0RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=jswD4b2K1HMAHE6WGzlprCE/UoZOacYHwUT/I0Wyapc=; fh=8LYQn/gIw+V+pQF1F5yweaIwfmvdZXdbQg4sOUyVT0A=; b=IRFOD1VRW9S05NbjhDTTixHZj+iyZo7JZweQlMqOSa6cLoEqb9BxpDKd1klI5eW4C5 vEd0Qzrpn6Crx1JTVBZaQ4BtIujRfDLLg4eu6ngphcraPm1bhCUSFcdfGaTE7fyCZYD5 1wx8TwIe6ymuD74an5jXrhi+w+ktgl7/dxbeax3OD2HZXBg3hUKg3FJUFnRqvF0lN1sg zWILdDRb2iCDUfnN4THUk0yISB7CYpzaBW8+TkLxxdTGxV41eD3ENveNMfuHjxmjqPjO urlyafPeMavHFmsP4fOiD7RkNyauj/duksTbtuuy+nWWlGXpOX/HZEcsv9Eycr3QHFCG MWPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vBOmrl87; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id d24-20020a17090ab31800b002639acf55c7si3951472pjr.7.2023.09.30.11.19.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Sep 2023 11:20:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vBOmrl87; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id E2DA58032026; Sat, 30 Sep 2023 11:19:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234707AbjI3ST5 (ORCPT + 99 others); Sat, 30 Sep 2023 14:19:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233050AbjI3ST5 (ORCPT ); Sat, 30 Sep 2023 14:19:57 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBE95E1; Sat, 30 Sep 2023 11:19:53 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D97A7C433C7; Sat, 30 Sep 2023 18:19:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696097993; bh=VkV7TjXZJnym2EdSAsMapvwnoXQMIzv/8uo4dDQrWTg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=vBOmrl8788GbnxHeP93j29wo1oJzATYxI9FNfCZ+5dQrB5Zfl32IFQxHVQs5Mezw4 qg4RET03lYP+nNNp3ZdBfn1/I+8fe6faywJo5j1LwYGiD25oZBdcYV96BAuVW4pESV GDtUHZblaXnXYqGPF0Pslim6HYcSh6fffRQ68Pu7xz6OVXQyZBGoUcSu2nuRiaZzGc 7Uca+FJvj0NT2Wsy+d5XaonAEHbaAVVuahl6HFm6KNFjvbcR0u4DoemNLVz5GL9tN6 zaEfh4YeXokL6XoDUQxIW3dFzXWGDnJhyFZ2ljWi8VeWvXW0ApGHMrjgx2mhFcrFzz TsWCHsXKX6Q4A== Date: Sat, 30 Sep 2023 20:19:46 +0200 From: Simon Horman To: Haiyang Zhang Cc: "linux-hyperv@vger.kernel.org" , "netdev@vger.kernel.org" , Dexuan Cui , KY Srinivasan , Paul Rosswurm , "olaf@aepfle.de" , vkuznets , "davem@davemloft.net" , "wei.liu@kernel.org" , "edumazet@google.com" , "kuba@kernel.org" , "pabeni@redhat.com" , "leon@kernel.org" , Long Li , "ssengar@linux.microsoft.com" , "linux-rdma@vger.kernel.org" , "daniel@iogearbox.net" , "john.fastabend@gmail.com" , "bpf@vger.kernel.org" , "ast@kernel.org" , Ajay Sharma , "hawk@kernel.org" , "tglx@linutronix.de" , "shradhagupta@linux.microsoft.com" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH net, 3/3] net: mana: Fix oversized sge0 for GSO packets Message-ID: <20230930181946.GG92317@kernel.org> References: <1695519107-24139-1-git-send-email-haiyangz@microsoft.com> <1695519107-24139-4-git-send-email-haiyangz@microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sat, 30 Sep 2023 11:19:59 -0700 (PDT) On Fri, Sep 29, 2023 at 04:11:15PM +0000, Haiyang Zhang wrote: ... > > > @@ -209,19 +281,6 @@ netdev_tx_t mana_start_xmit(struct sk_buff *skb, > > struct net_device *ndev) > > > pkg.wqe_req.client_data_unit = 0; > > > > > > pkg.wqe_req.num_sge = 1 + skb_shinfo(skb)->nr_frags; > > > - WARN_ON_ONCE(pkg.wqe_req.num_sge > > > MAX_TX_WQE_SGL_ENTRIES); > > > - > > > - if (pkg.wqe_req.num_sge <= ARRAY_SIZE(pkg.sgl_array)) { > > > - pkg.wqe_req.sgl = pkg.sgl_array; > > > - } else { > > > - pkg.sgl_ptr = kmalloc_array(pkg.wqe_req.num_sge, > > > - sizeof(struct gdma_sge), > > > - GFP_ATOMIC); > > > - if (!pkg.sgl_ptr) > > > - goto tx_drop_count; > > > - > > > - pkg.wqe_req.sgl = pkg.sgl_ptr; > > > - } > > > > It is unclear to me why this logic has moved from here to further > > down in this function. Is it to avoid some cases where > > alloation has to be unwond on error (when mana_fix_skb_head() fails) ? > > If so, this feels more like an optimisation than a fix. > mana_fix_skb_head() may add one more sge (success case) so the sgl > allocation should be done later. Otherwise, we need to free / re-allocate > the array later. Understood, thanks for the clarification. > > > if (skb->protocol == htons(ETH_P_IP)) > > > ipv4 = true; > > > @@ -229,6 +288,23 @@ netdev_tx_t mana_start_xmit(struct sk_buff *skb, > > struct net_device *ndev) > > > ipv6 = true; > > > > > > if (skb_is_gso(skb)) { > > > + gso_hs = mana_get_gso_hs(skb); > > > + > > > + if (mana_fix_skb_head(ndev, skb, gso_hs, > > &pkg.wqe_req.num_sge)) > > > + goto tx_drop_count; > > > + > > > + if (skb->encapsulation) { > > > + u64_stats_update_begin(&tx_stats->syncp); > > > + tx_stats->tso_inner_packets++; > > > + tx_stats->tso_inner_bytes += skb->len - gso_hs; > > > + u64_stats_update_end(&tx_stats->syncp); > > > + } else { > > > + u64_stats_update_begin(&tx_stats->syncp); > > > + tx_stats->tso_packets++; > > > + tx_stats->tso_bytes += skb->len - gso_hs; > > > + u64_stats_update_end(&tx_stats->syncp); > > > + } > > > > nit: I wonder if this could be slightly more succinctly written as: > > > > u64_stats_update_begin(&tx_stats->syncp); > > if (skb->encapsulation) { > > tx_stats->tso_inner_packets++; > > tx_stats->tso_inner_bytes += skb->len - gso_hs; > > } else { > > tx_stats->tso_packets++; > > tx_stats->tso_bytes += skb->len - gso_hs; > > } > > u64_stats_update_end(&tx_stats->syncp); > > > Yes it can be written this way:) > > > Also, it is unclear to me why the stats logic is moved here from > > futher down in the same block. It feels more like a clean-up than a fix > > (as, btw, is my suggestion immediately above). > Since we need to calculate the gso_hs and fix head earlier than the stats and > some other work, I move it immediately after skb_is_gso(skb). > The gso_hs calculation was part of the tx_stats block, so the tx_stats is moved > together to remain close to the gso_hs calculation to keep readability. I agree it is nice the way you have it. I was mainly thinking that the diffstat could be made smaller, which might be beneficial to a fix. But I have no strong feelings on that. > > > + > > > pkg.tx_oob.s_oob.is_outer_ipv4 = ipv4; > > > pkg.tx_oob.s_oob.is_outer_ipv6 = ipv6; > > > ...