Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp2673347rwb; Sun, 4 Sep 2022 22:26:46 -0700 (PDT) X-Google-Smtp-Source: AA6agR5+WXwJetUJM4mdBcFvv9wRv/jyGLNARcPdc6NhtvBzwF/hVHapiOFm/fGnh7msv+62lChy X-Received: by 2002:a17:902:e80c:b0:174:e386:c5b7 with SMTP id u12-20020a170902e80c00b00174e386c5b7mr33578298plg.84.1662355606090; Sun, 04 Sep 2022 22:26:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662355606; cv=none; d=google.com; s=arc-20160816; b=D4nEzjLJbyy0i6EWhGzrtHMPduUQHLxYDk/8jIiuMNSzCKcZZzSoxpkEkdKQ2PykYb q9UXCKQkvFDbLNaWnftqrRN7Gem0T/t4PHvbSWq6Jt+MjLApNGTtKFv24t8WXqLZagUw qN+HJ7n2T/HA8mevIVGdx153XM0SuTQ+YEof+B5ChIPsqdp1aJEPxZA/AYeGvgyAifVh hKoF+HXi0yyxzLKb9qucba2DxKlVdMHYS2fDAY4JFKWAy7lmJXfTCxDacv7DgUjp02C5 2TMlLRuYVuYaw/tYSmXWxgY1jGnjRpbgANolYFo6Eaf7Su7QWOyt9l0sHIHGCZ47lRmx 5ANg== 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=m9dcPGbMHXaYmZUV3H1zsLHmGsdVHZV/OdAWS9Cd78s=; b=eEuVvBsz3D2LGyYKPhADxPfKAow1NJIWbQinJ7tVUc562+ISiX0skAZzkxL0d1tQ9y TS3bQYViMvlhP9RpwmBXuceST6SwRPPNtqhp2XPqZcPnfwAkE2qoNEaNEeCTMb+1/mpi gE/vixiswLCAT6HWQQ3sZlzkWJrA8Ha4UNH73XxWaC0qaQOu4bdDNAKDZ5mrp7TnzKax np30wmJebXoGKI4LMpaXkwK+MYwQeIZfUX9xbn+v8uQTIl+6GbwkwsI38aA3CUKrgXMU zohiDoHtqog15kibkCD8ULvr0BkCGpxsX37Ksjxu0QkQthTjs5qAzPn01JWD3gF+kz6W wI8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=O3mg3eS4; 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 n2-20020a63e042000000b0042a00292790si5812967pgj.242.2022.09.04.22.26.34; Sun, 04 Sep 2022 22:26:46 -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=O3mg3eS4; 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 S234698AbiIEEx5 (ORCPT + 99 others); Mon, 5 Sep 2022 00:53:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232183AbiIEExz (ORCPT ); Mon, 5 Sep 2022 00:53:55 -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 DC5F5286D6 for ; Sun, 4 Sep 2022 21:53:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662353634; 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; bh=m9dcPGbMHXaYmZUV3H1zsLHmGsdVHZV/OdAWS9Cd78s=; b=O3mg3eS49dTB9nRTQhbaee3KBJLUkdwCoWLb3ms5cWewJkNFlj6qUt5wQu8elKfw6iK5Nx DRXMM53KB8sdmtt6hVkeh2uwuEJEVX8y/a/ig970HwjO88mIoUd11rxERNyAkbJnz6EtJe 8+MdWbF6XeAnPhxSDDL7RjAwjYC8/oU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-144-dwOq394-M3KwOdNU4AR59g-1; Mon, 05 Sep 2022 00:53:48 -0400 X-MC-Unique: dwOq394-M3KwOdNU4AR59g-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7F93A185A79C; Mon, 5 Sep 2022 04:53:48 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-129.pek2.redhat.com [10.72.12.129]) by smtp.corp.redhat.com (Postfix) with ESMTP id 51F421410F37; Mon, 5 Sep 2022 04:53:44 +0000 (UTC) From: Jason Wang To: mst@redhat.com, jasowang@redhat.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: gautam.dawar@xilinx.com, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net] virtio-net: add cond_resched() to the command waiting loop Date: Mon, 5 Sep 2022 12:53:41 +0800 Message-Id: <20220905045341.66191-1-jasowang@redhat.com> MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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, 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 Adding cond_resched() to the command waiting loop for a better co-operation with the scheduler. This allows to give CPU a breath to run other task(workqueue) instead of busy looping when preemption is not allowed. What's more important. This is a must for some vDPA parent to work since control virtqueue is emulated via a workqueue for those parents. Fixes: bda324fd037a ("vdpasim: control virtqueue support") Signed-off-by: Jason Wang --- drivers/net/virtio_net.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index ece00b84e3a7..169368365d6a 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -2000,8 +2000,10 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd, * into the hypervisor, so the request should be handled immediately. */ while (!virtqueue_get_buf(vi->cvq, &tmp) && - !virtqueue_is_broken(vi->cvq)) + !virtqueue_is_broken(vi->cvq)) { + cond_resched(); cpu_relax(); + } return vi->ctrl->status == VIRTIO_NET_OK; } -- 2.25.1