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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1212C61DA4 for ; Fri, 3 Feb 2023 08:34:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230140AbjBCIe6 (ORCPT ); Fri, 3 Feb 2023 03:34:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232377AbjBCIen (ORCPT ); Fri, 3 Feb 2023 03:34:43 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DC2F712C6 for ; Fri, 3 Feb 2023 00:33:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675413231; 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=c9gia5gCXojDKJbnjBecgsqKUe4A6lVBjKVa+Q7BTrU=; b=AnBshBWaENwvqAs1H1A/JCtAHe5DsiYSEsS/kZTCdKpogyTXculHtdSfGBdECRa3djetk7 3pNZiKZ72kbWuft4VRGOvmivQrb/haLaDGyJp6JHG0NWjHTnuGQZe9T/yfXDpxMbTQvTFG ylulVi7VvO/an9DnV3quoiV9omm2Ey0= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-17-UZ6vgAkXOMehGiSb0WhSxg-1; Fri, 03 Feb 2023 03:33:48 -0500 X-MC-Unique: UZ6vgAkXOMehGiSb0WhSxg-1 Received: by mail-wm1-f72.google.com with SMTP id j20-20020a05600c1c1400b003dc5dd44c0cso2281034wms.8 for ; Fri, 03 Feb 2023 00:33:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=c9gia5gCXojDKJbnjBecgsqKUe4A6lVBjKVa+Q7BTrU=; b=5LMSgYukIQUPvhUKOHZpEdh9RKmYouDelD3V4Xo//q2LNuerfqWlG7nyP4nfLh9r71 bCk0aPEdL+rNRkTmi3Qc/UX8Qx/M1WGIgS75TUalCqA4B2Y/GVizegmAHVo52pYo+s6r LaNhMmJfMDAQ+p41p07PJ9G42/0V342z3dRsen7m+8kknY/w2b27h6j2+JGpUu50N1NM NqQ0ffolIUlRTz1B8s3tHPbDnhBPolX5+M/qaZKfTKDiDbQtrlxfqVjHqXhj4r6pqooA uyaAuXRkFzs72PWX02gcOz7Ci6ShLcKfyPpKAkObxbTSMj1cSSuPeWDu/Jx/DR5mKBHQ MwWA== X-Gm-Message-State: AO0yUKW3JD/7YT/LKdmd7PZu9LD7kix62DUpTxtgmReKOu+UuS9bhYfm tkgnOFF6ev6jf3cmfQBG+ZmyR8KId9ADQngVX+VD3k9M+4hFRMhoofyXReKAt7xfbSAN4A/mt67 Z9sc9HJxJGuOO X-Received: by 2002:a05:600c:1d03:b0:3dd:1bcc:eb17 with SMTP id l3-20020a05600c1d0300b003dd1bcceb17mr8913702wms.28.1675413226957; Fri, 03 Feb 2023 00:33:46 -0800 (PST) X-Google-Smtp-Source: AK7set+Y8WwnwZ3TGibkgw7+NTRwE/wRyUdxNN+qG3QQe1IWY+jcAry8oCig/t9FCfmiWTBrHfVg6Q== X-Received: by 2002:a05:600c:1d03:b0:3dd:1bcc:eb17 with SMTP id l3-20020a05600c1d0300b003dd1bcceb17mr8913678wms.28.1675413226764; Fri, 03 Feb 2023 00:33:46 -0800 (PST) Received: from redhat.com ([2.52.156.122]) by smtp.gmail.com with ESMTPSA id m13-20020a05600c3b0d00b003dc51c48f0bsm7879692wms.19.2023.02.03.00.33.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 00:33:46 -0800 (PST) Date: Fri, 3 Feb 2023 03:33:41 -0500 From: "Michael S. Tsirkin" To: Xuan Zhuo Cc: netdev@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jason Wang , =?iso-8859-1?Q?Bj=F6rn_T=F6pel?= , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Sebastian Andrzej Siewior , Menglong Dong , Kuniyuki Iwashima , Petr Machata , virtualization@lists.linux-foundation.org, bpf@vger.kernel.org Subject: Re: [PATCH 24/33] virtio_net: xsk: stop disable tx napi Message-ID: <20230203032945-mutt-send-email-mst@kernel.org> References: <20230202110058.130695-1-xuanzhuo@linux.alibaba.com> <20230202110058.130695-25-xuanzhuo@linux.alibaba.com> <20230202122445-mutt-send-email-mst@kernel.org> <1675394682.9569418-1-xuanzhuo@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1675394682.9569418-1-xuanzhuo@linux.alibaba.com> Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Fri, Feb 03, 2023 at 11:24:42AM +0800, Xuan Zhuo wrote: > On Thu, 2 Feb 2023 12:25:59 -0500, "Michael S. Tsirkin" wrote: > > On Thu, Feb 02, 2023 at 07:00:49PM +0800, Xuan Zhuo wrote: > > > Since xsk's TX queue is consumed by TX NAPI, if sq is bound to xsk, then > > > we must stop tx napi from being disabled. > > > > > > Signed-off-by: Xuan Zhuo > > > --- > > > drivers/net/virtio/main.c | 9 ++++++++- > > > 1 file changed, 8 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/net/virtio/main.c b/drivers/net/virtio/main.c > > > index ed79e750bc6c..232cf151abff 100644 > > > --- a/drivers/net/virtio/main.c > > > +++ b/drivers/net/virtio/main.c > > > @@ -2728,8 +2728,15 @@ static int virtnet_set_coalesce(struct net_device *dev, > > > return ret; > > > > > > if (update_napi) { > > > - for (i = 0; i < vi->max_queue_pairs; i++) > > > + for (i = 0; i < vi->max_queue_pairs; i++) { > > > + /* xsk xmit depend on the tx napi. So if xsk is active, > > > > depends. > > > > > + * prevent modifications to tx napi. > > > + */ > > > + if (rtnl_dereference(vi->sq[i].xsk.pool)) > > > + continue; > > > + > > > vi->sq[i].napi.weight = napi_weight; > > > > I don't get it. > > changing napi weight does not work then. > > why is this ok? > > > static void skb_xmit_done(struct virtqueue *vq) > { > struct virtnet_info *vi = vq->vdev->priv; > struct napi_struct *napi = &vi->sq[vq2txq(vq)].napi; > > /* Suppress further interrupts. */ > virtqueue_disable_cb(vq); > > if (napi->weight) > virtqueue_napi_schedule(napi, vq); > else > /* We were probably waiting for more output buffers. */ > netif_wake_subqueue(vi->dev, vq2txq(vq)); > } > > > If the weight is 0, tx napi will not be triggered again. > > Thanks. This needs more thought then. First ignoring what user is requesting is not nice. Second what if napi is first disabled and then xsk enabled? > > > > > > > + } > > > } > > > > > > return ret; > > > -- > > > 2.32.0.3.g01195cf9f > > 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 Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E8E0BC636D6 for ; Fri, 3 Feb 2023 08:33:57 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 66076429C6; Fri, 3 Feb 2023 08:33:56 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 66076429C6 Authentication-Results: smtp4.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Es+CFDeM X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id H_kiXWmtnn4f; Fri, 3 Feb 2023 08:33:54 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 8D4D041D41; Fri, 3 Feb 2023 08:33:53 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 8D4D041D41 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 60497C0032; Fri, 3 Feb 2023 08:33:53 +0000 (UTC) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1D178C002B for ; Fri, 3 Feb 2023 08:33:52 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id D62CF41D41 for ; Fri, 3 Feb 2023 08:33:51 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org D62CF41D41 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2VqzUgBfOBy2 for ; Fri, 3 Feb 2023 08:33:51 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org C273541D21 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id C273541D21 for ; Fri, 3 Feb 2023 08:33:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675413229; 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=c9gia5gCXojDKJbnjBecgsqKUe4A6lVBjKVa+Q7BTrU=; b=Es+CFDeMQrAGZA/KkThcSvNXwe5vpbGJZXeKQxoddvNTcjN5jvOUGNp8SJhJgKjnFnWfy8 FGtRJ7ZUAoKNRI2B6mY2Az+ngvrwpoWNQivK7J2G3kcBsnr4OeDwx7xwCmMkwAm4oq7OWa k1E5WEKIrk9Eat5/XgEpUp486a+lDuA= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-279-6cftP8pBNaSNCf9SmJoAHg-1; Fri, 03 Feb 2023 03:33:48 -0500 X-MC-Unique: 6cftP8pBNaSNCf9SmJoAHg-1 Received: by mail-wm1-f71.google.com with SMTP id o31-20020a05600c511f00b003dc53da325dso4207060wms.8 for ; Fri, 03 Feb 2023 00:33:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=c9gia5gCXojDKJbnjBecgsqKUe4A6lVBjKVa+Q7BTrU=; b=vqTsD2v+an3+VQODJyklSSY/6hm4tR68F0x9EM2IS7cc91wN4k4oKJ1CtLkQGw/9tu rbkCdpliOwDxsjqwTO9/jaftBeZVHZmMVAgqdnb8CdURYpP7SOT0CTUt6yIlY+vUNPE9 QK8HQgS4VzmpxaSTysP2sQOCGp0GSdTjP7wpxEc9sSgAYcpdkhgypHcxhD7dBc77vXLm l+J24n6aVvXL9zlwaHVHTbG7UZtSMlmiwp1nA1PXDo9su4z0vu5O1fwNFthXcxC2ZggP K5m/UbZ6c01nZK+XOwdlQLaoSm6S02+gcy7AxZFfmWpu9JGAL2gb4w1VYzhubnCDH2JE 66lA== X-Gm-Message-State: AO0yUKUSKHNK6Kg3ND7v6Mahb1nUpCVbGu2CKtnEhyPu12sCNJR20AQy EdrPBFs5Eac2cpjDvX3Eu5cbQETpHcFbEiRqS+yFVzcLefaGdVHu45VODW3Mqvx7VKfabw7SHWa 4tImJL7lsoTsKI0O45RTS3kxeJQkRh6ohWIWrzfamNQ== X-Received: by 2002:a05:600c:1d03:b0:3dd:1bcc:eb17 with SMTP id l3-20020a05600c1d0300b003dd1bcceb17mr8913701wms.28.1675413226957; Fri, 03 Feb 2023 00:33:46 -0800 (PST) X-Google-Smtp-Source: AK7set+Y8WwnwZ3TGibkgw7+NTRwE/wRyUdxNN+qG3QQe1IWY+jcAry8oCig/t9FCfmiWTBrHfVg6Q== X-Received: by 2002:a05:600c:1d03:b0:3dd:1bcc:eb17 with SMTP id l3-20020a05600c1d0300b003dd1bcceb17mr8913678wms.28.1675413226764; Fri, 03 Feb 2023 00:33:46 -0800 (PST) Received: from redhat.com ([2.52.156.122]) by smtp.gmail.com with ESMTPSA id m13-20020a05600c3b0d00b003dc51c48f0bsm7879692wms.19.2023.02.03.00.33.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 00:33:46 -0800 (PST) Date: Fri, 3 Feb 2023 03:33:41 -0500 From: "Michael S. Tsirkin" To: Xuan Zhuo Subject: Re: [PATCH 24/33] virtio_net: xsk: stop disable tx napi Message-ID: <20230203032945-mutt-send-email-mst@kernel.org> References: <20230202110058.130695-1-xuanzhuo@linux.alibaba.com> <20230202110058.130695-25-xuanzhuo@linux.alibaba.com> <20230202122445-mutt-send-email-mst@kernel.org> <1675394682.9569418-1-xuanzhuo@linux.alibaba.com> MIME-Version: 1.0 In-Reply-To: <1675394682.9569418-1-xuanzhuo@linux.alibaba.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Cc: Petr Machata , Menglong Dong , Maciej Fijalkowski , Jesper Dangaard Brouer , Daniel Borkmann , netdev@vger.kernel.org, John Fastabend , =?iso-8859-1?Q?Bj=F6rn_T=F6pel?= , Alexei Starovoitov , Eric Dumazet , Kuniyuki Iwashima , Sebastian Andrzej Siewior , Jonathan Lemon , Jakub Kicinski , bpf@vger.kernel.org, Paolo Abeni , virtualization@lists.linux-foundation.org, "David S. Miller" , Magnus Karlsson X-BeenThere: virtualization@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux virtualization List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: virtualization-bounces@lists.linux-foundation.org Sender: "Virtualization" On Fri, Feb 03, 2023 at 11:24:42AM +0800, Xuan Zhuo wrote: > On Thu, 2 Feb 2023 12:25:59 -0500, "Michael S. Tsirkin" wrote: > > On Thu, Feb 02, 2023 at 07:00:49PM +0800, Xuan Zhuo wrote: > > > Since xsk's TX queue is consumed by TX NAPI, if sq is bound to xsk, then > > > we must stop tx napi from being disabled. > > > > > > Signed-off-by: Xuan Zhuo > > > --- > > > drivers/net/virtio/main.c | 9 ++++++++- > > > 1 file changed, 8 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/net/virtio/main.c b/drivers/net/virtio/main.c > > > index ed79e750bc6c..232cf151abff 100644 > > > --- a/drivers/net/virtio/main.c > > > +++ b/drivers/net/virtio/main.c > > > @@ -2728,8 +2728,15 @@ static int virtnet_set_coalesce(struct net_device *dev, > > > return ret; > > > > > > if (update_napi) { > > > - for (i = 0; i < vi->max_queue_pairs; i++) > > > + for (i = 0; i < vi->max_queue_pairs; i++) { > > > + /* xsk xmit depend on the tx napi. So if xsk is active, > > > > depends. > > > > > + * prevent modifications to tx napi. > > > + */ > > > + if (rtnl_dereference(vi->sq[i].xsk.pool)) > > > + continue; > > > + > > > vi->sq[i].napi.weight = napi_weight; > > > > I don't get it. > > changing napi weight does not work then. > > why is this ok? > > > static void skb_xmit_done(struct virtqueue *vq) > { > struct virtnet_info *vi = vq->vdev->priv; > struct napi_struct *napi = &vi->sq[vq2txq(vq)].napi; > > /* Suppress further interrupts. */ > virtqueue_disable_cb(vq); > > if (napi->weight) > virtqueue_napi_schedule(napi, vq); > else > /* We were probably waiting for more output buffers. */ > netif_wake_subqueue(vi->dev, vq2txq(vq)); > } > > > If the weight is 0, tx napi will not be triggered again. > > Thanks. This needs more thought then. First ignoring what user is requesting is not nice. Second what if napi is first disabled and then xsk enabled? > > > > > > > + } > > > } > > > > > > return ret; > > > -- > > > 2.32.0.3.g01195cf9f > > _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization