Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp337566rwr; Thu, 27 Apr 2023 01:54:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6kSbhGWspQmeqHnlBqo7HsbWDeZZo85dcU+pS3uIf/vRHVObCQ7ORLxsWd587GcF2Q8ZBB X-Received: by 2002:a17:90a:1912:b0:23b:4bce:97de with SMTP id 18-20020a17090a191200b0023b4bce97demr1049017pjg.4.1682585698292; Thu, 27 Apr 2023 01:54:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682585698; cv=none; d=google.com; s=arc-20160816; b=f88KwOP87dgRNpx0Je0jYJyBXA/T2RD1YW/TbgxP1OycLBu+CYY2MRFi4ktJXLWDhy qsryuYqYDRcvUw1eJgU+3C2Gis+RGB/5m0RU85kJA2LuK7JD07UL1EEttsjW5gmoeNFA w3XKyo52DjMeEKpG+/8BUtGim6IsRm1cGp3EuNs2FNdDASxtv7v43fz1/DL8tZ91qTUm ylQ3RFQpmmdw5t9KndE3QekagQga8iWgJ5efDc1cGQtta+AZNRxeR6OBL5Ti3hzaodfh azkliSHRz+I3X6T4FKL31bbBoJvueK+0LtuzzHH8SlyQt7uOq5/amk3M8DJ2osCWwKis DzsA== 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:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=bOdJGbByKbJcYV9ZPYV2JH9cXI/RfIpCkrphjg1KQ/s=; b=wZhWW7RaQm3vs058HZ1YS8rhXp8yWkW+vpd1X+nqI8kD/pUtklaJw82Gv3QZeR2H8G VDuLCcITJwA3svZ7ShglNOficRqnm/T51iGjNGdRt7dhPz34OEZlPGXyltk40H6ZTApt ckMhBp+1RDhtG1MX0D2Hte3XB8kR1Uh1FFxldEuVi+vBQNV0jCqsw1Y/tYKVMBrxeVPa 9gAHMZ+S6Tv4DEZl6K4RycV1pETlX7qHubzxmUlKAxTNHJjxuqdh4UT6T+EGgPt6NTrB MdZhg4MaCe2e+8HWz3KGH1v1IXm4fqTW+I4dPp4La4Ua/U2DrF6qeDTtL8K+y6qgUR0H heWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=JFduCOcz; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i12-20020a17090adc0c00b002474560207csi17641773pjv.189.2023.04.27.01.54.46; Thu, 27 Apr 2023 01:54:58 -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=@bytedance.com header.s=google header.b=JFduCOcz; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243094AbjD0Iud (ORCPT + 99 others); Thu, 27 Apr 2023 04:50:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242777AbjD0Iuc (ORCPT ); Thu, 27 Apr 2023 04:50:32 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0D3C4C12 for ; Thu, 27 Apr 2023 01:50:04 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-63f273b219eso4186779b3a.1 for ; Thu, 27 Apr 2023 01:50:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1682585404; x=1685177404; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=bOdJGbByKbJcYV9ZPYV2JH9cXI/RfIpCkrphjg1KQ/s=; b=JFduCOczIxe+WvXouPfyVX6fu1JwXSLLKwfZR+9hn/noUchGmyHoojut/KX4jfDeyv 6RC800/0LfqEszOsaWbkrJVUZmPoJ+75sjwhF/2QZjMDClg4VGnftJnHzRTv0gZuNZWb 7hZZW5MuCc+IFpRnEYWwvBCfw6gzAYN7n/3VZ22Mac5WKWXiykiWzJTcN6FFahID981S vT6DtQLiUkAl4J231z3+nG699UnPonC7zRDHrTeELAdX7lOJDOjNo1tliDDxIlXvU0ko hyPChymYsFvoMAzfMbJeMJ8V/2yy5ptUScYW7Gq108kYpXTUF8y5PbEPYwpC5uqVtq0h DWIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682585404; x=1685177404; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bOdJGbByKbJcYV9ZPYV2JH9cXI/RfIpCkrphjg1KQ/s=; b=kPXUgZTrSEJ5RGteK64uRCiF1vqJHyIVdlNv/jPt2DJ/kp4/wCodbG8tjr7oC6nWLZ mZB1+ef5i93iIfjUdRia0v2haTn1BICEfP0UkxmmxQJfIXqcH3GskQkyl2NrfW0pnd4H fG3Av+w7fXcA92PvLCPNcePZAABElM9CLuyGnaSWbTr52wlx4luf/GNr/8EEvcPt8m6v OmkiGZb8Bi3FAOvKMmi15QEf0suE9vcWEOxHMGD43Y4QyXorNvgeHH2TNr3TFjEk2Un3 km0MXopOHqx4WzDtobLHEF/s4eaZcbg/d1JvvP32yXH29EJ6kQ5gzgQgOCdIkBS/NTIl SrPw== X-Gm-Message-State: AC+VfDw+hgOiVVKGfvdOHbUxXw+VIMk/DR1UGJJv6VJjQDCw9T9WOwz+ VZyRQHTPcPao1dy38inM0bZqnQ== X-Received: by 2002:a05:6a00:2282:b0:63d:254a:3902 with SMTP id f2-20020a056a00228200b0063d254a3902mr1359429pfe.12.1682585404154; Thu, 27 Apr 2023 01:50:04 -0700 (PDT) Received: from [10.2.195.40] ([61.213.176.12]) by smtp.gmail.com with ESMTPSA id o8-20020a62f908000000b0063b5776b073sm12551490pfh.117.2023.04.27.01.50.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 27 Apr 2023 01:50:03 -0700 (PDT) Message-ID: Date: Thu, 27 Apr 2023 16:49:58 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH] virtio_net: suppress cpu stall when free_unused_bufs Content-Language: en-US To: "Michael S. Tsirkin" , Xuan Zhuo Cc: 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 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> <20230427042259-mutt-send-email-mst@kernel.org> From: Wenliang Wang In-Reply-To: <20230427042259-mutt-send-email-mst@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,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 4/27/23 4:23 PM, Michael S. Tsirkin wrote: > 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? > Yeah, it works better. > >> >> >>> >>>> >>>>> >>>>>> >>>>>> Thanks. >>>>>> >>>>>> >>>>>>> } >>>>>>> } >>>>>>> >>>>>>> -- >>>>>>> 2.20.1 >>>>>>> >>> >