From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.bufferbloat.net (Postfix) with ESMTPS id BFABF3B2A4 for ; Fri, 25 Feb 2022 07:25:39 -0500 (EST) Received: by mail-ej1-x635.google.com with SMTP id p15so10535145ejc.7 for ; Fri, 25 Feb 2022 04:25:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-transfer-encoding; bh=qQUhpTjkUiJStoSzDGsQ+cf0yHhkDcQQnGgCQypN9P8=; b=ZfnEuJKkVvOeorOqa1Yen42f1SawpHzW1Bb0uPmmHQbGfKh/NLll6pVlpGOAuhQer4 qtRRdUCApUB4/fc1KZXhwuMMImz4PFRkW6G+pfMLjkgXNxIgNscxZjabMWcNXVDWzlAw u0MKBCFgPk1dgob2tQlzOxOmWA780zGXlBvB2jQJDumwWnGwF8c7IW4744RJUV9Rot+w bgU5IaTZM/DzlNeotaN/7ODHYPYeV5ukyxhOGygXP+YVW0jtKGi/8YcXaNvLCy/Vh4zz DOFzgYdyFoeFvLsx/DGiWZbw7iMpBH25uW1xWqoMN1XsWKCGGZ36OD79zo0JDrK94Oy/ D7hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-transfer-encoding; bh=qQUhpTjkUiJStoSzDGsQ+cf0yHhkDcQQnGgCQypN9P8=; b=g7EPax0mduU8YbuBv2d3BavZ1/x+MAIEeUkCX+Z3/mqVu8E6qTcISOBQknMABX2/lI DuOkKy0bQMpUswqODNir4wT3IBfyvOVeqXa3FWjWTnMY4j9mSMl0xrhnN/oMAP/3XQat 6Gw18zmXgy1Rr3wwYSMeccuiMUdf7ngv1HfNuKIdeUQ2G27u9UgCfNUInMFet+Vvs/ab vlTDRZYhOImd2tGsQZXGRwN5vXCuHTLNyv4wpCrTu0kBKTmspPXxa2/r+Svl5PvvUWpF 1VenbaEHR5hRim+sThs3bw1KsfoKTifDttlozlrLHt5iINxTeecX0rVCo/GGwKNc+z4o Kd1w== X-Gm-Message-State: AOAM530WJe4+KCzPSA6r2Miu9uFbUuc9rP0BGVPAbw0PM6h9pdQ6VaZi gT7jVykpNtrVwyHiT0260zr5MyiSZ+JMkcwlfiKdSSYS X-Google-Smtp-Source: ABdhPJzlFIW74RB4mZe1GNltzT5D0mLn0Up+JKKllJyQ+Ge2T0eo86iHiuvENdKol62fN7+wYbFqhCU/H012EzFrc00= X-Received: by 2002:a17:907:205a:b0:6ce:e4c5:4809 with SMTP id pg26-20020a170907205a00b006cee4c54809mr6287529ejb.116.1645791938321; Fri, 25 Feb 2022 04:25:38 -0800 (PST) MIME-Version: 1.0 References: <20220224103852.311369-1-baymaxhuang@gmail.com> In-Reply-To: <20220224103852.311369-1-baymaxhuang@gmail.com> From: Dave Taht Date: Fri, 25 Feb 2022 07:25:24 -0500 Message-ID: To: cerowrt-devel Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: [Cerowrt-devel] Fwd: [PATCH] tun: support NAPI to accelerate packet processing X-BeenThere: cerowrt-devel@lists.bufferbloat.net X-Mailman-Version: 2.1.20 Precedence: list List-Id: Development issues regarding the cerowrt test router project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Feb 2022 12:25:39 -0000 really remarkable potential improvement in userspace vpn traffic ---------- Forwarded message --------- From: Harold Huang Date: Thu, Feb 24, 2022 at 6:37 AM Subject: [PATCH] tun: support NAPI to accelerate packet processing To: Cc: , Harold Huang , David S. Miller , Jakub Kicinski , open list In tun, NAPI is supported and we can also use NAPI in the path of batched XDP buffs to accelerate packet processing. What is more, after we use NPAI, GRO is also supported. The iperf shows that the throughput could be improved from 4.5Gbsp to 9.2Gbps per stream. Reported-at: https://lore.kernel.org/netdev/CAHJXk3Y9_Fh04sakMMbcAkef7kOTEc= -kf84Ne3DtWD7EAp13cg@mail.gmail.com/T/#t Signed-off-by: Harold Huang --- drivers/net/tun.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index fed85447701a..4e1cea659b42 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -2388,6 +2388,7 @@ static int tun_xdp_one(struct tun_struct *tun, struct virtio_net_hdr *gso =3D &hdr->gso; struct bpf_prog *xdp_prog; struct sk_buff *skb =3D NULL; + struct sk_buff_head *queue; u32 rxhash =3D 0, act; int buflen =3D hdr->buflen; int err =3D 0; @@ -2464,7 +2465,14 @@ static int tun_xdp_one(struct tun_struct *tun, !tfile->detached) rxhash =3D __skb_get_hash_symmetric(skb); - netif_receive_skb(skb); + if (tfile->napi_enabled) { + queue =3D &tfile->sk.sk_write_queue; + spin_lock(&queue->lock); + __skb_queue_tail(queue, skb); + spin_unlock(&queue->lock); + } else { + netif_receive_skb(skb); + } /* No need to disable preemption here since this function is * always called with bh disabled @@ -2507,6 +2515,9 @@ static int tun_sendmsg(struct socket *sock, struct msghdr *m, size_t total_len) if (flush) xdp_do_flush(); + if (tfile->napi_enabled) + napi_schedule(&tfile->napi); + rcu_read_unlock(); local_bh_enable(); -- 2.27.0 --=20 I tried to build a better future, a few times: https://wayforward.archive.org/?site=3Dhttps%3A%2F%2Fwww.icei.org Dave T=C3=A4ht CEO, TekLibre, LLC