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 91D07C61DA4 for ; Fri, 3 Feb 2023 03:26:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231778AbjBCD0c (ORCPT ); Thu, 2 Feb 2023 22:26:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229881AbjBCD0b (ORCPT ); Thu, 2 Feb 2023 22:26:31 -0500 Received: from out30-100.freemail.mail.aliyun.com (out30-100.freemail.mail.aliyun.com [115.124.30.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D15796602B; Thu, 2 Feb 2023 19:26:29 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R441e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=xuanzhuo@linux.alibaba.com;NM=1;PH=DS;RN=21;SR=0;TI=SMTPD_---0Van8fN4_1675394784; Received: from localhost(mailfrom:xuanzhuo@linux.alibaba.com fp:SMTPD_---0Van8fN4_1675394784) by smtp.aliyun-inc.com; Fri, 03 Feb 2023 11:26:25 +0800 Message-ID: <1675394682.9569418-1-xuanzhuo@linux.alibaba.com> Subject: Re: [PATCH 24/33] virtio_net: xsk: stop disable tx napi Date: Fri, 3 Feb 2023 11:24:42 +0800 From: Xuan Zhuo To: "Michael S. Tsirkin" Cc: netdev@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jason Wang , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , 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 References: <20230202110058.130695-1-xuanzhuo@linux.alibaba.com> <20230202110058.130695-25-xuanzhuo@linux.alibaba.com> <20230202122445-mutt-send-email-mst@kernel.org> In-Reply-To: <20230202122445-mutt-send-email-mst@kernel.org> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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. > > > > + } > > } > > > > return ret; > > -- > > 2.32.0.3.g01195cf9f >