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 X-Spam-Level: X-Spam-Status: No, score=-17.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10E8AC433ED for ; Wed, 14 Apr 2021 03:34:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D3C80613BB for ; Wed, 14 Apr 2021 03:34:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233298AbhDNDem (ORCPT ); Tue, 13 Apr 2021 23:34:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24958 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233286AbhDNDem (ORCPT ); Tue, 13 Apr 2021 23:34:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618371261; 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: in-reply-to:in-reply-to:references:references; bh=CLfRM/TFiz4bH/Fuoa5M4fK7KllTM/752Rs7vsgn1IA=; b=WQFRfnzxnlVY6srTeYp2hbUWGMZHsmCeWOb5+G//DtcLQpR3Rw6jQd9FDN6gy8s4wFg1br O3ePpP1qN1uy2rY8uBm50y+Zn+8lwElQ/AXgr5waxTNLZ3KWmr/AOIpYDtZXxT1zV46UMl /63FX6Pk8S8So/2hMI7LMhu3l62oURc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-483-UM4ytrdeP_6nttRSXdU59Q-1; Tue, 13 Apr 2021 23:34:19 -0400 X-MC-Unique: UM4ytrdeP_6nttRSXdU59Q-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1C0A0192AB70; Wed, 14 Apr 2021 03:34:17 +0000 (UTC) Received: from wangxiaodeMacBook-Air.local (ovpn-13-196.pek2.redhat.com [10.72.13.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id 470F5710A6; Wed, 14 Apr 2021 03:34:09 +0000 (UTC) Subject: Re: [PATCH net-next v4 07/10] virtio-net: virtnet_poll_tx support budget check To: Xuan Zhuo , netdev@vger.kernel.org Cc: "Michael S. Tsirkin" , "David S. Miller" , Jakub Kicinski , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Jonathan Lemon , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , virtualization@lists.linux-foundation.org, bpf@vger.kernel.org, "dust . li" References: <20210413031523.73507-1-xuanzhuo@linux.alibaba.com> <20210413031523.73507-8-xuanzhuo@linux.alibaba.com> From: Jason Wang Message-ID: Date: Wed, 14 Apr 2021 11:34:07 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 In-Reply-To: <20210413031523.73507-8-xuanzhuo@linux.alibaba.com> Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org ÔÚ 2021/4/13 ÉÏÎç11:15, Xuan Zhuo дµÀ: > virtnet_poll_tx() check the work done like other network card drivers. > > When work < budget, napi_poll() in dev.c will exit directly. And > virtqueue_napi_complete() will be called to close napi. If closing napi > fails or there is still data to be processed, virtqueue_napi_complete() > will make napi schedule again, and no conflicts with the logic of > napi_poll(). > > When work == budget, virtnet_poll_tx() will return the var 'work', and > the napi_poll() in dev.c will re-add napi to the queue. > > The purpose of this patch is to support xsk xmit in virtio_poll_tx for > subsequent patch. > > Signed-off-by: Xuan Zhuo Acked-by: Jason Wang > --- > 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 f3752b254965..f52a25091322 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -1529,6 +1529,7 @@ static int virtnet_poll_tx(struct napi_struct *napi, int budget) > struct virtnet_info *vi = sq->vq->vdev->priv; > unsigned int index = vq2txq(sq->vq); > struct netdev_queue *txq; > + int work_done = 0; > > if (unlikely(is_xdp_raw_buffer_queue(vi, index))) { > /* We don't need to enable cb for XDP */ > @@ -1541,12 +1542,13 @@ static int virtnet_poll_tx(struct napi_struct *napi, int budget) > free_old_xmit(sq, true); > __netif_tx_unlock(txq); > > - virtqueue_napi_complete(napi, sq->vq, 0); > + if (work_done < budget) > + virtqueue_napi_complete(napi, sq->vq, 0); > > if (sq->vq->num_free >= 2 + MAX_SKB_FRAGS) > netif_tx_wake_queue(txq); > > - return 0; > + return work_done; > } > > static int xmit_skb(struct send_queue *sq, struct sk_buff *skb)