Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4301973pxv; Mon, 5 Jul 2021 20:07:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhLbV7CMbFPMOsbviZGYd01yAobDpY2kbZE3/BxAtdFhtJnTiWDPjq+z0eAvuSbG9H0F4S X-Received: by 2002:a17:906:7953:: with SMTP id l19mr16539861ejo.158.1625540857396; Mon, 05 Jul 2021 20:07:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625540857; cv=none; d=google.com; s=arc-20160816; b=RuDJ6RFrwUpoiHKguQiT6BuRycSHGk8+88NMkLezi4/GGBGG794F22ho+TWuUNm+tH srb6Kjg2OSd7OcpOS0WzB0vhYO+uZl/vxusU2jGdPp4jlVNpoWRVWyDLauee35x9kHUu 1fnvC8+ndBqfhvyFFGDEyICppZL5Zuw4Yb3LBAeAgHhhxZpwCiVppfl08HOtpbWY0W0v +6o+eLpSCTMdMKt7KVlAbT/KDuo49cfa0mhu91cxPwd3LoyyCTKGrpOVKB2A/UkYOjtW a3iIiP8jVXJAf9GCJmDEqcfmdlOiVJ9g//n5QJcZOmolPQnEtpSEVEg4odS4JVClecu+ pPpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=LCgUQ9YXkJh4ceT+VmUThz5I8QlmLbs1I7Jug0v7X9c=; b=kzgiA2ldFVgeHx8X27c8gQ7nO0iJN2am4pTzQRfb/bjem5uTacVBZq7Q47KoP0kNRb OpXz9SQNTrZrD7IZ7XpcJ+yPqubkZuyXlUFWrWSAW3nf5JNsSYuosuwp7zbS/1p7/o4y RBR+EB7YrsI6qgG4ksdJYUUv/H1YNBCuJDmrtV2MAliMi/++6P2Yi4ox+IXJ1Xff6VG3 9zb6zLHg71Pw/88TMw2H2Q46zBvD//xOt3oEo0YJG6mBpLFDBYaOB2H5wwu+7cpCFrmo bZo8i8LojrKhNIl1Rxj50bTns7ai7oEhtmbTtxg6jDR+Y9fD3tmc3CB4UJauB6Y1dA8X XsoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=AniVf1hg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l3si15484088ejd.313.2021.07.05.20.07.04; Mon, 05 Jul 2021 20:07:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=AniVf1hg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229938AbhGFDHM (ORCPT + 99 others); Mon, 5 Jul 2021 23:07:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229879AbhGFDHJ (ORCPT ); Mon, 5 Jul 2021 23:07:09 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57A2CC06175F for ; Mon, 5 Jul 2021 20:04:30 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id m1so25945156edq.8 for ; Mon, 05 Jul 2021 20:04:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=LCgUQ9YXkJh4ceT+VmUThz5I8QlmLbs1I7Jug0v7X9c=; b=AniVf1hg8E84bf88GbqvkjR+BefQ1f0lgfPF37iHtxf/YNkU0AyXPnMQYAxXb02mbo G48TrGfyovbNsFXOaWMWb/wyYJ2otEbO4ALwFWjEp+ou6S1UnsrushF1eZx06kGNzJN8 ZE+sG3ukhj23G3+11XF15U8C53r0c8X3EEc4Ok4kOBRxqvzy8189Ucu76sgW34Wbm8+X cTKFYWmWxoprLOtkLuVBPTW79tw5zhQYEEPwKl+lmcbOagdDirWCGWdkJ6EIa0dQXVy8 dgnLZv4WULOteK3YLraIZY9wXPfWdUjgUnwLaGWun0yx5ionzoeg2EP/vsiH019ipKeh +bSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=LCgUQ9YXkJh4ceT+VmUThz5I8QlmLbs1I7Jug0v7X9c=; b=NFHd997BWKS+RPIyG1UxTnzVghik1umXanTHtcK/wUlF9b0WPJ5LfFLAIqhMI/Gbdt tgjWKvHkSf8pArb31OjWu2PGjTRs8RsKXqBXqExJdkcA2+y4pJLC6iSMnWsToOj8WBaT QdslswWKkTMPW5/RBwy9nZ3bZ1FciT60MSIBXKj2rDhkDX0GyxeXBeiijQuc5clJPu4T YEM5vCzhkAObzXAamyehjZm1rIaypFsrr7APLlhloJyNk850VC8/+DL6Ei9F0xSstndU Uv3wtmIjKETN5sIyjLdXWjxcF9uqT6XLeFs7SO0bDHvrCnCrl+7q6Cvdgfy6SiDD6V+A Vlyg== X-Gm-Message-State: AOAM533apUaIOvtcTAJAt+rtdwk9BE+bY2QTZn8+rME9NspSMtWt5kZn 4ziJbeO0porLzw5wAKyBC7pM8VEpS0mdPcQi+3ZK X-Received: by 2002:a50:ff01:: with SMTP id a1mr19688860edu.253.1625540668739; Mon, 05 Jul 2021 20:04:28 -0700 (PDT) MIME-Version: 1.0 References: <20210615141331.407-1-xieyongji@bytedance.com> <20210615141331.407-11-xieyongji@bytedance.com> <8320d26d-6637-85c6-8773-49553dfa502d@redhat.com> In-Reply-To: From: Yongji Xie Date: Tue, 6 Jul 2021 11:04:18 +0800 Message-ID: Subject: Re: [PATCH v8 10/10] Documentation: Add documentation for VDUSE To: Stefan Hajnoczi Cc: Jason Wang , "Michael S. Tsirkin" , Stefano Garzarella , Parav Pandit , Christoph Hellwig , Christian Brauner , Randy Dunlap , Matthew Wilcox , Al Viro , Jens Axboe , bcrl@kvack.org, Jonathan Corbet , =?UTF-8?Q?Mika_Penttil=C3=A4?= , Dan Carpenter , joro@8bytes.org, Greg KH , songmuchun@bytedance.com, virtualization , netdev@vger.kernel.org, kvm , linux-fsdevel@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 5, 2021 at 8:50 PM Stefan Hajnoczi wrote: > > On Mon, Jul 05, 2021 at 11:36:15AM +0800, Jason Wang wrote: > > > > =E5=9C=A8 2021/7/4 =E4=B8=8B=E5=8D=885:49, Yongji Xie =E5=86=99=E9=81= =93: > > > > > OK, I get you now. Since the VIRTIO specification says "Device > > > > > configuration space is generally used for rarely-changing or > > > > > initialization-time parameters". I assume the VDUSE_DEV_SET_CONFI= G > > > > > ioctl should not be called frequently. > > > > The spec uses MUST and other terms to define the precise requiremen= ts. > > > > Here the language (especially the word "generally") is weaker and m= eans > > > > there may be exceptions. > > > > > > > > Another type of access that doesn't work with the VDUSE_DEV_SET_CON= FIG > > > > approach is reads that have side-effects. For example, imagine a fi= eld > > > > containing an error code if the device encounters a problem unrelat= ed to > > > > a specific virtqueue request. Reading from this field resets the er= ror > > > > code to 0, saving the driver an extra configuration space write acc= ess > > > > and possibly race conditions. It isn't possible to implement those > > > > semantics suing VDUSE_DEV_SET_CONFIG. It's another corner case, but= it > > > > makes me think that the interface does not allow full VIRTIO semant= ics. > > > > > > Note that though you're correct, my understanding is that config space = is > > not suitable for this kind of error propagating. And it would be very h= ard > > to implement such kind of semantic in some transports. Virtqueue shoul= d be > > much better. As Yong Ji quoted, the config space is used for > > "rarely-changing or intialization-time parameters". > > > > > > > Agreed. I will use VDUSE_DEV_GET_CONFIG in the next version. And to > > > handle the message failure, I'm going to add a return value to > > > virtio_config_ops.get() and virtio_cread_* API so that the error can > > > be propagated to the virtio device driver. Then the virtio-blk device > > > driver can be modified to handle that. > > > > > > Jason and Stefan, what do you think of this way? > > Why does VDUSE_DEV_GET_CONFIG need to support an error return value? > We add a timeout and return error in case userspace never replies to the message. > The VIRTIO spec provides no way for the device to report errors from > config space accesses. > > The QEMU virtio-pci implementation returns -1 from invalid > virtio_config_read*() and silently discards virtio_config_write*() > accesses. > > VDUSE can take the same approach with > VDUSE_DEV_GET_CONFIG/VDUSE_DEV_SET_CONFIG. > I noticed that virtio_config_read*() only returns -1 when we access a invalid field. But in the VDUSE case, VDUSE_DEV_GET_CONFIG might fail when we access a valid field. Not sure if it's ok to silently ignore this kind of error. Thanks, Yongji