From patchwork Mon Dec 26 07:49:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 13081692 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B45A8C46467 for ; Mon, 26 Dec 2022 07:50:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231771AbiLZHuJ (ORCPT ); Mon, 26 Dec 2022 02:50:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231684AbiLZHuD (ORCPT ); Mon, 26 Dec 2022 02:50:03 -0500 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 714DD5FF7 for ; Sun, 25 Dec 2022 23:49:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672040959; 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=r0SQFSZXD8Vb1EKKItz+UfkpNXT80NYrf2iD+mDfQXM=; b=GjXvKJXOTdycRXPt/NgJ22tDlCaxr+j2cZ+5eVmL3IOtnVFTfewngS7DZv8MZWuPGvJGc3 d+TdxXaP1TRGboEYxQBIUfqNvLLXnhQhSUTTnqahe0C8yDqAn97j+PYwzzH5H04Q2bz5jS hml8rp1VmLRbC/4B/TRM/T9nh1+HQnk= 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-349-Bwd-GaOKMOud6zZNOUbn6Q-1; Mon, 26 Dec 2022 02:49:15 -0500 X-MC-Unique: Bwd-GaOKMOud6zZNOUbn6Q-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 20A448533DF; Mon, 26 Dec 2022 07:49:15 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-100.pek2.redhat.com [10.72.13.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83DFB492B00; Mon, 26 Dec 2022 07:49:10 +0000 (UTC) From: Jason Wang To: mst@redhat.com, jasowang@redhat.com Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, maxime.coquelin@redhat.com, alvaro.karsz@solid-run.com, eperezma@redhat.com Subject: [PATCH 0/4] virtio-net: don't busy poll for cvq command Date: Mon, 26 Dec 2022 15:49:04 +0800 Message-Id: <20221226074908.8154-1-jasowang@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Hi all: The code used to busy poll for cvq command which turns out to have several side effects: 1) infinite poll for buggy devices 2) bad interaction with scheduler So this series tries to use sleep + timeout instead of busy polling. Please review. Thanks Changes since RFC: - switch to use BAD_RING in virtio_break_device() - check virtqueue_is_broken() after being woken up - use more_used() instead of virtqueue_get_buf() to allow caller to get buffers afterwards - break the virtio-net device when timeout - get buffer manually since the virtio core check more_used() instead Jason Wang (4): virtio-net: convert rx mode setting to use workqueue virtio_ring: switch to use BAD_RING() virtio_ring: introduce a per virtqueue waitqueue virtio-net: sleep instead of busy waiting for cvq command drivers/net/virtio_net.c | 90 +++++++++++++++++++++++++++++++----- drivers/virtio/virtio_ring.c | 37 +++++++++++++-- include/linux/virtio.h | 3 ++ 3 files changed, 115 insertions(+), 15 deletions(-)