Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp3457578rwo; Fri, 4 Aug 2023 05:23:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IElvEIbuaZKyFTAM+7ZUTs7glNV1gEuNvFphSGzYXDdZRy46OpuTRmLhnvJI0odciyQErZY X-Received: by 2002:a17:902:e80a:b0:1b8:7fd7:e022 with SMTP id u10-20020a170902e80a00b001b87fd7e022mr1190973plg.28.1691151798601; Fri, 04 Aug 2023 05:23:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691151798; cv=none; d=google.com; s=arc-20160816; b=qugftyMVqCZ4NV4BtdWlWSjmgG3r82uhF3oiAT0jcjTEbL9PaBiD66HRemM9sQGuOB m1YlHkyeTz038c88hUS0aBonudsQPxI+qMqL8DtqstZszu1cEhxEfWV753J26FaRaB4F nz3Q22Fm4uf6+A4VJwrX0eiohlQBJ0AeVnTwFQCOAiY3jVu9sG6l4nuoroLWhwiAriDF bnLtxcR/rFmvbDQKkZabe8ISeNON85oMLykgVqeNA1Iwulqye0yPtuwcd4T0FviLlSHC sgvfQKMX6DbLfbEDyczo7QjqyBAt6uQEzD0ZLrzyOA1ro3nsupd2lX8nPqGpBbJzrHij i9ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=3lh3Hctj95NHoFHXDNQqXs317LqiT3KEHjD0k7M5U8k=; fh=/n21StzDB8SsjTPCNBwZ9wrHNEce1nVbhCMe1bzHzKk=; b=vf/++UkV3kZgaxFnkeq3eJKTOqcV6V3iK+tBv/oMNxvrM8Vlsb/mv/urlH0AgJZQyA PfzSkVNfdViRO8dDrw50Q9ol/KhQgtCyFlzLJfbtj1ysmLUGyLVNeVAafSDZ9I89uI0Q SgoN6+muEUMJ3QEdhK1e1YLeFO+AofusQ5SYlvWFXn9as2M7xfRgiQmtVOaX2nq0i5U4 CpTd1/SiFr02cVwX5OfvU3hbnodFiWZwWBAoc+RMmCvM6+NkvYMgSK4BlbVQbx409hDg 6BQ4Gl6Ff4VPViyvLwI94A9xc95xkU4dHazfNf/wqLBc+ER+Gm6UxsfkfP1CFThE+Iej ER4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GFx83acK; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f16-20020a170902ce9000b001b8a4954be1si1812440plg.595.2023.08.04.05.23.05; Fri, 04 Aug 2023 05:23:18 -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=@kernel.org header.s=k20201202 header.b=GFx83acK; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229818AbjHDMJ5 (ORCPT + 99 others); Fri, 4 Aug 2023 08:09:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbjHDMJ4 (ORCPT ); Fri, 4 Aug 2023 08:09:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AB7C46BB for ; Fri, 4 Aug 2023 05:09:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C776961FBA for ; Fri, 4 Aug 2023 12:09:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 172B6C433C7; Fri, 4 Aug 2023 12:09:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691150994; bh=axWaUXP/2OhWrOi66tqNCt4hqCOmMutZJ5QBsrM8Zp0=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=GFx83acKyAhwxLNwQ2QD1TqpWgk816I2NQ5ZNVBe1IX5m/P6LIjSTys8bU9fS0xq9 xIR7kbCTFnfNZ76KhKuJ1SmZ1fy12ta3i7CqbrhT5rBEYiBeSB1YunwKmzfRuOHXsx cTXRbR3N1SEgQAzDI8CFNKi0OSiqKeASEmZBOApsuhg90g6fQ0Q8MzYjf/v8/6pVPY oQ7Ep6Svy3onB0co9lm2YpfOAlbfOqU6B+JkeZeJqocYFdS2PSd1xmFzhC7keXIyP6 DCWLKRfzWPKSuuD5NYKD9oJD6ZYAH2FmDflVpQEe1vcFuNlXI3HRVhg34Q0zfp2p7M q2k1Bqtr+kfhw== Message-ID: <3a11f1e2-ee5d-676f-2666-0cee8bcbed6b@kernel.org> Date: Fri, 4 Aug 2023 14:09:49 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH V3 net-next] net: fec: add XDP_TX feature support Content-Language: en-US To: Wei Fang , Jesper Dangaard Brouer Cc: "brouer@redhat.com" , dl-linux-imx , "linux-kernel@vger.kernel.org" , "bpf@vger.kernel.org" , Andrew Lunn , "davem@davemloft.net" , "edumazet@google.com" , "kuba@kernel.org" , "pabeni@redhat.com" , Shenwei Wang , Clark Wang , "ast@kernel.org" , "daniel@iogearbox.net" , "john.fastabend@gmail.com" , "netdev@vger.kernel.org" References: <20230731060025.3117343-1-wei.fang@nxp.com> <3d0a8536-6a22-22e5-41c0-98c13dd7b802@redhat.com> From: Jesper Dangaard Brouer In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, 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 On 02/08/2023 14.33, Wei Fang wrote: >>> + struct xdp_frame *xdpf = xdp_convert_buff_to_frame(xdp); >> XDP_TX can avoid this conversion to xdp_frame. >> It would requires some refactor of fec_enet_txq_xmit_frame(). >> > Yes, but I'm not intend to change it, using the existing interface is enough. > >>> + struct fec_enet_private *fep = netdev_priv(ndev); >>> + struct fec_enet_priv_tx_q *txq; >>> + int cpu = smp_processor_id(); >>> + struct netdev_queue *nq; >>> + int queue, ret; >>> + >>> + queue = fec_enet_xdp_get_tx_queue(fep, cpu); >>> + txq = fep->tx_queue[queue]; Notice how TXQ gets selected based on CPU. Thus it will be the same for all the frames. >>> + nq = netdev_get_tx_queue(fep->netdev, queue); >>> + >>> + __netif_tx_lock(nq, cpu); >> >> It is sad that XDP_TX takes a lock for each frame. >> > Yes, but the XDP path share the queue with the kernel network stack, so > we need a lock here, unless there is a dedicated queue for XDP path. Do > you have a better solution? > Yes, the solution would be to keep a stack local (or per-CPU) queue for all the XDP_TX frames, and send them at the xdp_do_flush_map() call site. This is basically what happens with xdp_do_redirect() in cpumap.c and devmap.c code, that have a per-CPU bulk queue and sends a bulk of packets into fec_enet_xdp_xmit / ndo_xdp_xmit. I understand if you don't want to add the complexity to the driver. And I guess, it should be a followup patch to make sure this actually improves performance. --Jesper