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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7927C7EE24 for ; Sat, 6 May 2023 02:08:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229924AbjEFCIE (ORCPT ); Fri, 5 May 2023 22:08:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbjEFCIC (ORCPT ); Fri, 5 May 2023 22:08:02 -0400 Received: from out30-99.freemail.mail.aliyun.com (out30-99.freemail.mail.aliyun.com [115.124.30.99]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25D945274; Fri, 5 May 2023 19:07:59 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=xuanzhuo@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0VhrSoEj_1683338876; Received: from localhost(mailfrom:xuanzhuo@linux.alibaba.com fp:SMTPD_---0VhrSoEj_1683338876) by smtp.aliyun-inc.com; Sat, 06 May 2023 10:07:57 +0800 Message-ID: <1683338663.2120674-1-xuanzhuo@linux.alibaba.com> Subject: Re: [PATCH v4] virtio_net: suppress cpu stall when free_unused_bufs Date: Sat, 6 May 2023 10:04:23 +0800 From: Xuan Zhuo To: Jason Wang Cc: mst@redhat.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, zhengqi.arch@bytedance.com, willemdebruijn.kernel@gmail.com, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Wenliang Wang References: <1683167226-7012-1-git-send-email-wangwenliang.1995@bytedance.com> In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 5 May 2023 11:28:25 +0800, Jason Wang wrote: > On Thu, May 4, 2023 at 10:27=E2=80=AFAM Wenliang Wang > wrote: > > > > For multi-queue and large ring-size use case, the following error > > occurred when free_unused_bufs: > > rcu: INFO: rcu_sched self-detected stall on CPU. > > > > Fixes: 986a4f4d452d ("virtio_net: multiqueue support") > > Signed-off-by: Wenliang Wang > > --- > > v2: > > -add need_resched check. > > -apply same logic to sq. > > v3: > > -use cond_resched instead. > > v4: > > -add fixes tag > > --- > > drivers/net/virtio_net.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > > index 8d8038538fc4..a12ae26db0e2 100644 > > --- a/drivers/net/virtio_net.c > > +++ b/drivers/net/virtio_net.c > > @@ -3560,12 +3560,14 @@ static void free_unused_bufs(struct virtnet_inf= o *vi) > > struct virtqueue *vq =3D vi->sq[i].vq; > > while ((buf =3D virtqueue_detach_unused_buf(vq)) !=3D N= ULL) > > virtnet_sq_free_unused_buf(vq, buf); > > + cond_resched(); > > Does this really address the case when the virtqueue is very large? Yes, I also have this question. I think cond_resched() should be called eve= ry time a certain number of buffers are processed. Thanks. > > Thanks > > > } > > > > for (i =3D 0; i < vi->max_queue_pairs; i++) { > > struct virtqueue *vq =3D vi->rq[i].vq; > > while ((buf =3D virtqueue_detach_unused_buf(vq)) !=3D N= ULL) > > virtnet_rq_free_unused_buf(vq, buf); > > + cond_resched(); > > } > > } > > > > -- > > 2.20.1 > > >