Received: by 2002:a05:622a:1442:b0:3a5:28ea:c4b9 with SMTP id v2csp805717qtx; Mon, 31 Oct 2022 14:25:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4vO93eN3Yi3ZC/IURvkvmegfOyKFPaICzg6/eTwaD7M+bPGN0HEOenIRcQNirMJqQr6VrU X-Received: by 2002:a65:4909:0:b0:46b:2752:e4ab with SMTP id p9-20020a654909000000b0046b2752e4abmr14582942pgs.293.1667251558846; Mon, 31 Oct 2022 14:25:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667251558; cv=none; d=google.com; s=arc-20160816; b=mXwnIBDzhTWITWQ/TYwrySmLCvC4EVsnGlsJo3xe/SgNDQnqS7FoIiTjATMVhLvIQW K17Uj4IDuNoAVowGyMSUK50PKmI3LLp34pX21ZWatpFME68pbrVLvUw0GkdBHHvlpCiS Fu7ndnLQYPgjk4DPObw309uive3EfX8UavgLaWiESc5assZ+mVU2Wf8+mHDXAe6NeejW dhFrEGeIJApvTPl3An2SK19apIAOqdYi6pEgxr7/L+kBxzDWXsSFMr9tMazmn0Z4urX0 kuzYia1bkPpU7Gx1M0Di832QKpSVCmP/th7ZX6S0/ZL60ZcPeGUgtrcciWz65W2/8huS ikWg== 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=k76g8mPvFlEsezniA/wfzLnncWnwoBf8Gjp4kw6Bjfs=; b=aOp7f0QsVdn607/WmCRnQaC702+BKnxmX52jd/TP6/aqXS8Jpwfo2JZtnjUiJxtUr7 Q3Xc/Wn1nln1xDh8zteSbOwDta/VL1WY487Hf6upXAKl6CdZIQji1xOCKCeYRvcT8Rrp PTh/XRKZNdzZNJdhliMEDQe+oMoywkNXxFX8XpTzHz0bE/MQzGqeqMdS9igu4+75THGi izLp/zna25hPZen45TqsaC9zVfXf12cg+9upcUNTtfxg7RxYFGow4uKtYkvXa20RLpUN vxnBGm7tZreiwaIg35c7dxuwzQgiHK5HhwMb6sVp72X8jLhVyRkVwxby1VoRVOex+oOl /v5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b="gPhd/zBy"; 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=lunn.ch Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i11-20020a63130b000000b0046ef5b35735si10437113pgl.654.2022.10.31.14.25.19; Mon, 31 Oct 2022 14:25:58 -0700 (PDT) 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=@lunn.ch header.s=20171124 header.b="gPhd/zBy"; 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=lunn.ch Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230112AbiJaUS1 (ORCPT + 98 others); Mon, 31 Oct 2022 16:18:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229721AbiJaUSY (ORCPT ); Mon, 31 Oct 2022 16:18:24 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 587C6DD; Mon, 31 Oct 2022 13:18:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=k76g8mPvFlEsezniA/wfzLnncWnwoBf8Gjp4kw6Bjfs=; b=gPhd/zBywntCe7Ln240c4GIlxd R5bz4c6omlPxFAvMBH0RerjVxsZHIqkzcpoo0otBjauOSEhJCrxSx6xnq1Qy1Tjo58NwOVIH5z9O7 hYNrxQfWOmWnlSffTqerNBJGgpMf9TW+uAZEm2B7XskYuElv2Bf8Ok9xo8+iJv/fxovE=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1opbDY-00137a-EL; Mon, 31 Oct 2022 21:17:08 +0100 Date: Mon, 31 Oct 2022 21:17:08 +0100 From: Andrew Lunn To: Shenwei Wang Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "imx@lists.linux.dev" , kernel test robot Subject: Re: [EXT] Re: [PATCH v2 1/1] net: fec: add initial XDP support Message-ID: References: <20221031162200.1997788-1-shenwei.wang@nxp.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,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 > > > + cbd_base = rxq->bd.base; > > > + if (bpf->prog) > > > + rxq->bd.ring_size = XDP_RX_RING_SIZE; > > > + else > > > + rxq->bd.ring_size = RX_RING_SIZE; > > > + size = dsize * rxq->bd.ring_size; > > > + cbd_base = (struct bufdesc *)(((void *)cbd_base) + size); > > > + rxq->bd.last = (struct bufdesc *)(((void > > > + *)cbd_base) - dsize); > > > > This does not look safe. netif_tx_disable(dev) will stop new transmissions, but > > the hardware can be busy receiving, DMAing frames, using the descriptors, etc. > > Modifying rxq->bd.last in particular seems risky. I think you need to disable the > > receiver, wait for it to indicate it really has stopped, and only then make these > > modifications. > > > > Sounds reasonable. How about moving the codes of updating ring size to the place > right after the enet reset inside the fec_restart? This should clear those risky corner > cases. That sounds reasonable. But please add some comments. The driver has RX_RING_SIZE elements allocated, but you are only using a subset. This needs to be clear for when somebody implements the ethtool --rings option. And i still think it would be good to implement that code. As your numbers show, the ring size does affect performance, and it is hard to know if your hard coded XDP_RX_RING_SIZE is the right value, depending on what the eBPF program is doing. If the ethtool option was provided, it allows users to benchmark different ring sizes for their workload. Andrew