virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <lvivier@redhat.com>
To: Jason Wang <jasowang@redhat.com>, mst@redhat.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	virtualization@lists.linux-foundation.org,
	Stefano Brivio <sbrivio@redhat.com>,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	davem@davemloft.net
Subject: Re: [PATCH net V3] virtio-net: correctly enable callback during start_xmit
Date: Tue, 17 Jan 2023 17:33:55 +0100	[thread overview]
Message-ID: <fefccbdb-9ccd-4057-743a-b23bad4e123d@redhat.com> (raw)
In-Reply-To: <20230117034707.52356-1-jasowang@redhat.com>

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

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

      reply	other threads:[~2023-01-17 16:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-17  3:47 [PATCH net V3] virtio-net: correctly enable callback during start_xmit Jason Wang
2023-01-17 16:33 ` Laurent Vivier [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fefccbdb-9ccd-4057-743a-b23bad4e123d@redhat.com \
    --to=lvivier@redhat.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jasowang@redhat.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sbrivio@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).