From patchwork Thu Aug 3 14:04:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?6buE5p2w?= X-Patchwork-Id: 130752 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp1290955vqx; Thu, 3 Aug 2023 10:13:40 -0700 (PDT) X-Google-Smtp-Source: APBJJlEbJVYpOj0aZIxjZIHcfwzYG8YlXTDIW7v1omXMpoYMf3OuF19N7UMl6lxcQX14kko1OFyv X-Received: by 2002:a05:6e02:1d0a:b0:346:77f4:e22d with SMTP id i10-20020a056e021d0a00b0034677f4e22dmr22481475ila.6.1691082819763; Thu, 03 Aug 2023 10:13:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691082819; cv=none; d=google.com; s=arc-20160816; b=UcwJ5D7PiqcdNBlM43J0gMpWZlfjYVE8sWapjWQIfIMAifu4r7RU6QOi3KHncMpM6e BWjughdNPjFHcLsygSbsENbq2vorTvUJvlHlMLluTcnUMAd4FfnJPDHONV26x5SS+zlE fBgSg8QgRo/sHdNdaNBoufpq80fvZxESzbuJql/f/Wa0eAxqiZlXrSiwm2bQqISLb3Mr X0Uoocz+OL39BjQiLOU24aC7LkOEEgvb8184PV2WtFLnXj5adUTn/n/4sJtGSQLP2O2D YxhuawWgFwK0jzc6MzhnQ3sRVXiF1zuYIXmfpTPvgXrX4kFY6TQ4qvoircX+6R2jEwAU zt2Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6Lk7Clg45RdUie/KjcmE3+28g2kd4eecHFcFfnkQv4M=; fh=VmDIXGzgGAt+mNxTrP6+sl6fho9mCQcJ7z//e5pew+A=; b=EMa3leDXIcMVPqV3a9bb1TaQUDhYdmilybUWr0U4Na7fdtpjLWTVjYZDgeW3vPhNRf +4MfzBNrA405VrsBep40NzRDYAPZdqq3wf4zdQxpcmjH8VsSYkwO005bA7yLiir0uMsF BZq6i2Iu1Fhy6SMG+0VEKIMpmVboU5XBpkUl7VGukAvut8coTpXOMhXWWTa7WvPRcmL5 5aY2CVaKlA8uKTwS1ThlL5dcgacOE4Zfe2usImF+MkR2VpiMVrXHt+qI3Pp0QZTg0YIn qKoZW0qGqurAros8aUIFcpn9rZztu7ATE2b9gl8mlasfIAvdr1PbKpjRBgztmBYycvXp yfhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=asWSJ+14; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c8-20020a17090a020800b00263f3c1bb86si303731pjc.158.2023.08.03.10.13.26; Thu, 03 Aug 2023 10:13:39 -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=@bytedance.com header.s=google header.b=asWSJ+14; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235653AbjHCOH0 (ORCPT + 99 others); Thu, 3 Aug 2023 10:07:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235486AbjHCOHB (ORCPT ); Thu, 3 Aug 2023 10:07:01 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD66044AE for ; Thu, 3 Aug 2023 07:05:47 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1bba48b0bd2so6837605ad.3 for ; Thu, 03 Aug 2023 07:05:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1691071545; x=1691676345; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6Lk7Clg45RdUie/KjcmE3+28g2kd4eecHFcFfnkQv4M=; b=asWSJ+14SkxdbE8UXoYgIqvov0BFM79fmeO9euJ1Wv5XRqpkHwShFP6NIXKgvBYS39 KY1uMbrWNQbSjJupGWVrrURhvJ8kmrkqWIv6ZEFPZTTKBxHUS5kikgwuA3z8c5IUvEuo pwfcOp99klDueriStK3YRP+G2A3ta6IrwdNffYwsY1QRFXnKH7rVeHr4XVx9ICdMcs8u TYhqMuVKoTXjFoBzzxm/+LJENMac9MTDwKIUuXzmbia+bqx/NXWlVFRC025fJ/SNhI7G 0sUAAhVdNnFRuvikv0BqaV30V85oEqKXByDdz6upJq+kqp/EKzh4Br8vam8A46D6ers7 qYNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691071545; x=1691676345; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6Lk7Clg45RdUie/KjcmE3+28g2kd4eecHFcFfnkQv4M=; b=fuiISlavSALpClyHugZLb2O5AbiWQGwGCBgdbiJ6+PnRn8H2okPJtHPoEm+aR5A9Qf c1lCW/wJppL/F1Xwm3/xgRkUnKIdc9BU5nQKC5JgmqTVju9oEvzyEgzrHQ7X8YgnRQU/ 0c0P0DRLueQFDvGEfZ+srnxb46KF0eqTmuQ94R2Jr1sq5J1w8rrvjIqB74x/NFadGqOe 88qFeMOJLiULo/wkfoQ6wLDTS+hcaKmVd9vqWeLaBajCcD2058ozPPumgnQmQ/kAbrex poaQjQGN6ijs8BIZvG/HM94t91Xnl8P08uo5gZUAjIykSdSi25e6C+lFRMRcPBPGKGsP DPbg== X-Gm-Message-State: ABy/qLbcZmyBc78xxHLY6bMnkdbCab/U4rVDvjDO8yQ66DlD80SOq1dr 8DjPySrj982jlTZ7q6/DFOMgyg== X-Received: by 2002:a17:903:22c1:b0:1b8:a936:1905 with SMTP id y1-20020a17090322c100b001b8a9361905mr19934085plg.38.1691071545362; Thu, 03 Aug 2023 07:05:45 -0700 (PDT) Received: from C02FG34NMD6R.bytedance.net ([2001:c10:ff04:0:1000::8]) by smtp.gmail.com with ESMTPSA id ji11-20020a170903324b00b001b8a897cd26sm14367485plb.195.2023.08.03.07.05.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 07:05:44 -0700 (PDT) From: "huangjie.albert" To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: "huangjie.albert" , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , Pavel Begunkov , Kees Cook , Richard Gobert , Yunsheng Lin , netdev@vger.kernel.org (open list:NETWORKING DRIVERS), linux-kernel@vger.kernel.org (open list), bpf@vger.kernel.org (open list:XDP (eXpress Data Path)) Subject: [RFC Optimizing veth xsk performance 03/10] veth: add support for send queue Date: Thu, 3 Aug 2023 22:04:29 +0800 Message-Id: <20230803140441.53596-4-huangjie.albert@bytedance.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20230803140441.53596-1-huangjie.albert@bytedance.com> References: <20230803140441.53596-1-huangjie.albert@bytedance.com> MIME-Version: 1.0 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_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: INBOX X-GMAIL-THRID: 1773228859062962037 X-GMAIL-MSGID: 1773228859062962037 in order to support native af_xdp for veth. we need support for send queue for napi tx. the upcoming patch will make use of it. Signed-off-by: huangjie.albert --- drivers/net/veth.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/net/veth.c b/drivers/net/veth.c index c2b431a7a017..63c3ebe4c5d0 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -56,6 +56,11 @@ struct veth_rq_stats { struct u64_stats_sync syncp; }; +struct veth_sq_stats { + struct veth_stats vs; + struct u64_stats_sync syncp; +}; + struct veth_rq { struct napi_struct xdp_napi; struct napi_struct __rcu *napi; /* points to xdp_napi when the latter is initialized */ @@ -69,11 +74,25 @@ struct veth_rq { struct page_pool *page_pool; }; +struct veth_sq { + struct napi_struct xdp_napi; + struct net_device *dev; + struct xdp_mem_info xdp_mem; + struct veth_sq_stats stats; + u32 queue_index; + /* this is for xsk */ + struct { + struct xsk_buff_pool __rcu *pool; + u32 last_cpu; + }xsk; +}; + struct veth_priv { struct net_device __rcu *peer; atomic64_t dropped; struct bpf_prog *_xdp_prog; struct veth_rq *rq; + struct veth_sq *sq; unsigned int requested_headroom; }; @@ -1495,6 +1514,15 @@ static int veth_alloc_queues(struct net_device *dev) u64_stats_init(&priv->rq[i].stats.syncp); } + priv->sq = kcalloc(dev->num_tx_queues, sizeof(*priv->sq), GFP_KERNEL); + if (!priv->sq) + return -ENOMEM; + + for (i = 0; i < dev->num_tx_queues; i++) { + priv->sq[i].dev = dev; + u64_stats_init(&priv->sq[i].stats.syncp); + } + return 0; } @@ -1503,6 +1531,7 @@ static void veth_free_queues(struct net_device *dev) struct veth_priv *priv = netdev_priv(dev); kfree(priv->rq); + kfree(priv->sq); } static int veth_dev_init(struct net_device *dev)