Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp716184rwb; Thu, 15 Dec 2022 01:12:24 -0800 (PST) X-Google-Smtp-Source: AA0mqf51qGwW8iSjOfhpOKDNnD2UWabdnExS0PH4T6/8862lWuBre1MXsKc65gDPCk+e/7FqoDE0 X-Received: by 2002:a17:90a:740e:b0:219:78e:9c3c with SMTP id a14-20020a17090a740e00b00219078e9c3cmr28382482pjg.39.1671095544290; Thu, 15 Dec 2022 01:12:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671095544; cv=none; d=google.com; s=arc-20160816; b=ogWojEdwQPJmH4nVnrT8XU6b31i+6f4ftKW04Uq+UMbW6AUjreoi2SVL88cFYaOA8d Bb0H5m3H6QdssnkpaD3WTl+OTs/5/hPDYAgPE3tHUzoJyo0ZXYf3jfpLVmzZz30ztYra lsz3ztCloKdbFi/OFFfw57jo+hhr5pMgKh/jnPiGZ0QJW5jV8f1hUOyhqXuxub2m63eJ Rvd4y3YDsJmgMmRwpMLgtrbayI+8xEESSIBie74XngaYcnuIZ9s6TN33rrLOfoSD+0q4 kRlS7b5hEkJtgae5k0vO+ZHPjQy05iq/5EN2GIEjbz5r+BJ3t0cOVvPMhxMA4BujOohX cuUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=uwD8NOGTwYs5ieTi5qX1aPfmwnbaS+5RWWUvD/filRE=; b=eFFh2ZLd0pNL0LHtxmPXtnVbbd+E4LWaz/KhGsdfaj6ZcN3Z3ZcLiR624dCDDFoedV OYIutLZlOnLnHydGYZW+6bjP0WCcjiT8H/Tpz+smTzIHXPqHNQSaIwYDD7zWE2C+kTA9 Egw0FeRvYp1L8j+HERH7WDbg0IxW/2s603LNn4xezM5DeNXBEzxjV5iwtAo8mnDqY04J 9SzmnX2LVcxZrTPDaP3Gy8jIwLDh0NE+Om7/DD5sxrPhFgV52LY0wBAQkYRCXUZ2Ug7m hGvLdHnJgdIJeGkNll4ouDi+85yRnnp8SXO9PkedyEyqSRF88dS6vTm5Iv4em5PfuRGz s0Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WKcxcGnD; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 8-20020a631448000000b004790794f259si2316650pgu.739.2022.12.15.01.12.13; Thu, 15 Dec 2022 01:12:24 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=WKcxcGnD; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229620AbiLOJDs (ORCPT + 69 others); Thu, 15 Dec 2022 04:03:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229748AbiLOJDr (ORCPT ); Thu, 15 Dec 2022 04:03:47 -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 4670C43876 for ; Thu, 15 Dec 2022 01:02:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671094977; 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=uwD8NOGTwYs5ieTi5qX1aPfmwnbaS+5RWWUvD/filRE=; b=WKcxcGnDrRGVCmEfnImlEQ8do2JO5IuRT1xQwQuqSEYiu5e5lHk0KRpiSK2XV2P974Db0t 1pRSs8ZWCHaZMHONfZw+G0RtErmZ+zdf/3u7zz0FPUPl/xw9lcVeMuZ/y7KEcLHyk/x6GX yNKRonKdic+HL+2qGIRS3V/RYvAnlvg= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-15-nqZ-jfTCOGCAOOBnnCCnkg-1; Thu, 15 Dec 2022 04:02:56 -0500 X-MC-Unique: nqZ-jfTCOGCAOOBnnCCnkg-1 Received: by mail-wr1-f70.google.com with SMTP id w11-20020adfbacb000000b002418a90da01so503248wrg.16 for ; Thu, 15 Dec 2022 01:02:56 -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=uwD8NOGTwYs5ieTi5qX1aPfmwnbaS+5RWWUvD/filRE=; b=YbdWTqFPhexlEY8jayPpH9yXiYEKkpDB5Bs56ogyHYyLiJadD85Hm6g1nKiyF6rNQ2 GFzOavVk20qDYm7Ui3WyIeo6ysUUS2Oof6+meSuJYQKuikno64K0T+EA7b0wKayl2lN1 QfLuanZ3Mg0wxhGtyhjh23K/SBErJ5nKyVQ9bztyS+RB7+MGY0OG4cdwGAsWBoPVhTym KZXuy8YrqaGwIs1O2S465HXOdfgTsMHVby1i+QJu7jUwYaLHk23oZc+rLJ4rnR3OvYTY YTB64qIiQLi0QJOdoH/ZLZnoOG7wO76mt/ALPoyIxSk4xtDJgJdpM965xcD+bzd0+NpQ 6wyQ== X-Gm-Message-State: ANoB5pnN5wK79fmR4otAcskK8cqlLqy+2KS7ceHCuQuFCBQwFy3ury3h YMysXBoq7yALpUyWPPvUv2QNVlXXM0JAc+9jopvtaV1okAHJOyWjIsRGrAsCHlm7ICAuv+R7YYg Ml3h0rSs1rP+S5g8aE277DKDf X-Received: by 2002:a05:6000:1290:b0:242:733b:af28 with SMTP id f16-20020a056000129000b00242733baf28mr22015732wrx.5.1671094975069; Thu, 15 Dec 2022 01:02:55 -0800 (PST) X-Received: by 2002:a05:6000:1290:b0:242:733b:af28 with SMTP id f16-20020a056000129000b00242733baf28mr22015704wrx.5.1671094974758; Thu, 15 Dec 2022 01:02:54 -0800 (PST) Received: from redhat.com ([2a02:14f:179:247f:e426:6c6e:c44d:93b]) by smtp.gmail.com with ESMTPSA id x12-20020a5d650c000000b002415dd45320sm5151669wru.112.2022.12.15.01.02.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 01:02:54 -0800 (PST) Date: Thu, 15 Dec 2022 04:02:49 -0500 From: "Michael S. Tsirkin" To: Jason Wang Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, xuanzhuo@linux.alibaba.com Subject: Re: [PATCH net V2] virtio-net: correctly enable callback during start_xmit Message-ID: <20221215034740-mutt-send-email-mst@kernel.org> References: <20221215032719.72294-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221215032719.72294-1-jasowang@redhat.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham 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 On Thu, Dec 15, 2022 at 11:27:19AM +0800, Jason Wang wrote: > Commit a7766ef18b33("virtio_net: disable cb aggressively") enables > virtqueue callback via the following statement: > > do { > ...... > } while (use_napi && kick && > unlikely(!virtqueue_enable_cb_delayed(sq->vq))); > > When NAPI is used and kick is false, the callback won't be enabled > here. And when the virtqueue is about to be full, the tx will be > disabled, but we still don't enable tx interrupt which will cause a TX > hang. This could be observed when using pktgen with burst enabled. > > Fixing this by trying to enable tx interrupt after we disable TX when > we're not using napi or kick is false. > > Fixes: a7766ef18b33 ("virtio_net: disable cb aggressively") > Signed-off-by: Jason Wang > --- > The patch is needed for -stable. > Changes since V1: > - enable tx interrupt after we disable tx > --- > drivers/net/virtio_net.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index 86e52454b5b5..dcf3a536d78a 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -1873,7 +1873,7 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev) > */ > if (sq->vq->num_free < 2+MAX_SKB_FRAGS) { > netif_stop_subqueue(dev, qnum); > - if (!use_napi && > + if ((!use_napi || !kick) && > unlikely(!virtqueue_enable_cb_delayed(sq->vq))) { > /* More just got used, free them then recheck. */ > free_old_xmit_skbs(sq, false); This will work but the following lines are: if (sq->vq->num_free >= 2+MAX_SKB_FRAGS) { netif_start_subqueue(dev, qnum); virtqueue_disable_cb(sq->vq); } and I thought we are supposed to keep callbacks enabled with napi? One of the ideas of napi is to free on napi callback, not here immediately. I think it is easier to just do a separate branch here. Along the lines of: if (use_napi) { if (unlikely(!virtqueue_enable_cb_delayed(sq->vq))) virtqueue_napi_schedule(napi, vq); } else { ... old code ... } also reduces chances of regressions on !napi (which is not well tested) and keeps callbacks off while we free skbs. No? > -- > 2.25.1