From patchwork Tue Aug 8 03:19:10 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: 132534 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2212193vqr; Tue, 8 Aug 2023 08:48:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFfRHEIxKAPDHJhRfVk9JFmaJhn2HzdwEytc7dYXeexyc0JorRGpmBV+dJGtqSj+ajIKtDK X-Received: by 2002:a17:902:b193:b0:1b3:fb76:215b with SMTP id s19-20020a170902b19300b001b3fb76215bmr52526plr.48.1691509723593; Tue, 08 Aug 2023 08:48:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691509723; cv=none; d=google.com; s=arc-20160816; b=lm9/ru69TV2HpoBX8e4ywOY0yF0gELPAP3Rjr9r4Pmnu4kOWsPtOrlIIc7/QUyuJ34 8Q/zBq8rXMBGlN3pAh4XyRjYAxhhNIW42phq/5APr7LKkOMkpHlLMqfhthuSUS/c45G+ H33uxgkWXacn1xugTWVM97UgbkyhWOTKr82OJHJqdJATOPIIeOqpXLty2b8tdxfq1BPL OeQFsoqwGMQ2Z+wXQWgUV0tAcXIKHXXNsM7ZRitmn52XwI0GtBN+DpPUfF0fFgLPnsqc 3aqOxqtzh7kM5v2Ps2VoLK0KGrsUo9NU4n3VVZH8fM0g/+MSA9geiSnKNOCJIyu5fszX zfuQ== 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=ICV3oSZrEepyfkdFh294C2oc/HDgt3q4tnvL6u1XOSo=; fh=d52JIWYEkePcj18BLr16Py79ZIzTYL7SzTuYhl8wvHo=; b=KF3qNAZPoNLWoCnOHfEpox9rczZYFZlls2Fb9RL0Tt2+VK+3HsXobg4AUU1d/9SJUO obqmWLxN89/Vvx6QrR+F/6YQbVg7XdLAzBvCYIJt40YOcAug4bafFVfvfbzQlbHBmsMB 3fNthcjVuYmOxpRn6Ria6yMjjibycEX6cxWeU8Zo5UQ+yUU9S/1hFuLfe3C7H7+k9mSe G5gwT4FMh4VeLg7n9/VDFICqHj4DK0NFiE3Wf8Ofoqzn2lVJKOauCZtukH9Wjq7JM7qa OS3spksLU/f96BvXe/yKgmAkol5iYQu1qTs9iu1jM0MKbERuILc6WBL0awKmgS+gcAdn 7UOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=lutZ0A2W; 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 lm7-20020a170903298700b001bba7713547si7687091plb.151.2023.08.08.08.48.30; Tue, 08 Aug 2023 08:48:43 -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=lutZ0A2W; 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 S231428AbjHHDV3 (ORCPT + 99 others); Mon, 7 Aug 2023 23:21:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231370AbjHHDVG (ORCPT ); Mon, 7 Aug 2023 23:21:06 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 047281729 for ; Mon, 7 Aug 2023 20:21:05 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-53482b44007so3016567a12.2 for ; Mon, 07 Aug 2023 20:21:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1691464864; x=1692069664; 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=ICV3oSZrEepyfkdFh294C2oc/HDgt3q4tnvL6u1XOSo=; b=lutZ0A2WljE0PHMq69IriO2rZ3mTGdwt4yVVFZOwx7KaXGHtsYthZEnorDptzuoR9Z 3bTfCPeVS8fpSvafHRcMLxrDNgnA2loby72Wgu9cfloNQRxmHCbPK3vKdpTZfK8jUlmF 7p0hYB/3nnDjWEtIceXVAL8kl4qqmuLDT5CgZQQRARE9KRnFvExGQzyuneXXfHttAgdL zsKB0Oh+uxe0BPwxqJaQMOPzn/nTgtz9LdZMlVg0RTJdKhq0bRAT7rJsnC7zn+ynGm5n Lymc0VkgXf3C5i+q0ZNqVquZH5V2gVRVSKb9Yn7GpEFzEVlv3u68qZNnVPavuo/G/XFK RNwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691464864; x=1692069664; 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=ICV3oSZrEepyfkdFh294C2oc/HDgt3q4tnvL6u1XOSo=; b=OqbWEPWagk7j7me7n4HvNtO0vOTtZbHqulCu8PGlR4gJ7tWy+doWvPAMKrLIHwWde8 wK8gnkDxy6c9ZBoKlWPV6DltHAG4aC6BHNuQuNHqBFHY03tbaJn8zwuLz3ekXQNznojE 25/IaMNvpv4junlTnmmZ0TTA1J+tu7lj4MlaWY17j8PJhCnchdcYRVIjfTryk8zw3U/b pW2RKqU2KkavmrfXsG0sg6aH5eRAPlzPUdZoCXmxVHa6KbuhLZpA9bsRNvXj1YcWd39h IaGqmv8l5RbTtRMHQPIUR8wrzQ7kzC9albHhPUafURtLwkFsxUPmduhkUaXoi7KdeImJ fr5Q== X-Gm-Message-State: AOJu0YwYrKRa849FSqDMigPx3vEG013aFqpbfwX6McIQ8h8sovGNQQMQ A/wDReLqryiH2Z2c3968wD4uAg== X-Received: by 2002:a05:6a21:2713:b0:133:2974:d31a with SMTP id rm19-20020a056a21271300b001332974d31amr8482956pzb.17.1691464864453; Mon, 07 Aug 2023 20:21:04 -0700 (PDT) Received: from C02FG34NMD6R.bytedance.net ([2408:8656:30f8:e020::b]) by smtp.gmail.com with ESMTPSA id 13-20020a170902c10d00b001b896686c78sm7675800pli.66.2023.08.07.20.20.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 20:21:04 -0700 (PDT) From: Albert Huang To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: Albert Huang , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , Pavel Begunkov , Yunsheng Lin , Kees Cook , Richard Gobert , "open list:NETWORKING DRIVERS" , open list , "open list:XDP (eXpress Data Path)" Subject: [RFC v3 Optimizing veth xsk performance 6/9] veth: add ndo_xsk_wakeup callback for veth Date: Tue, 8 Aug 2023 11:19:10 +0800 Message-Id: <20230808031913.46965-7-huangjie.albert@bytedance.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20230808031913.46965-1-huangjie.albert@bytedance.com> References: <20230808031913.46965-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_PASS,URIBL_BLOCKED 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: 1773676499931360485 X-GMAIL-MSGID: 1773676499931360485 add ndo_xsk_wakeup callback for veth, this is used to wakeup napi tx. Signed-off-by: Albert Huang --- drivers/net/veth.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/net/veth.c b/drivers/net/veth.c index 28b891dd8dc9..ac78d6a87416 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -1805,6 +1805,44 @@ static void veth_set_rx_headroom(struct net_device *dev, int new_hr) rcu_read_unlock(); } +static void veth_xsk_remote_trigger_napi(void *info) +{ + struct veth_sq *sq = info; + + napi_schedule(&sq->xdp_napi); +} + +static int veth_xsk_wakeup(struct net_device *dev, u32 qid, u32 flag) +{ + struct veth_priv *priv; + struct veth_sq *sq; + u32 last_cpu, cur_cpu; + + if (!netif_running(dev)) + return -ENETDOWN; + + if (qid >= dev->real_num_rx_queues) + return -EINVAL; + + priv = netdev_priv(dev); + sq = &priv->sq[qid]; + + if (napi_if_scheduled_mark_missed(&sq->xdp_napi)) + return 0; + + last_cpu = sq->xsk.last_cpu; + cur_cpu = get_cpu(); + + /* raise a napi */ + if (last_cpu == cur_cpu) + napi_schedule(&sq->xdp_napi); + else + smp_call_function_single(last_cpu, veth_xsk_remote_trigger_napi, sq, true); + + put_cpu(); + return 0; +} + static int veth_xdp_set(struct net_device *dev, struct bpf_prog *prog, struct netlink_ext_ack *extack) { @@ -2019,6 +2057,7 @@ static const struct net_device_ops veth_netdev_ops = { .ndo_set_rx_headroom = veth_set_rx_headroom, .ndo_bpf = veth_xdp, .ndo_xdp_xmit = veth_ndo_xdp_xmit, + .ndo_xsk_wakeup = veth_xsk_wakeup, .ndo_get_peer_dev = veth_peer_dev, };