Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp315942rwr; Thu, 27 Apr 2023 01:30:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6k86lr3MVj6J1K9fqWXxmrw5zdFfVX/zzaOH8e/+ketPBqiqCkUlraz7dY98fX5qEp6MVj X-Received: by 2002:a05:6a00:2d8a:b0:63a:2829:7e33 with SMTP id fb10-20020a056a002d8a00b0063a28297e33mr1301762pfb.0.1682584213122; Thu, 27 Apr 2023 01:30:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682584213; cv=none; d=google.com; s=arc-20160816; b=jxz3unjKIKhMY0PuLZj2jTW50RtRjqFmav201NfXzf1xXGMi2Da64XWWgkUnc+24uH ynri1NrETUfld8m50pGNuKuNb5n3iXdcboLC3yTxRlBYp/M8NDjZuS/tapuzFaiskIaW JQOxn1BKiWEl/g3Tu7kgteQG9tR37dOrsgXsBOOPwSjJZEmVMs0tDAYcfe0e3y7vuq7U fk39BNHNq+Roiw9S+slCOPyHABSEIB8407bmcHdDyl4LReHTbINOAA7WJIOJPsJQi2vY Oxxw5yEbi0dDrr4QintK6akUrvRde9X9TXOw4BS6QxMBy9qPQHLkLTkdzIfa0tHQgBuz QtHw== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=W8usmC3JGK9PorB0wAqvMMI+OvA7gcjYhdZApmddriY=; b=ytaG8vpFOKXHog55KiWtsHlYe332e049CYl0ULARMXCN8bqUzgCJRi41hlfLRQhsIZ eGYIcbffi2MmTX8c10lXQxyBwPgAEim2px/OiruQj0P2ig7EbJX1YxpMCyGPJd3P1K6Z bxBh88onkVxIjaTqk79wv6mfvIZpmjgIfuxEPpUaJQiMfhticndbiHZNkNaNQw3yHGxq CImxTgS7L9c9SHAt0JxOSnBshWrQTcjb6pTgDjdc9wRaVRB6BSEeBON9qJiOXIujBGa2 kmgrrJEX6gqFvYyakoShen4Y8PmWFZP8KdSGDIuhlMtHS7aVBk+bDDAZmUNeBqBJHVOc nwRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=N+faVCjZ; 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 n19-20020a635c53000000b00524d6cd6415si14999047pgm.665.2023.04.27.01.29.59; Thu, 27 Apr 2023 01:30:13 -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=N+faVCjZ; 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 S243016AbjD0IZE (ORCPT + 99 others); Thu, 27 Apr 2023 04:25:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229665AbjD0IYq (ORCPT ); Thu, 27 Apr 2023 04:24:46 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A373249D8 for ; Thu, 27 Apr 2023 01:23:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682583838; 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=W8usmC3JGK9PorB0wAqvMMI+OvA7gcjYhdZApmddriY=; b=N+faVCjZTFN00z42gAqKl3oYG9GRn6FRnRrF737cQBGA7P9wCKTnNjo55m4c7f0YyDrKlq +xcKGfU8CJ3qMYDjRDEKN2x+52t+SuEXbFdL4SAJ0q2tvisBcaHEaVYS6pc7ylMv5ZSDCN wprGYQhh+UoT7waG3J30G8nCkjjpxBo= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-397-nQiIc9wNM_2hHSx1kQ2s0Q-1; Thu, 27 Apr 2023 04:23:56 -0400 X-MC-Unique: nQiIc9wNM_2hHSx1kQ2s0Q-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-2f446161e5aso4895677f8f.1 for ; Thu, 27 Apr 2023 01:23:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682583835; x=1685175835; h=in-reply-to: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=W8usmC3JGK9PorB0wAqvMMI+OvA7gcjYhdZApmddriY=; b=K9uwhVVq5P6kvr4WjufzQKpJkD79FywFfJSmCcWS8SRf/XPrPZa21eTDOUN1mTwnpN /yvbx03lPLKlttHyV2D/LdhovCX7X4bjgZtp66pKBmEhre1DBSE9eZoDsmKGWQEY1CSa T66yncmGe0WXquW1bTZ44IcFTAiBKKSI+UHJfVzn5tAtEAd3H9dZoFDXWWyK7XFzulCX pagX7YFXTXANvL11ciQwQuVJ5mJ2hiwdiYIL7QcSyvRig1TANKd5e/EBRya9EesnTeKs 9lFh4Ob0JmrptiBg0GsUvCmM7k6yIW3TnQNzHV3hd9NfMU5oQ+QmTXbPyd3MECaFv8bk 2qWA== X-Gm-Message-State: AC+VfDw2Sro8EV4/ZWuhjlS13nw/nhQ3kgayYME7z7EAWyMiPlpUCPaO oywwh3j/nuCmMhF04QluG7eX3gtwv/SznVGM1BqUcSs0TY5Eu/AQ6g94yi3Q/dADH0wl0xdkz0g JwKrkyDxeYS0Wtle5dGfl90Am X-Received: by 2002:adf:db8e:0:b0:2fe:f2d1:dcab with SMTP id u14-20020adfdb8e000000b002fef2d1dcabmr580410wri.58.1682583835566; Thu, 27 Apr 2023 01:23:55 -0700 (PDT) X-Received: by 2002:adf:db8e:0:b0:2fe:f2d1:dcab with SMTP id u14-20020adfdb8e000000b002fef2d1dcabmr580392wri.58.1682583835248; Thu, 27 Apr 2023 01:23:55 -0700 (PDT) Received: from redhat.com ([2.52.19.183]) by smtp.gmail.com with ESMTPSA id b4-20020a05600010c400b002e45f6ffe63sm17892253wrx.26.2023.04.27.01.23.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 01:23:54 -0700 (PDT) Date: Thu, 27 Apr 2023 04:23:51 -0400 From: "Michael S. Tsirkin" To: Xuan Zhuo Cc: Wenliang Wang , virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, jasowang@redhat.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Subject: Re: [PATCH] virtio_net: suppress cpu stall when free_unused_bufs Message-ID: <20230427042259-mutt-send-email-mst@kernel.org> References: <20230427043433.2594960-1-wangwenliang.1995@bytedance.com> <1682576442.2203932-1-xuanzhuo@linux.alibaba.com> <252ee222-f918-426e-68ef-b3710a60662e@bytedance.com> <1682579624.5395834-1-xuanzhuo@linux.alibaba.com> <20230427041206-mutt-send-email-mst@kernel.org> <1682583225.3180113-2-xuanzhuo@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1682583225.3180113-2-xuanzhuo@linux.alibaba.com> X-Spam-Status: No, score=-2.3 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=unavailable 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 Thu, Apr 27, 2023 at 04:13:45PM +0800, Xuan Zhuo wrote: > On Thu, 27 Apr 2023 04:12:44 -0400, "Michael S. Tsirkin" wrote: > > On Thu, Apr 27, 2023 at 03:13:44PM +0800, Xuan Zhuo wrote: > > > On Thu, 27 Apr 2023 15:02:26 +0800, Wenliang Wang wrote: > > > > > > > > > > > > On 4/27/23 2:20 PM, Xuan Zhuo wrote: > > > > > On Thu, 27 Apr 2023 12:34:33 +0800, Wenliang Wang wrote: > > > > >> For multi-queue and large rx-ring-size use case, the following error > > > > > > > > > > Cound you give we one number for example? > > > > > > > > 128 queues and 16K queue_size is typical. > > > > > > > > > > > > > >> occurred when free_unused_bufs: > > > > >> rcu: INFO: rcu_sched self-detected stall on CPU. > > > > >> > > > > >> Signed-off-by: Wenliang Wang > > > > >> --- > > > > >> drivers/net/virtio_net.c | 1 + > > > > >> 1 file changed, 1 insertion(+) > > > > >> > > > > >> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > > > > >> index ea1bd4bb326d..21d8382fd2c7 100644 > > > > >> --- a/drivers/net/virtio_net.c > > > > >> +++ b/drivers/net/virtio_net.c > > > > >> @@ -3565,6 +3565,7 @@ static void free_unused_bufs(struct virtnet_info *vi) > > > > >> struct virtqueue *vq = vi->rq[i].vq; > > > > >> while ((buf = virtqueue_detach_unused_buf(vq)) != NULL) > > > > >> virtnet_rq_free_unused_buf(vq, buf); > > > > >> + schedule(); > > > > > > > > > > Just for rq? > > > > > > > > > > Do we need to do the same thing for sq? > > > > Rq buffers are pre-allocated, take seconds to free rq unused buffers. > > > > > > > > Sq unused buffers are much less, so do the same for sq is optional. > > > > > > I got. > > > > > > I think we should look for a way, compatible with the less queues or the smaller > > > rings. Calling schedule() directly may be not a good way. > > > > > > Thanks. > > > > Why isn't it a good way? > > For the small ring, I don't think it is a good way, maybe we only deal with one > buf, then call schedule(). > > We can call the schedule() after processing a certain number of buffers, > or check need_resched () first. > > Thanks. Wenliang, does if (need_resched()) schedule(); fix the issue for you? > > > > > > > > > > > > > > > > > > > > > Thanks. > > > > > > > > > > > > > > >> } > > > > >> } > > > > >> > > > > >> -- > > > > >> 2.20.1 > > > > >> > >