Message ID | 20230117034707.52356-1-jasowang@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1542380wrn; Mon, 16 Jan 2023 19:49:50 -0800 (PST) X-Google-Smtp-Source: AMrXdXu9rcdEK0MdD1Gmv8189+wBmLIYclokqXA0wBhsFCQn97ZBUM+ALDGEp/lcXYOWPLHePLfM X-Received: by 2002:a05:6402:4305:b0:49b:4711:f4b4 with SMTP id m5-20020a056402430500b0049b4711f4b4mr2142569edc.0.1673927390254; Mon, 16 Jan 2023 19:49:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673927390; cv=none; d=google.com; s=arc-20160816; b=VwJSn3D3zwzFgDjWyp+UCp7ME+VX+0wNX00VpE2o/G1naNXdMrx3S82P7YbMKIYp03 NRNAG2ChhoCn0btxbP8MQDI2O66A4oYeiHZDHYKx1/qLbsYM2Yphptv+w4I2rkJalqfx 6Miv3KxINgCkwHwnP+FsxWl0EoybjwdND7/lBfPPTSNVbWwz2QPOFmRDCScxORIEQ1l9 5GQSquKXmfhximpBY8vh1ge3NqI4KwVxKl7/OqhFjF2fsZ4/9X6k2PuLWSB4iY4EohWe 3n6W+RzBCdkTw/4d9QZgAHbrCeDEipjKBgi5uLTu8vkvxjOOhrsB1ZeBaJVJZsNwKv/E Fs6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=90WVwCZHiyeI3L+ZIDFVaep8HNaYc9xGptfBX2i+B+U=; b=n59FnONgUHEsFCyemrP5Z9cY8ZQoBY6d7ALhoFlRe7KCyvT2t8U4nmHUhcdtZ3fLpX NmFr/enRocW154c3pD3aYchG/YhzUpFKw8wQdZyvRmh6JDzwP0YEpLGtOSx/nSH63ZIh ZBiD4ihJhmsQxQfcBpDc7ZYEucWsRE14/78374pWpktvdpjZDIY51B//AzHsL6a5Wkom Dhj7Yo8j95J7MwlPZGB8w72rleUMLcdAEUH1IwDbCD6KSDTV8asERaJPpmWXSlIxGIyv Mg/do7ZWnlEjfOjFaShCZX0qae6utgRSmCRgNJuKVIidXJc+GPX3RTq8XTvKV/S0v0U2 n+bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=U8flMJLa; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b14-20020a0564021f0e00b0049e054594e4si7499842edb.397.2023.01.16.19.49.26; Mon, 16 Jan 2023 19:49:50 -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=U8flMJLa; 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 S235447AbjAQDsS (ORCPT <rfc822;pfffrao@gmail.com> + 99 others); Mon, 16 Jan 2023 22:48:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235451AbjAQDsL (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 16 Jan 2023 22:48:11 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F4DF21A2F for <linux-kernel@vger.kernel.org>; Mon, 16 Jan 2023 19:47:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673927247; 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: content-transfer-encoding:content-transfer-encoding; bh=90WVwCZHiyeI3L+ZIDFVaep8HNaYc9xGptfBX2i+B+U=; b=U8flMJLaM8v04ZBr3YlsiBu7j1/ra/EY2YBOb7A6Roj3SWcA/lG+oR24cnf2UWDTLnRbsk TuV8ekThbXqjEiFEbb1EuV+He9GV6Ox4disz8Y5S5vAfOnczfzEPb/lw5VL/QrM5EaR6r0 Sm9GU0k7D2QjF85nzCkyLs/9Dh8uxwo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-308-Xfu7N253NMu8rBvYODjSUw-1; Mon, 16 Jan 2023 22:47:17 -0500 X-MC-Unique: Xfu7N253NMu8rBvYODjSUw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4452B858F09; Tue, 17 Jan 2023 03:47:17 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-215.pek2.redhat.com [10.72.13.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id 571522166B26; Tue, 17 Jan 2023 03:47:09 +0000 (UTC) From: Jason Wang <jasowang@redhat.com> To: mst@redhat.com, jasowang@redhat.com 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, lvivier@redhat.com Subject: [PATCH net V3] virtio-net: correctly enable callback during start_xmit Date: Tue, 17 Jan 2023 11:47:07 +0800 Message-Id: <20230117034707.52356-1-jasowang@redhat.com> MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755240087480019242?= X-GMAIL-MSGID: =?utf-8?q?1755240087480019242?= |
Series |
[net,V3] virtio-net: correctly enable callback during start_xmit
|
|
Commit Message
Jason Wang
Jan. 17, 2023, 3:47 a.m. UTC
Commit a7766ef18b33("virtio_net: disable cb aggressively") enables
virtqueue callback via the following statement:
do {
if (use_napi)
virtqueue_disable_cb(sq->vq);
free_old_xmit_skbs(sq, false);
} 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.
TO be consistent with the logic that tries to disable cb only for
NAPI, fixing this by trying to enable delayed callback only when NAPI
is enabled when the queue is about to be full.
Fixes: a7766ef18b33 ("virtio_net: disable cb aggressively")
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
The patch is needed for -stable.
Changes since V2:
- try to enabled delayed callback and schedule NAPI instead of try to
poll as when TX NAPI is disabled
Changes since V1:
- enable tx interrupt after we disable TX
---
drivers/net/virtio_net.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
Comments
On 1/17/23 04:47, Jason Wang wrote: > Commit a7766ef18b33("virtio_net: disable cb aggressively") enables > virtqueue callback via the following statement: > > do { > if (use_napi) > virtqueue_disable_cb(sq->vq); > > free_old_xmit_skbs(sq, false); > > } 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. > > TO be consistent with the logic that tries to disable cb only for > NAPI, fixing this by trying to enable delayed callback only when NAPI > is enabled when the queue is about to be full. > > Fixes: a7766ef18b33 ("virtio_net: disable cb aggressively") > Signed-off-by: Jason Wang <jasowang@redhat.com> > --- > The patch is needed for -stable. > Changes since V2: > - try to enabled delayed callback and schedule NAPI instead of try to > poll as when TX NAPI is disabled > Changes since V1: > - enable tx interrupt after we disable TX > --- > drivers/net/virtio_net.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index 7723b2a49d8e..18b3de854aeb 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -1877,8 +1877,10 @@ 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 && > - unlikely(!virtqueue_enable_cb_delayed(sq->vq))) { > + if (use_napi) { > + if (unlikely(!virtqueue_enable_cb_delayed(sq->vq))) > + virtqueue_napi_schedule(&sq->napi, sq->vq); > + } else if (unlikely(!virtqueue_enable_cb_delayed(sq->vq))) { > /* More just got used, free them then recheck. */ > free_old_xmit_skbs(sq, false); > if (sq->vq->num_free >= 2+MAX_SKB_FRAGS) { This fix works fine with my test case (netdev stream + passt) Tested-by: Laurent Vivier <lvivier@redhat.com> Thanks, Laurent
Hello: This patch was applied to netdev/net.git (master) by David S. Miller <davem@davemloft.net>: On Tue, 17 Jan 2023 11:47:07 +0800 you wrote: > Commit a7766ef18b33("virtio_net: disable cb aggressively") enables > virtqueue callback via the following statement: > > do { > if (use_napi) > virtqueue_disable_cb(sq->vq); > > [...] Here is the summary with links: - [net,V3] virtio-net: correctly enable callback during start_xmit https://git.kernel.org/netdev/net/c/d71ebe8114b4 You are awesome, thank you!
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 7723b2a49d8e..18b3de854aeb 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -1877,8 +1877,10 @@ 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 && - unlikely(!virtqueue_enable_cb_delayed(sq->vq))) { + if (use_napi) { + if (unlikely(!virtqueue_enable_cb_delayed(sq->vq))) + virtqueue_napi_schedule(&sq->napi, sq->vq); + } else if (unlikely(!virtqueue_enable_cb_delayed(sq->vq))) { /* More just got used, free them then recheck. */ free_old_xmit_skbs(sq, false); if (sq->vq->num_free >= 2+MAX_SKB_FRAGS) {