From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BFA8AC433B4 for ; Fri, 9 Apr 2021 14:58:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A812600D1 for ; Fri, 9 Apr 2021 14:58:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234000AbhDIO6Q (ORCPT ); Fri, 9 Apr 2021 10:58:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55255 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233541AbhDIO6P (ORCPT ); Fri, 9 Apr 2021 10:58:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617980281; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=5lM8BXbAB1LpWiYvO+Oh6jqO0FSF6aQebUJSfZqsk2w=; b=I0TmGagACttPrM5snH/F5FFXfMYtVxB5pj2R4dZmbITYeQb2BQOVo3X3z1nIL+5y4JK0Nr JVcEndK1fb6Wgj83qIsVvbQZK125A4Cc+EVCI0kbPNP0/uTUWVN+q8dV/RD0ErCyd3kTpt vqFZyDectiTZAH+m9x7iJvE1Y1mUy3U= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-424-k9QPskJtMaqm7hVKtuhE3A-1; Fri, 09 Apr 2021 10:57:50 -0400 X-MC-Unique: k9QPskJtMaqm7hVKtuhE3A-1 Received: by mail-ej1-f70.google.com with SMTP id a11so2053433ejg.7 for ; Fri, 09 Apr 2021 07:57:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=5lM8BXbAB1LpWiYvO+Oh6jqO0FSF6aQebUJSfZqsk2w=; b=qG4EWNlNArJkWPQsxRmMwVWZgiyajFH+NLbyISBiDZdoJrP0qGaDU1Hac+2fNJ+/px AvBhZfNWF57X5ZzEti1BM/LRJAL5eSx69k7yXnqut/4u7pMY0LYg4xkcEECbT5czKKaH mnmoPg+rIvcFBfePbWToxY12tRpnW7/3SjM66oufiPMngPGaMDSVEHh4zYqTr3Tx+dg0 BCSJSc2ebAmZNxdPBTb8vH8RP0MyuyLzAkCNHE7waXgQ8/wqB9moQr3doM0EO9YHi3sh mInQWOvBuYLcWjcRnG0R1fB0l4l/Px2c5KmGxe2weKQC5F4Z6laEZG+cRnbVnHfaq3n+ bo2w== X-Gm-Message-State: AOAM530/B7SKgHdU0YHf6Py+T3g7eH8ZV1ZCJsoRLbk2osZqxqp1jp5F uan2rGezqreJiCz8Ma6o1mpbiq3JwZCn66dvYQQaor9thyPLfqsgae8PLkH05jegghZhFPRQn6U yBgBvfeYpWwZf5h79 X-Received: by 2002:aa7:c9c8:: with SMTP id i8mr17664021edt.193.1617980269385; Fri, 09 Apr 2021 07:57:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPtXF1LEzt286HlIzaz3Xy5xGUjW/PsMrKRaD0MkLFFVNpqLClJjkDG2qa3d1LRkaGFdii1g== X-Received: by 2002:aa7:c9c8:: with SMTP id i8mr17664013edt.193.1617980269213; Fri, 09 Apr 2021 07:57:49 -0700 (PDT) Received: from alrua-x1.borgediget.toke.dk ([45.145.92.2]) by smtp.gmail.com with ESMTPSA id eo22sm1350756ejc.0.2021.04.09.07.57.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Apr 2021 07:57:48 -0700 (PDT) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id C503A1802F9; Fri, 9 Apr 2021 16:57:47 +0200 (CEST) From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= To: Paolo Abeni , netdev@vger.kernel.org Cc: "David S. Miller" , Jakub Kicinski , Toshiaki Makita , Lorenzo Bianconi Subject: Re: [PATCH net-next 3/4] veth: refine napi usage In-Reply-To: References: X-Clacks-Overhead: GNU Terry Pratchett Date: Fri, 09 Apr 2021 16:57:47 +0200 Message-ID: <87y2drtsic.fsf@toke.dk> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Paolo Abeni writes: > After the previous patch, when enabling GRO, locally generated > TCP traffic experiences some measurable overhead, as it traverses > the GRO engine without any chance of aggregation. > > This change refine the NAPI receive path admission test, to avoid > unnecessary GRO overhead in most scenarios, when GRO is enabled > on a veth peer. > > Only skbs that are eligible for aggregation enter the GRO layer, > the others will go through the traditional receive path. > > Signed-off-by: Paolo Abeni > --- > drivers/net/veth.c | 23 ++++++++++++++++++++++- > 1 file changed, 22 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/veth.c b/drivers/net/veth.c > index ca44e82d1edeb..85f90f33d437e 100644 > --- a/drivers/net/veth.c > +++ b/drivers/net/veth.c > @@ -282,6 +282,25 @@ static int veth_forward_skb(struct net_device *dev, struct sk_buff *skb, > netif_rx(skb); > } > > +/* return true if the specified skb has chances of GRO aggregation > + * Don't strive for accuracy, but try to avoid GRO overhead in the most > + * common scenarios. > + * When XDP is enabled, all traffic is considered eligible, as the xmit > + * device has TSO off. > + * When TSO is enabled on the xmit device, we are likely interested only > + * in UDP aggregation, explicitly check for that if the skb is suspected > + * - the sock_wfree destructor is used by UDP, ICMP and XDP sockets - > + * to belong to locally generated UDP traffic. > + */ > +static bool veth_skb_is_eligible_for_gro(const struct net_device *dev, > + const struct net_device *rcv, > + const struct sk_buff *skb) > +{ > + return !(dev->features & NETIF_F_ALL_TSO) || > + (skb->destructor == sock_wfree && > + rcv->features & (NETIF_F_GRO_FRAGLIST | NETIF_F_GRO_UDP_FWD)); > +} > + > static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev) > { > struct veth_priv *rcv_priv, *priv = netdev_priv(dev); > @@ -305,8 +324,10 @@ static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev) > > /* The napi pointer is available when an XDP program is > * attached or when GRO is enabled > + * Don't bother with napi/GRO if the skb can't be aggregated > */ > - use_napi = rcu_access_pointer(rq->napi); > + use_napi = rcu_access_pointer(rq->napi) && > + veth_skb_is_eligible_for_gro(dev, rcv, skb); > skb_record_rx_queue(skb, rxq); > } You just changed the 'xdp_rcv' check to this use_napi, and now you're conditioning it on GRO eligibility, so doesn't this break XDP if that was the reason NAPI was turned on in the first place? -Toke