Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1680825rwr; Fri, 5 May 2023 19:20:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6EJd0lpjzYcDqnM3YLyNuREm4urU3uGniqGNnnZlg85PqP4RpI5tT2auY0XRS+wAgUuNuu X-Received: by 2002:a17:90a:404b:b0:24e:3b85:a8a with SMTP id k11-20020a17090a404b00b0024e3b850a8amr3566476pjg.8.1683339641197; Fri, 05 May 2023 19:20:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683339641; cv=none; d=google.com; s=arc-20160816; b=1I9gjpuqJ87iyidfRd1WKM76093/rhvaDHeKKpZ/SdK2CCr6gqpdCw5/vAH4sQ0/sr 51mMWI+qJQN0JPe3/2Ak1qT2cmGArmR58tbr6kSN7jMJkuKzHR/2hD8zXrv9vERkw9+g hEPmtPfP8kxCjY5KuKn1Auy6mVpO+CH2xNh1zif8VqQu+NncDHn2+18XRaYvkK5h4O3+ 8bTwXruxWCcTmNN3R0EI1ScKYHvKVSj+OVI7s65mghpXohVA5ltYn8ZX2VwiJ+kHiXbv hGuImMrYqSGY8BYsaqdZ08gj1A/Jz3g1G1Ad/aEUcRXS+cSUYhQc7XXtZl1/duccbntL Hcnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:date:subject:message-id; bh=ocBq9T9Dz0v8+iXOLxE62KaqBGsI8+iDQhUg3qF+8EI=; b=XyvFtPJk2/FKq1T0YklYs5c+HtFFSNbNozWJ1MyT4y28+z8HT9EFlTuyjJoP0OlSO5 /YCvNcS7oorS8ZloeOgPeRd1poJ3Zb6edR8J9bF0XiX1gDtA4ObPXdsLUWUrycFhyi1r hv3f8U7dUsiz/fgVJfqaXRT3TpOc3CS/kqIPqTYwGL+yUXgvpRy7n9f7qXseN2SI1Enp jrsq2kNCV1twf8OQFvqt49ZisBlL/2ZvfP/i3PNlaBw3WMskzjN7eeEk+yL8ozyqFXhN RTw7ja0m2GOajAe3/QVCRCn/u7aR4cXL5JT+y2n5oogKrSITtI86ehMlPCvlqYgGGAla HGvg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bo13-20020a17090b090d00b0024e22853a90si10619891pjb.170.2023.05.05.19.20.26; Fri, 05 May 2023 19:20:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229805AbjEFCID (ORCPT + 99 others); Fri, 5 May 2023 22:08:03 -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 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 > > >