Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp3197915rwr; Sun, 7 May 2023 06:50:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5WZctdaukMwaqSlQhyQsIN1LFwwE8RCYzzddqmYkZs2Ez0cyfAOCTAzodKa1WS6h1Opn5W X-Received: by 2002:a17:903:2292:b0:1a1:bff4:49e9 with SMTP id b18-20020a170903229200b001a1bff449e9mr10415282plh.23.1683467407783; Sun, 07 May 2023 06:50:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683467407; cv=none; d=google.com; s=arc-20160816; b=Vxlx0gh8ocqzVl8jLx/27ZqlVJ3cvAKF7egkRYtOYYoJA5R9m8hLg45aUa8u9GN+pK Uo2J9sqx2q75M2ThSzn5+XYNfSCwZKbID1xqse25o+8RxT3pnYkoWHha0L4Uv53kEXws Zb4YO6IA3tudOuXsdA4B/XV9Iv75rpyiOpO9c5UgAvGXxmud80bWJ3JnF+KhVwqE7Hd4 1zMdhXmEZm2YE/SjWks8Z2p4LAQ4VBytyKsT3/85isDCnvFbGfxRGaI8KsP+vixF2PUU BGq9FBDImPn/1G62V+wopbcuboJzrplEXRzyGS0/lyYAXs2fpevNalIHh5cE9yBSITMF h6Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=65lQRJ+gv4EXk4uO01YGhnAV/eJrvV/vUJvZ5bnqIuQ=; b=d/KzL3RQ2N20xslP21+J26oZgMEUHpFtUiIQS+FxL6LZATZm6xgUphDioUOpSdDZWt PlMkqKRuFsktFoLTBHgyBFfoaRCva+hX9/hT8r6lUfasRwSpUvHP6WiMUt+mdGGDOStD PRqTECiR2orQ0FEezWQp/OGMJLvi6N8td1i3D1yBQVQg0n1Udv1NtDpQ7azGl9412A46 BOwy6PXj6zrLXGi1B91kheuF+MqQ8zUm/8xSan6L2a0wZq1QBNDU3pC9Bfp9E5DkzJV3 86uJZF/FE032lak+KKWkDHRK7LGacEI+CA6Z0pZwtvEU9EoTXvYcIaX9V7JXLRF9Km6J rePA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="SUqrfA/H"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u1-20020a170902e80100b001a980a2b405si6402781plg.471.2023.05.07.06.49.51; Sun, 07 May 2023 06:50:07 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="SUqrfA/H"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230415AbjEGNfC (ORCPT + 99 others); Sun, 7 May 2023 09:35:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230527AbjEGNfB (ORCPT ); Sun, 7 May 2023 09:35:01 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E919D12485 for ; Sun, 7 May 2023 06:34:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683466453; 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=65lQRJ+gv4EXk4uO01YGhnAV/eJrvV/vUJvZ5bnqIuQ=; b=SUqrfA/HiJnTfk63a/hV5ut5bxskMtolnasGYJc2C3Ltswg2Ek+Sa9pokexJ3a+uWJBOMw 5bzSkzblF8QuBfL7pgq/PokTaBBvvUvOSCJpPrbPjHqB8dRkua/U1WZQD0DWwxuz84GlUI Yyqdp6/LA5ltnaRsIogjzG4sQbQ1FYg= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-140-TurOFaeCOrOH30MkhdP0Rg-1; Sun, 07 May 2023 09:34:11 -0400 X-MC-Unique: TurOFaeCOrOH30MkhdP0Rg-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-3f170a1fbe7so22236255e9.2 for ; Sun, 07 May 2023 06:34:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683466450; x=1686058450; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=65lQRJ+gv4EXk4uO01YGhnAV/eJrvV/vUJvZ5bnqIuQ=; b=Rdn+YwK0SlxHy4s5v9p4rOTRgcL9hehxZQICW2pCpkEVHs5txBTtkK6x+4q92+7zJc vuct+NI2YgzMy6QNZfp6IOgDYDYwV4TQjOtrspowEGp+5dWfGfWGg6LzRgs4kkqbshAh 82GgsYCJfoAeVqBL5A86eIcm187zM3XPPPmns284ORdcBWLu2Y50guuIOmJ8+KsV9wdG W1S7e2o0QSvwncXu0UYHdHwBvrRK8jn7AC9fJFymDpWCaqOldwx6m5Md7QXOQzBYF/te L7o4Vb07/JZtoRLBG5erMVIkj+a0zH3ZUZ/KsLh0HdChA4mTi4PSYKwKf+a30ukDblAy EHjw== X-Gm-Message-State: AC+VfDzJRfe7+Rko6JPqn3G9A8Pb3L/PzRvcnCNVYa+AxBgEcCNq4JlX fMz59O1724ge2dIG+09hyOUnT4IEcgGAFhWOyrLWv9HCuzH7TcdsW4dqRorSEE9bP/ECRMpKoCA s21mzXicG5mHxduNQM5c/gZQA X-Received: by 2002:a05:600c:28b:b0:3f4:2438:31c7 with SMTP id 11-20020a05600c028b00b003f4243831c7mr595355wmk.19.1683466450676; Sun, 07 May 2023 06:34:10 -0700 (PDT) X-Received: by 2002:a05:600c:28b:b0:3f4:2438:31c7 with SMTP id 11-20020a05600c028b00b003f4243831c7mr595347wmk.19.1683466450367; Sun, 07 May 2023 06:34:10 -0700 (PDT) Received: from redhat.com ([2.52.158.28]) by smtp.gmail.com with ESMTPSA id z17-20020a1c4c11000000b003ee20b4b2dasm13605868wmf.46.2023.05.07.06.34.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 May 2023 06:34:09 -0700 (PDT) Date: Sun, 7 May 2023 09:34:05 -0400 From: "Michael S. Tsirkin" To: Jason Wang Cc: Wenliang Wang , 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, xuanzhuo@linux.alibaba.com Subject: Re: [PATCH v4] virtio_net: suppress cpu stall when free_unused_bufs Message-ID: <20230507093328-mutt-send-email-mst@kernel.org> References: <1683167226-7012-1-git-send-email-wangwenliang.1995@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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, May 05, 2023 at 11:28:25AM +0800, Jason Wang wrote: > On Thu, May 4, 2023 at 10:27 AM 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_info *vi) > > struct virtqueue *vq = vi->sq[i].vq; > > while ((buf = virtqueue_detach_unused_buf(vq)) != NULL) > > virtnet_sq_free_unused_buf(vq, buf); > > + cond_resched(); > > Does this really address the case when the virtqueue is very large? > > Thanks it does in that a very large queue is still just 64k in size. we might however have 64k of these queues. > > } > > > > for (i = 0; i < vi->max_queue_pairs; i++) { > > struct virtqueue *vq = vi->rq[i].vq; > > while ((buf = virtqueue_detach_unused_buf(vq)) != NULL) > > virtnet_rq_free_unused_buf(vq, buf); > > + cond_resched(); > > } > > } > > > > -- > > 2.20.1 > >