Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp162993rwj; Thu, 22 Dec 2022 00:53:55 -0800 (PST) X-Google-Smtp-Source: AMrXdXurkwQ8FGMVbNHZTklrjl9tewf9UWYZNhDnczpi3QniEXvJJZDERL1GJPcYCXtfkqqgMpbK X-Received: by 2002:a17:906:1c4e:b0:7c1:49e:6e3b with SMTP id l14-20020a1709061c4e00b007c1049e6e3bmr3914920ejg.68.1671699234785; Thu, 22 Dec 2022 00:53:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671699234; cv=none; d=google.com; s=arc-20160816; b=h3h2TNlTn4DlOwTiZmXr9L03jw8xpBXOE9oZb5V8Vhtvh/jqqdLjzc+BH2L0IvZMnd eQx8YsDn3hqrL3F7lgoN+rqNGl8Rr5xEYrQas61UgOMVjFkP7Tq7CimudvTsafmIWhY4 nH63bcU1cPhDwrYDvCmp1zE/ht4X/fqdNzBsybLHhCLn47J8n6az4PXYkiFckTVB9jbU 7lY3SyKDphcA2EVeKMH2o7WD/8zzPvSluH0c6f0oeGWkbe0JhH0d+2JniRnuuW2zn+cG SEIlpbvpvZkkwhOrhHEIuDZN2CV9zewgKz7S1BVJW4QiS3h9sUIGteAKrWSvEoF4Gncp j71Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=KNeBYmXuI57DgCzyGIVCTcmPzwc5WTW5DEjmav8+hVE=; b=XJ4NN9za5nv1Za4AlkmW4t8nyZZNWPlNBrCfHqum18uxVd/L1qAxp1MM202g11az/Y hv9tp7uMWZPqDHZbWokqzi/TtlsI3TTYr/IY1GkhXcsNs6wYrMJC24H0nokH7pxBsllw 0/JpWHGzjLLPtbi04sw+dYiGf79FJ7XcdT4qqRGyXVyuv6pOZEFR2YNn8yShVyPxcMVZ fDq22rzELXxjqQXNglDFr3Uhhc+IhiddM3zupGr6amtX+A2zE3+KDq/lUdjnawmVdQsU dpFCraYI0buk/vzMhoxTRgpLDlJfWm/P6/rVxyabFckLjb2MYZ/CfVV6Ik0qQOHOqGY+ //Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WBGJaCfw; 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 s6-20020a1709066c8600b007b5dd3e6995si3459273ejr.917.2022.12.22.00.53.39; Thu, 22 Dec 2022 00:53:54 -0800 (PST) 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=WBGJaCfw; 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 S231221AbiLVIoJ (ORCPT + 67 others); Thu, 22 Dec 2022 03:44:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235056AbiLVIoH (ORCPT ); Thu, 22 Dec 2022 03:44:07 -0500 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 434C923BE7 for ; Thu, 22 Dec 2022 00:43:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671698602; 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=KNeBYmXuI57DgCzyGIVCTcmPzwc5WTW5DEjmav8+hVE=; b=WBGJaCfwyy1XMcuanNditZ70P0bZNPJNaTypgu5NPJn+MYQ4qMQINx4JS4fYvD8UtD47kS pR7NT4nBrY2dZYSgULcxjlKdC346nQ81IsV282m+t7rdtM2slCnACH1DXLsoxFxSKpR5EL 2Tr8DR5mMel4x1uETswKnXi8QjaSaKA= Received: from mail-ot1-f70.google.com (mail-ot1-f70.google.com [209.85.210.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-652-YvSGuYG6ONeVRK0vkLJ-QA-1; Thu, 22 Dec 2022 03:43:21 -0500 X-MC-Unique: YvSGuYG6ONeVRK0vkLJ-QA-1 Received: by mail-ot1-f70.google.com with SMTP id l44-20020a0568302b2c00b006782da3829eso681959otv.16 for ; Thu, 22 Dec 2022 00:43:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=KNeBYmXuI57DgCzyGIVCTcmPzwc5WTW5DEjmav8+hVE=; b=7+/e7os6Yjyj/JP+1ehINRjLC/TK1mxtATace0vF1EIEekXybKQKg+4OY4YrS9BNwi /w/GICwP//JIlTBYl6vN4/GmeHHyBmMixD7yb51H1Wq7iGLkxExFuU4z57UQOuSFhS0K Ab9QgwWPMiWjFT5vCwq5sO4Poeh1WkJEcEdB5PosS3ZepLeyi9JQb62tG0Xn/ePxyAH2 /IBpVzgSUNZ0J1zNRjOpysXnFHg3ynlFxb3Po9Jg52pEb4FsIvj5gMBdd0WLD9Tw9agA Qb8gew4ROBXuZ29EtaRp/fwG0kzPAUX0PRNhqePrU6NO4GtY9eQBrWDUJtg1WjFKXqP/ 62BA== X-Gm-Message-State: AFqh2kpm6vgBFLx/43YJ87tOJUD0GE1K3YOiEO0fFVJbv52NKWtWjRuA Ecd9ACcFUS1R0OY1AcqChEBs3DX4R6yxXGwzrWBzXCNiivZUwD2XpixqAJWr/i7XpehEd8FtsoM OcosJM54zd+OuamDoLnQD8Pg8/8ram50ZGnaOollR X-Received: by 2002:a05:6870:4413:b0:144:a97b:1ae2 with SMTP id u19-20020a056870441300b00144a97b1ae2mr266523oah.35.1671698600456; Thu, 22 Dec 2022 00:43:20 -0800 (PST) X-Received: by 2002:a05:6870:4413:b0:144:a97b:1ae2 with SMTP id u19-20020a056870441300b00144a97b1ae2mr266519oah.35.1671698600234; Thu, 22 Dec 2022 00:43:20 -0800 (PST) MIME-Version: 1.0 References: <20221222060427.21626-1-jasowang@redhat.com> <20221222060427.21626-5-jasowang@redhat.com> In-Reply-To: From: Jason Wang Date: Thu, 22 Dec 2022 16:43:09 +0800 Message-ID: Subject: Re: [RFC PATCH 4/4] virtio-net: sleep instead of busy waiting for cvq command To: Alvaro Karsz Cc: mst@redhat.com, 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, eperezma@redhat.com Content-Type: text/plain; charset="UTF-8" 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, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 Hi Alvaro: On Thu, Dec 22, 2022 at 2:44 PM Alvaro Karsz wrote: > > Hi Jason, > > Adding timeout to the cvq is a great idea IMO. > > > - /* Spin for a response, the kick causes an ioport write, trapping > > - * into the hypervisor, so the request should be handled immediately. > > - */ > > - while (!virtqueue_get_buf(vi->cvq, &tmp) && > > - !virtqueue_is_broken(vi->cvq)) > > - cpu_relax(); > > + virtqueue_wait_for_used(vi->cvq, &tmp); > > Do you think that we should continue like nothing happened in case of a timeout? We could, but we should not depend on a device to do this since it's not reliable. More below. > Shouldn't we reset the device? We can't depend on device, there's probably another loop in reset(): E.g in vp_reset() we had: while (vp_modern_get_status(mdev)) msleep(1); > What happens if a device completes the control command after timeout? Maybe we could have a BAD_RING() here in this case (and more check in vq->broken in this case). Thanks > > Thanks > > Alvaro >