Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1484841rwr; Thu, 27 Apr 2023 19:28:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4s+yC8+TFLv0el2gZFPmAB9DEel5KdcXMxdwvzFHE33ERWUivMryKarz4hQ8DawcNx/Wkc X-Received: by 2002:a05:6a00:1ac7:b0:63d:32a3:b5f7 with SMTP id f7-20020a056a001ac700b0063d32a3b5f7mr8955554pfv.12.1682648890616; Thu, 27 Apr 2023 19:28:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682648890; cv=none; d=google.com; s=arc-20160816; b=ffuwLUFgKJ2ffzGFTeReBHhyXyjqoJqQqRWr4KNns9O67XuxOgS4V7WwMnFzrqXn3Z PLJJRX20yiNuhLtoqgz/ZfSTfSdhdz21S5UAlGNkX7upthfqn5rRp91zrt5W396Kl6t9 z5CJYbKltZzMjFiBbbiI7SdvYZ1NGoWRFN0NokPwLcuWylpwvVOYuLtvmvErPQQr48MS u8RuBZgfHjtsndkrl5JfLbBA/YPoFUNr3WY5UKr+rVZTr9Zn6v7+c6lWuGCcGCD8lhCD PeQ3YT3sfMIsGwNkjtjlMld9R2Ht4PZ5T6oZTk0UQTDIwX8tgAftPI7/cX6HlLtbJdf2 pOCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=UsGPjHUd/JAVdo+0tuStqIz7Tm1YkeItSZg+vCTmFL0=; b=ki64Vwxxu6aBwJH8Kyh8slIuZcw1E93iI+SQHXWNh4tQvJtndFm88MK8v3anWsYbKE QeXfr63mWO/GD+KuWkMtT3qqErXXUYe44JiIKbU7zNxpGGqumYRz5h3f1wR3ctirRp+y 6uKrRh2KTx0GU+lDbrO7VHoMOKVc6U9jyDAQi78Rzink6GJwlolrha0QboSznlnVehPR RMek4Nl8CMQzrJ+gBPn0iC3qVfC8cPAxiLrIIBdWMK53MaNIhgbAV2U1OziHEuQSLe92 DXVnuyBkVPn7j4/XOWqL/XGFuxTGND3lrMKxgV5jshBMrPSogwAyttAz9/29Ag1bYqpc WGdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=OuOomwVr; 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 a8-20020aa78e88000000b0062d781f1f87si19926627pfr.355.2023.04.27.19.27.56; Thu, 27 Apr 2023 19:28:10 -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=OuOomwVr; 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 S1344790AbjD1C0s (ORCPT + 99 others); Thu, 27 Apr 2023 22:26:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344424AbjD1C0q (ORCPT ); Thu, 27 Apr 2023 22:26:46 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4146C2137 for ; Thu, 27 Apr 2023 19:26:21 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-64115eef620so9385194b3a.1 for ; Thu, 27 Apr 2023 19:26:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1682648781; x=1685240781; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=UsGPjHUd/JAVdo+0tuStqIz7Tm1YkeItSZg+vCTmFL0=; b=OuOomwVr1+BUVgODDImCVU1rjVLtKKlmWxZM2hn3gGiQ6R13Fs7p78CSCDw4t19Bnf 3S16IDwx9H1vG4cwiX0lIFiTpnvDJN08bLXCXZZlTlyDiSdHyfgp+BVkdmsrcd8beHuD jwd0ZOaH2Y/NDAyYWJ9RZYR5ZQawfxTk7Xna+rpQJ9ZhZgtX+eXkx+F/VTfFgqMDB17e nnwO25mrKnxnagZenkBVknBa54zPvGz5m2YuXPiAhzvNLASIPoj/YHGWs5En/CUessYQ oY0AddnJ9ZGxdjROwv1NXna6QIklo5DJVEcKS0/Jl33MN7QiQ37BApALD+XHIP2TqMzT 3THw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682648781; x=1685240781; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=UsGPjHUd/JAVdo+0tuStqIz7Tm1YkeItSZg+vCTmFL0=; b=NqV6B52CmltFrmQ9Ognw8i+xX9H2pYY+FiqrjSmVuevC2mVKQ+xrxD8J+iQ2Jys+WF LYCj8sk3f3Tgzk+x5ynKNusKmjTdyN4HFJceHpwvZ6vlD2YKn0GONGtlKvg5ha50x2sJ +UfaT2F8IsV38emWUhaUc47gtQKWh4yWR+Ceyk1hjLqI+ZyjhSviNG4DdQ4S/w5ITfQr NkNuoe7ZZ2IpfMiw3hfaPy9GPdhSKsovm0Ej7TDG8ezhYRtXwAxmPeTDWANR2d8gLu+G fUKCSpekhHSaeq8/uyn/UHaQDtkZFBj5cOwyMdQkugEFAlcl5/Df17DjTWwFfIKz7jpT Tq3w== X-Gm-Message-State: AC+VfDwwFTL6NJSubn8prvcuQwd3Uz/jK1AFINOVidbL+IWoUdKopieL ydISLcEsp34ywP+kW0O5I+A2qg== X-Received: by 2002:a05:6a00:a16:b0:63d:3c39:ecc2 with SMTP id p22-20020a056a000a1600b0063d3c39ecc2mr4864383pfh.12.1682648780674; Thu, 27 Apr 2023 19:26:20 -0700 (PDT) Received: from n137-048-144.byted.org ([121.30.179.80]) by smtp.gmail.com with ESMTPSA id h125-20020a628383000000b0063b87717661sm13936511pfe.85.2023.04.27.19.26.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 19:26:20 -0700 (PDT) From: Wenliang Wang To: mst@redhat.com, jasowang@redhat.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Wenliang Wang Subject: [PATCH v2] virtio_net: suppress cpu stall when free_unused_bufs Date: Fri, 28 Apr 2023 10:26:13 +0800 Message-Id: <20230428022613.863298-1-wangwenliang.1995@bytedance.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 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. Signed-off-by: Wenliang Wang --- v2: -add need_resched check. -apply same logic to sq. --- drivers/net/virtio_net.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index ea1bd4bb326d..573558b69a60 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -3559,12 +3559,16 @@ 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); + if (need_resched()) + schedule(); } 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); + if (need_resched()) + schedule(); } } -- 2.20.1