From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7AF0281525 for ; Sun, 21 Jun 2026 22:31:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782081096; cv=none; b=Oj/DFYRK+8uT9CCUqLTZgTsXCWRHWOl2IDMG7hmI85QjOuLcTbOZbNdgpD2aGSH/S6JdfVZL99EHGYK0wlYe8xcu5MzolU53FJggCvpV9yNG+UCCUOONqGRU4zQJHtB6fiDsp0YIHC15RneEKH7nTT0EzPrx7TFsn7FoJz8zeeU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782081096; c=relaxed/simple; bh=gak6u5xVNKNtPy9SyiZwr828na6uRPsG4KNYGmdyl5Y=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=AaXFfdsI6QSTM7rTdFwffASyrQOdURarAyZJ8ky14BhEjYmIqOQytnfZ+EuHAsw/+1TzZhVSkwMaCKGqPkUovD7vRCRNYvNOz822aO60zy8WV0RwEGuCHncVbdw1qvELnT8gQpUcStkyNbcD2aoefcGNw6yXY5a/XhoDXULip/A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=dZmcz6vn; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=gdFTCl0h; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dZmcz6vn"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="gdFTCl0h" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782081093; 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=p3hT6b+62UwE6IrhyySHAzdMAZ/HMl2D61nk6Amr5cc=; b=dZmcz6vn7AFKTIraII/bf2sh5mwR0+ZYf5mJETzQJQDfQcd2tb9PpFTfG89RCXdMdIJ+dw ipHaARthpSmm5S7aKQs+FyZQ4uQC7Lz58J5yiMMVYudDQC7ZYWYf7s/TOScsAJk5nY2v89 OlgNmvrTDKvRZUEmS2YpmKUkGIwXBE0= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-630-RQCAbHLaPRabCrN43Dlphw-1; Sun, 21 Jun 2026 18:31:32 -0400 X-MC-Unique: RQCAbHLaPRabCrN43Dlphw-1 X-Mimecast-MFC-AGG-ID: RQCAbHLaPRabCrN43Dlphw_1782081091 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4923d323a83so11768465e9.2 for ; Sun, 21 Jun 2026 15:31:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782081091; x=1782685891; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=p3hT6b+62UwE6IrhyySHAzdMAZ/HMl2D61nk6Amr5cc=; b=gdFTCl0hcul6M4TXsk0hppqQiwfCMludrBLXPkR1ysiA5yeAiElB7PWBxDCyBOR9uo w8lC7Hkh/x8QfXHg+BcauX3/hVVirOfMOVASwj4sZKRLY+Cs//CKTws8qBY4Afa9G94J BtgnZuECmkWN3aS1IGpyILq/BS5j9ZaBt9Hg5NQisJnAfqaFDulCDYNX9Ai1MgM4fsJE kq66C5iGSKfalj5tROXLQm8tcF/IYkPC9UWfyv86eUjOupieIB2dLtFY6KJepUpFcm/Z C3e0ANZ2J8GbxbzereyTLh/k2u1hts5evO0dXQCc/C7obkKtHreGZkWtahQvcSvnvNeF CmAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782081091; x=1782685891; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=p3hT6b+62UwE6IrhyySHAzdMAZ/HMl2D61nk6Amr5cc=; b=ajBfA5zFFq2gaL4O+FS/bbsOkpVGeqeunx/C6V1ZSVTVO8EMWh8gI0t8vz1EWzcQ9C PO6Y/gpQi3/mnucyevsC8dQJvuh1hwk/dJ9WaMkBLnnpE52ajLxYb1JlxplPJww80OMk OxTCRv1zYvuGx2NwOho7tFRDPoAdkwBch4cwWel6+6j2FkUV3NIJMgRaDZKbQHgN7JFo t64fOESFh0Z3hLmQGGG6iFi1IOgLHun32E6KnAvywn6Buct+zodhujIbEQkrXr5Cvu2j oGA5d4Zu9JTdqE1wz/a900ti4dw0f30dIplWQ2FqwtXbqsAlhcbq7MB2Q/N6PiNo6b4N Nc4w== X-Forwarded-Encrypted: i=1; AFNElJ86A5PMNHKyBADgvzR4SWdpZDMhlxwmF9DNg3o2BJ4hJwhOeJbGo8QjSIQB9ZgmrwjQgeJeaEjYaCUhh/4=@vger.kernel.org X-Gm-Message-State: AOJu0YwD8lygyNORxQj/fpeAuzt/rAENxvpNfloBO0tZLw1zhJ5KCjV0 A9C0sjxKLcfjU8j1fwBKkdumww2GbBT75H9jiQS0eKzQxCDYCbPKuGuCazt895SlEaDWnWVQc98 b0G6da6WqJclSeR/Qk7FSvEIi3fNvC2CmuvMvZRecHGCAu91M2K0QTR7SPmUZqqjIiA== X-Gm-Gg: AfdE7cnNP1Asq1v+QqUWRw69rWQSUBGCxdQY+ujJEzWhn2H+mylX7ewx+obGV93uTZI uOo+KuGPAJIm9D6zDlZMuA1uCksk6/neDisKVgP3vbPAl0vouZMgIOhZJjLd7svLvWMHEUlBKjx HWX3ASPeHgcU+6QmdW3FCawI4RqWiWQ83hqKkeZOcBP7JrGZK+aNnSCUA18/NpQV0zy9H8qvnwR d6wKGks3VEFxc6+Fcj2oeKNxdx4FSJuAXdumy5cnTujaMZVfGs0D3WpGNWqFj6gWPDNvkK3amt2 anp4apN392/wS9Rjr34RTXs+5FGkPIUPTClG9h5HVnWmu3RQVK+lAAZMlkZbe25pcbkQe3S7AoY Gb+fwTPZLnF5fjtuIwrPlzB0O8v9NFLsw X-Received: by 2002:a05:600c:3550:b0:490:e913:6564 with SMTP id 5b1f17b1804b1-49249083bf1mr121077995e9.3.1782081091038; Sun, 21 Jun 2026 15:31:31 -0700 (PDT) X-Received: by 2002:a05:600c:3550:b0:490:e913:6564 with SMTP id 5b1f17b1804b1-49249083bf1mr121077755e9.3.1782081090605; Sun, 21 Jun 2026 15:31:30 -0700 (PDT) Received: from redhat.com (IGLD-80-230-85-71.inter.net.il. [80.230.85.71]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-466643f563dsm18451019f8f.3.2026.06.21.15.31.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jun 2026 15:31:30 -0700 (PDT) Date: Sun, 21 Jun 2026 18:31:27 -0400 From: "Michael S. Tsirkin" To: Menglong Dong Cc: xuanzhuo@linux.alibaba.com, eperezma@redhat.com, jasowang@redhat.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, virtualization@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next v3] virtio-net: xsk: support tx wake up Message-ID: <20260621182119-mutt-send-email-mst@kernel.org> References: <20260616115912.513183-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260616115912.513183-1-dongml2@chinatelecom.cn> On Tue, Jun 16, 2026 at 07:59:12PM +0800, Menglong Dong wrote: > For now, XDP_RING_NEED_WAKEUP is not supported properly by the virtio-net > in the tx path for example: we set xsk_set_tx_need_wakeup() in > virtnet_xsk_xmit(), but we didn't call xsk_clear_tx_need_wakeup() > anywhere, which means the user will call send() for every packet. > > We call xsk_set_tx_need_wakeup() after virtnet_xsk_xmit_batch() if sq->vq > is empty, as we can't be wakeup by the skb_xmit_done() in this case. > Otherwise, we will clear the wakeup flag. > > Race condition is considered for tx path. > > Fixes: 89f86675cb03 ("virtio_net: xsk: tx: support xmit xsk buffer") > Signed-off-by: Menglong Dong thanks for the patch! yes something to improve. > --- > v3: > - remove the confusing comment > > v2: > - add the Fixes tag > --- > drivers/net/virtio_net.c | 23 +++++++++++++++++++---- > 1 file changed, 19 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index f4adcfee7a80..6e099edef6e9 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -1440,8 +1440,9 @@ static bool virtnet_xsk_xmit(struct send_queue *sq, struct xsk_buff_pool *pool, > struct virtnet_info *vi = sq->vq->vdev->priv; > struct virtnet_sq_free_stats stats = {}; > struct net_device *dev = vi->dev; > + int sent, vring_size; > + bool need_wakeup; > u64 kicks = 0; > - int sent; > > /* Avoid to wakeup napi meanless, so call __free_old_xmit instead of > * free_old_xmit(). > @@ -1451,8 +1452,25 @@ static bool virtnet_xsk_xmit(struct send_queue *sq, struct xsk_buff_pool *pool, > if (stats.xsk) > xsk_tx_completed(sq->xsk_pool, stats.xsk); > > + vring_size = virtqueue_get_vring_size(sq->vq); > + need_wakeup = xsk_uses_need_wakeup(pool); > + > + if (need_wakeup && vring_size == sq->vq->num_free) > + xsk_set_tx_need_wakeup(pool); > + why are we doing this here? the check after virtnet_xsk_xmit_batch not enough? I vaguely think it's some kind of race we are closing? Pls add a comment to explain. > sent = virtnet_xsk_xmit_batch(sq, pool, budget, &kicks); > > + if (need_wakeup) { > + if (vring_size == sq->vq->num_free) > + /* we can't wake up by ourself, and it should be done > + * by the user. > + */ > + xsk_set_tx_need_wakeup(pool); > + else > + /* we can wake up from skb_xmit_done() */ > + xsk_clear_tx_need_wakeup(pool); But what if we don't have get tx napi so no wakeup in skb_xmit_done? > + } > + > if (!is_xdp_raw_buffer_queue(vi, sq - vi->sq)) > check_sq_full_and_disable(vi, vi->dev, sq); > > @@ -1470,9 +1488,6 @@ static bool virtnet_xsk_xmit(struct send_queue *sq, struct xsk_buff_pool *pool, > u64_stats_add(&sq->stats.xdp_tx, sent); > u64_stats_update_end(&sq->stats.syncp); > > - if (xsk_uses_need_wakeup(pool)) > - xsk_set_tx_need_wakeup(pool); > - > return sent; > } > > -- > 2.54.0