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 E2F4A78F20 for ; Wed, 24 Dec 2025 10:17:37 +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=1766571459; cv=none; b=T92vhSqQZSDb08c0bOoHn/ATZHwI6AljFaDR2BjgHl8tis853SKu1+GfQ1UoEqEa+ADIlk4lQLVmlO+iMQPU9GCHhYJsauG2oxyBSLYQwE2Xhps7TQKvxnh6TpIQDaori6p5NI6o2MsrzJZ936hJPAJAZmf8aHU64tuRNslwoMI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766571459; c=relaxed/simple; bh=3QKEUFo5LXygi5n84KS64jmf6l8RWX20LRDFKQGndDU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QxbYpusRfDnCggFegK6S972Uw/fE3v0dU/NaHFAL+0dg0tJcM+vGiEps5c/gc/P8GF9prJnYIh/4VJppNmNKNhVTmuR1w9C1bufTMi8Cel3UsOO7PA1zMehEdvEcQ1B437UAbxUn6zXdpdWo/4Ql41ZNnuDOaNzy4zYDpYpENt4= 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=M8sxJa/G; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=gyPQc56u; 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="M8sxJa/G"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="gyPQc56u" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1766571457; 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=jzP3CpgRIzIHd4j7JJHeELNPFQj8HTZPnJadpGgQjTc=; b=M8sxJa/GQk2vLSz7jSunXPDhytPdnF/KgOozFy6hUeyOYe+r8DfUel0+cnODG4L+jg0tB6 Y9G2EiEwXaAGhDi+qJO8JiKVXwq0DlNH+COwAgXiV9+dsWn4R443yH1tjOGTSpP6hb7yHp LHjCBeVx3R/b9G8r/DWjObRyuZ4g/08= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-16-JtNLFHagPjqHpXk7QrvU6A-1; Wed, 24 Dec 2025 05:17:35 -0500 X-MC-Unique: JtNLFHagPjqHpXk7QrvU6A-1 X-Mimecast-MFC-AGG-ID: JtNLFHagPjqHpXk7QrvU6A_1766571454 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4775d110fabso47156265e9.1 for ; Wed, 24 Dec 2025 02:17:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1766571454; x=1767176254; 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=jzP3CpgRIzIHd4j7JJHeELNPFQj8HTZPnJadpGgQjTc=; b=gyPQc56uIqeX0CaDkJfewzq61MGoO6jXYjokTCHFjgBrcGrsNoO44X5eLN3YmKSRzu HXLUA2I6zfIEzIiGW5SIkjJb0m4omkMpblB68lKpwtyJk1CHcMO6EcErznHXQ+643+1R y3Fpbc4MZcOZR/QmaxQmbWFtRlGoXsh2orX2f7YNQEB0BeV3nfH9VUeXf7yid5kcdL0F wdakzKSuoFR5cciU8lBOAi21qJC1m9WPU0PXxW94p5cY3spnK3W9JXAzO1Wz9cMhsmHO nJcmQ2LuuSKfA/fXBbr1fHByxDSjQH588lnv6ZqiZXBrqsN+TwA8/oDrr6DIsTnC275w tnMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766571454; x=1767176254; 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=jzP3CpgRIzIHd4j7JJHeELNPFQj8HTZPnJadpGgQjTc=; b=GzpjljSu3GiCQlK31Ikm4M4yNvnVrK4JpMvLpd8yGNpOMBTzfNr6jD9ixmacA8iHSn J0QU54usFAbfUtHrx0kjK9V/mwH1VALFN8zj3js8/Z6P3s8k7VVUn63XVKBc6VE8mMIy 6j7fgpwmnd/v5KmXQcOaAAXgHnzoIfDF6kN/iK4AVcyI/QNe7JMFWHNyQND6U+raDJK2 qR/XfL9lY3qH7sDy/KQOG1+1OL1QxxOwMbnZFWrr605WX1KROQHWyj7RU825qLToIj6W EjbAIxah/17xGakL8OukcONfYloFQauWUFo3T5hPyD8TnZpLhxD6kf3Hv8Q/r0TfF3dc ISFg== X-Forwarded-Encrypted: i=1; AJvYcCUIEkqXVgxriNDcATs4CiOSYxD0JX+oHvoXupS9G42HXo92larKmJ56bwp2YbdnOa6V3uzKOXgkFbgG68g=@vger.kernel.org X-Gm-Message-State: AOJu0YxuA/Vm/RS6VCirt1ly3adK1plgJo9d9TfAZhp97Z9+d1zHkB1+ tCmG3kt/yvhePz8f88htxggOUsnFFgojAi530U5pA+GsJYB5XoSu0vuKAdxeeZyDFWmENtbQpgx oBoHdyYlQvmjhdODp9IsgfOfFm8rrC3d+wahrLlZamPezuw16PvstnHkXWAkrAYoFlA== X-Gm-Gg: AY/fxX7KmxYZSRhrV8TjL5HBGQaaT3tglY3ixU4RXKaVRdbi++k9PBt6C/hj5VGYISM yizSSKbqaCiSC6Qf4Hr63Ampdn0rLv/EVL6J4Wd6DYleonUQALMHiDzA+YuAyJvIbjqKrW9bQHf WKfO/qurh6wNoYeyL5DhD49rfKYkZLnT1/Io5i8A4WvjKIU7QLJZh8QO1n5ZqY3OgZ+mHeD+Aqi M+BrS97/BmtCVZqaOnXi8I+DmXSNGWvDoLHP52zRj4qogLs2yi7BCb+O4grYfRJkzhNNVXre0Ta U7BQGFpktPQt+DxuEm/Hi+PjE8pDPKnLt3F4SDO9rDxCt4gW/CSR/d3lZaeNgeEOPwVA4KXcQvS x X-Received: by 2002:a05:600c:444b:b0:477:9814:6882 with SMTP id 5b1f17b1804b1-47d1953b77fmr150409845e9.5.1766571454139; Wed, 24 Dec 2025 02:17:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IFSLHXjoue22ycWh04PhviD8xBwMq2igG9VbtveaphLk/VbLO+tvT/RScqlygcnULbaItpauA== X-Received: by 2002:a05:600c:444b:b0:477:9814:6882 with SMTP id 5b1f17b1804b1-47d1953b77fmr150409605e9.5.1766571453707; Wed, 24 Dec 2025 02:17:33 -0800 (PST) Received: from redhat.com ([31.187.78.137]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47be27b0d5asm343055335e9.13.2025.12.24.02.17.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Dec 2025 02:17:33 -0800 (PST) Date: Wed, 24 Dec 2025 05:17:30 -0500 From: "Michael S. Tsirkin" To: Bui Quang Minh Cc: netdev@vger.kernel.org, Jason Wang , Xuan Zhuo , Eugenio =?iso-8859-1?Q?P=E9rez?= , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , virtualization@lists.linux.dev, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: Re: [PATCH net 3/3] virtio-net: schedule the pending refill work after being enabled Message-ID: <20251224051636-mutt-send-email-mst@kernel.org> References: <20251223152533.24364-1-minhquangbui99@gmail.com> <20251223152533.24364-4-minhquangbui99@gmail.com> 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: <20251223152533.24364-4-minhquangbui99@gmail.com> On Tue, Dec 23, 2025 at 10:25:33PM +0700, Bui Quang Minh wrote: > As we need to move the enable_delayed_refill after napi_enable, it's > possible that a refill work needs to be scheduled in virtnet_receive but > it cannot. This can make the receive side stuck because if we don't have > any receive buffers, there will be nothing trigger the refill logic. So > in case it happens, in virtnet_receive, set the rx queue's > refill_pending, then when the refill work is enabled again, a refill > work will be scheduled. > > Signed-off-by: Bui Quang Minh Sounds like this fixes a bug previous patch introduces? The thing to do is to reorder these two patches then. > --- > drivers/net/virtio_net.c | 21 ++++++++++++--------- > 1 file changed, 12 insertions(+), 9 deletions(-) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index 8016d2b378cf..ddc62dab2f9a 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -383,6 +383,9 @@ struct receive_queue { > /* Is delayed refill enabled? */ > bool refill_enabled; > > + /* A refill work needs to be scheduled when delayed refill is enabled */ > + bool refill_pending; > + > /* The lock to synchronize the access to refill_enabled */ > spinlock_t refill_lock; > > @@ -720,10 +723,13 @@ static void virtnet_rq_free_buf(struct virtnet_info *vi, > put_page(virt_to_head_page(buf)); > } > > -static void enable_delayed_refill(struct receive_queue *rq) > +static void enable_delayed_refill(struct receive_queue *rq, > + bool schedule_refill) > { > spin_lock_bh(&rq->refill_lock); > rq->refill_enabled = true; > + if (rq->refill_pending || schedule_refill) > + schedule_delayed_work(&rq->refill, 0); > spin_unlock_bh(&rq->refill_lock); > } > > @@ -3032,6 +3038,8 @@ static int virtnet_receive(struct receive_queue *rq, int budget, > spin_lock(&rq->refill_lock); > if (rq->refill_enabled) > schedule_delayed_work(&rq->refill, 0); > + else > + rq->refill_pending = true; > spin_unlock(&rq->refill_lock); > } > } > @@ -3228,11 +3236,8 @@ static int virtnet_open(struct net_device *dev) > if (err < 0) > goto err_enable_qp; > > - if (i < vi->curr_queue_pairs) { > - enable_delayed_refill(&vi->rq[i]); > - if (schedule_refill) > - schedule_delayed_work(&vi->rq[i].refill, 0); > - } > + if (i < vi->curr_queue_pairs) > + enable_delayed_refill(&vi->rq[i], schedule_refill); > } > > if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_STATUS)) { > @@ -3480,9 +3485,7 @@ static void __virtnet_rx_resume(struct virtnet_info *vi, > if (running) > virtnet_napi_enable(rq); > > - enable_delayed_refill(rq); > - if (schedule_refill) > - schedule_delayed_work(&rq->refill, 0); > + enable_delayed_refill(rq, schedule_refill); > } > > static void virtnet_rx_resume_all(struct virtnet_info *vi) > -- > 2.43.0