Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp199435rdb; Thu, 21 Dec 2023 06:57:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IHxlacnHtxa640G5FC9j1hEniqVF0Woyzaz1wzakDWHzNx1E/PHoyngEF1VA/1QvxSDrRbl X-Received: by 2002:a05:6e02:1c49:b0:35d:66a0:5432 with SMTP id d9-20020a056e021c4900b0035d66a05432mr35665779ilg.13.1703170652496; Thu, 21 Dec 2023 06:57:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703170652; cv=none; d=google.com; s=arc-20160816; b=fefgcyqU878U+Cv2ua7JFQgAo1+RVm8aLgEpdh9TC+jf2B/fT37Tb354GNFr9/Ddyr ZfVBTPNK1cWLQTOznObaBfpStPmX5k/rLJQVfj1s1ig0IYwAcz0/fqJ66HnKuDLXX/8o 0aIUg15Twue0ElwasG6fzbceL4b2l3LmD2+Cms8AsT9z34EDCZIgNT2ySNQNFDEF9JLB 7l1KcbZnts+QwIG4aod9EU8BhFI7qSDCmr1nkGsoM/iZ5uNsgb5CPwv9HVvAc9oiklR0 OfHXAS6xxJKa5+G3KDNaDtfVo+qyfW1qFMM4cWWO1P9aXj/ybIX5ixJgq+3gaCZCwr4/ bwCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=B8eIz4f9p7CSrHkPxbwx9C5GZwRnjE0R1lz9iIAHGRA=; fh=K4UNA2LVVRF+WlG/isOSicW4UkFZ3Mog+SoVLsnBtZk=; b=IXrU6kxDTrvbPwyWxrrsod+x3X/LiaxgKGZg6L+pwX0VdujUGzUakSeVMiPpcaG/fs E5OTi4hjFQjzI9+iG/JRbPYLQ/EID4R1PRnhh+/cf2jblyxWAvVUYELA6WLcuZrLihXJ LLlKencUoboDkzyAyUGR2/XfRTUErkWvlBswRZNCTjDhkZI3zd1ExCjmaDe3gnzru80p Sb7dKMhxn45KQyaNUw+uzBR94xLIKINseLgfFMRMtgrTopOJOS8FWZ7fJ2aUptcomwBV hx4zDzswIlGpN8zYvZl6J36GxRMBfGVfh7EMeKjzUIOta9X+NHiOkIe+g4v9mXWO6lX9 W1BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hWkPBdTx; spf=pass (google.com: domain of linux-kernel+bounces-8599-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8599-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id c1-20020a654201000000b005cde1b97cc7si1713167pgq.253.2023.12.21.06.57.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 06:57:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8599-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hWkPBdTx; spf=pass (google.com: domain of linux-kernel+bounces-8599-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8599-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 257C4288B7F for ; Thu, 21 Dec 2023 14:57:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2F75C46438; Thu, 21 Dec 2023 14:56:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hWkPBdTx" X-Original-To: linux-kernel@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD1564B13D for ; Thu, 21 Dec 2023 14:56:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703170580; 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: in-reply-to:in-reply-to:references:references; bh=B8eIz4f9p7CSrHkPxbwx9C5GZwRnjE0R1lz9iIAHGRA=; b=hWkPBdTxnyrRNpryCJHQJthAYlNj2Y4mqiy35XJDucZrxvaFOSx0O2wr5baYghHY+Ty697 pxKPMc2oqaV+MV1kPJBGYuAaYkPhcrgIECDraE/5l8dYzKCNOAqcctW3O7A5xLHesA+3+D PcLkFTvZLTAQwXjE5ZJTHczLO6LGiGE= Received: from mail-yb1-f200.google.com (mail-yb1-f200.google.com [209.85.219.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-313-aJm-suPgMrOuIqi5dRh9gA-1; Thu, 21 Dec 2023 09:56:15 -0500 X-MC-Unique: aJm-suPgMrOuIqi5dRh9gA-1 Received: by mail-yb1-f200.google.com with SMTP id 3f1490d57ef6-dbdd300d01bso205752276.3 for ; Thu, 21 Dec 2023 06:56:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703170575; x=1703775375; h=content-transfer-encoding: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=B8eIz4f9p7CSrHkPxbwx9C5GZwRnjE0R1lz9iIAHGRA=; b=Fe2saWMYwOuLmE5Bvw+eRfgdyrQkmQg27YGWiGw7yTPKVui9DgVWP6hazDYyoy/nOj 2GqFnGbMR/pJI2t83t6I3YYDZgk5xwgesNbWWWwiNl+iV2BtMMkDd4q7/hXaHQlZaFdi GZoST/iaEmLFZ/t6pf6rtZlTmWpWUJcWpzwze4T/AKbH3ZnwIDdNIva7HGEQLGPvC3GH MYh82nhpcjdlyliZYvh6OMRThVOfaEsOwaCC/u252KRilRWeaU1/oppj+WAtNi0zhMlk OltPA0Zkx0YD3cCmYCenEzTU2w1DvE+ztawUpnPVWnZcIcOZoU6SSAUDaxhYottgNQwY pnSg== X-Gm-Message-State: AOJu0YzsHrrXLp/gVj/ZLblySHfJnTKdw4NhTyQW0VWGgHrv9alPd864 uHvrUsMM9bD4xYphskWaCV6vnJzOcNp1ZZl5QFr/+YwJ5VOhbboJH0jer7kYNPEVlncdC7r6Ean Vbv7yUuwTQLkHWmswxUIFXBvEeuRq71HMnPV+2hMU X-Received: by 2002:a25:d88b:0:b0:dbd:11:5dee with SMTP id p133-20020a25d88b000000b00dbd00115deemr1311070ybg.37.1703170575142; Thu, 21 Dec 2023 06:56:15 -0800 (PST) X-Received: by 2002:a25:d88b:0:b0:dbd:11:5dee with SMTP id p133-20020a25d88b000000b00dbd00115deemr1311052ybg.37.1703170574842; Thu, 21 Dec 2023 06:56:14 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231219180858.120898-1-dtatulea@nvidia.com> <20231219180858.120898-3-dtatulea@nvidia.com> <70adc734331c1289dceb3bcdc991f3da7e4db2f0.camel@nvidia.com> In-Reply-To: From: Eugenio Perez Martin Date: Thu, 21 Dec 2023 15:55:38 +0100 Message-ID: Subject: Re: [PATCH vhost v4 02/15] vdpa: Add VHOST_BACKEND_F_CHANGEABLE_VQ_ADDR_IN_SUSPEND flag To: Dragos Tatulea Cc: "xuanzhuo@linux.alibaba.com" , Parav Pandit , Gal Pressman , "virtualization@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" , "si-wei.liu@oracle.com" , "kvm@vger.kernel.org" , "jasowang@redhat.com" , Saeed Mahameed , "mst@redhat.com" , "leon@kernel.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Dec 21, 2023 at 3:38=E2=80=AFPM Dragos Tatulea wrote: > > On Thu, 2023-12-21 at 13:08 +0100, Eugenio Perez Martin wrote: > > On Thu, Dec 21, 2023 at 12:52=E2=80=AFPM Dragos Tatulea wrote: > > > > > > On Thu, 2023-12-21 at 08:46 +0100, Eugenio Perez Martin wrote: > > > > On Thu, Dec 21, 2023 at 3:03=E2=80=AFAM Jason Wang wrote: > > > > > > > > > > On Wed, Dec 20, 2023 at 9:32=E2=80=AFPM Eugenio Perez Martin > > > > > wrote: > > > > > > > > > > > > On Wed, Dec 20, 2023 at 5:06=E2=80=AFAM Jason Wang wrote: > > > > > > > > > > > > > > On Wed, Dec 20, 2023 at 11:46=E2=80=AFAM Jason Wang wrote: > > > > > > > > > > > > > > > > On Wed, Dec 20, 2023 at 2:09=E2=80=AFAM Dragos Tatulea wrote: > > > > > > > > > > > > > > > > > > The virtio spec doesn't allow changing virtqueue addresse= s after > > > > > > > > > DRIVER_OK. Some devices do support this operation when th= e device is > > > > > > > > > suspended. The VHOST_BACKEND_F_CHANGEABLE_VQ_ADDR_IN_SUSP= END flag > > > > > > > > > advertises this support as a backend features. > > > > > > > > > > > > > > > > There's an ongoing effort in virtio spec to introduce the s= uspend state. > > > > > > > > > > > > > > > > So I wonder if it's better to just allow such behaviour? > > > > > > > > > > > > > > Actually I mean, allow drivers to modify the parameters durin= g suspend > > > > > > > without a new feature. > > > > > > > > > > > > > > > > > > > That would be ideal, but how do userland checks if it can suspe= nd + > > > > > > change properties + resume? > > > > > > > > > > As discussed, it looks to me the only device that supports suspen= d is > > > > > simulator and it supports change properties. > > > > > > > > > > E.g: > > > > > > > > > > static int vdpasim_set_vq_address(struct vdpa_device *vdpa, u16 i= dx, > > > > > u64 desc_area, u64 driver_area, > > > > > u64 device_area) > > > > > { > > > > > struct vdpasim *vdpasim =3D vdpa_to_sim(vdpa); > > > > > struct vdpasim_virtqueue *vq =3D &vdpasim->vqs[idx]; > > > > > > > > > > vq->desc_addr =3D desc_area; > > > > > vq->driver_addr =3D driver_area; > > > > > vq->device_addr =3D device_area; > > > > > > > > > > return 0; > > > > > } > > > > > > > > > > > > > So in the current kernel master it is valid to set a different vq > > > > address while the device is suspended in vdpa_sim. But it is not va= lid > > > > in mlx5, as the FW will not be updated in resume (Dragos, please > > > > correct me if I'm wrong). Both of them return success. > > > > > > > In the current state, there is no resume. HW Virtqueues will just get= re-created > > > with the new address. > > > > > > > Oh, then all of this is effectively transparent to the userspace > > except for the time it takes? > > > Not quite: mlx5_vdpa_set_vq_address will save the vq address only on the = SW vq > representation. Only later will it will call into the FW to update the FW= . Later > means: > - On DRIVER_OK state, when the VQs get created. > - On .set_map when the VQs get re-created (before this series) / updated = (after > this series) > - On .resume (after this series). > > So if the .set_vq_address is called when the VQ is in DRIVER_OK but not > suspended those addresses will be set later for later. > Ouch, that is more in the line of my thoughts :(. > > In that case you're right, we don't need feature flags. But I think it > > would be great to also move the error return in case userspace tries > > to modify vq parameters out of suspend state. > > > On the driver side or on the core side? > Core side. It does not have to be part of this series, I meant it can be proposed in a separate series and applied before the parent driver one. > Thanks > > Thanks! > > > > > > > > How can we know in the destination QEMU if it is valid to suspend & > > > > set address? Should we handle this as a bugfix and backport the > > > > change? > > > > > > > > > > > > > > > > The only way that comes to my mind is to make sure all parents = return > > > > > > error if userland tries to do it, and then fallback in userland= . > > > > > > > > > > Yes. > > > > > > > > > > > I'm > > > > > > ok with that, but I'm not sure if the current master & previous= kernel > > > > > > has a coherent behavior. Do they return error? Or return succes= s > > > > > > without changing address / vq state? > > > > > > > > > > We probably don't need to worry too much here, as e.g set_vq_addr= ess > > > > > could fail even without suspend (just at uAPI level). > > > > > > > > > > > > > I don't get this, sorry. I rephrased my point with an example earli= er > > > > in the mail. > > > > > > > > > >