Received: by 2002:ac8:6d01:0:b0:423:7e07:f8e4 with SMTP id o1csp6636507qtt; Mon, 18 Dec 2023 02:17:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IGRisQij1wxxofiHlhTcirlTqN6B+Nvtfcx0g1Y7sZmJfpvs8G15WWzBX9Hgpswpujpge7l X-Received: by 2002:a05:6358:2612:b0:16b:ac8e:c5f3 with SMTP id l18-20020a056358261200b0016bac8ec5f3mr21851047rwc.14.1702894673524; Mon, 18 Dec 2023 02:17:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702894673; cv=none; d=google.com; s=arc-20160816; b=XOTFk91jyRX+jpPQleVUu9x5dp6GmtTurEDkzne0k8zHLOExdzr25M9vNq4SuBBVUQ 9UNcnmU1FFWDb1BqnJrNJIWUg+IGpoFb0WfLybXndxXG/5VkAXatSvQymIStGBPuL7Vj pUf5t9zitlqg6VjgF5C4LEFAXEtPViihjki4whgMfg6nPJfaCOSagoXWDGHE7iV8dIzm c284Is1/do4FJ21Q35+jqruOgRAZvctj3wpYvdAiOeoZ4CSVOuQNIgFymt2DGphOWROu fwJVJs+B0Zl571s1yuNDMsXEkfzj6EZNPO21Kssbn4wIQFwvrStm4gKSr0hGJ41MH31n QkaA== 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=gH0iS7BjEOS5zAUICFnmkcxpbHOvpwgXq3uX0FBf858=; fh=Qn4BYfmKXpn0+APoj6NrYc5S+prPMNdenF6npFSyP60=; b=GsLnLptQ9yF1OSKyXrwA/YzAjNrhS5JltMzH4y2yE+1O1/P6o8t78BhCkrfszyp1YG jfh/02f+PlatU/6HJaxIh+nR6QZomT9u2S08cgyO00t2fP/iUL/1uNAtSoQTOvNQO1dF 3BdgKD6gk7ez4ZpjlTtrW2UMeSxkIVO+LaicFp7WCxrYo/+X7MUK6KwgNTw0b+dFwLxe YPN7i1tOlWk9pM6Vquj1WTmWaY/MuF/nalo7KPvn35c23GbdUEDezPKsaANaMpX7FYUF CHQWwMWkVn3hk67WHNpRtBY89ccOrM3tUwgKVJMOYM/eJ/buYK2Gy5vje4NIMhTuxMW7 zsLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZgjV86i4; spf=pass (google.com: domain of linux-kernel+bounces-3311-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3311-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 bx2-20020a056a02050200b005bdfb8a9048si18543245pgb.67.2023.12.18.02.17.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 02:17:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-3311-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=ZgjV86i4; spf=pass (google.com: domain of linux-kernel+bounces-3311-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3311-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 3715A281AC3 for ; Mon, 18 Dec 2023 10:17:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0FDF313FFF; Mon, 18 Dec 2023 10:17:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZgjV86i4" 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 5AB14134DA for ; Mon, 18 Dec 2023 10:17:38 +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=1702894657; 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=gH0iS7BjEOS5zAUICFnmkcxpbHOvpwgXq3uX0FBf858=; b=ZgjV86i4cBbzYNfGt17HK8O/2WQywvAN5b4dSQtbZYqhoMaZFYle7iBy5D1r/g7bnwpbTt Vp+y0T8mXJKrp76Ok70WFHxnQixc0IFEYtNpXzdcpM0gnF8VqPB8CKk1bU3ak7YHOi/AOt f/lfW8TiWFKzv9k7LcznHLh7gkuL4Pk= 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-655-OU-SKVeCPZCcJyX1B71G-Q-1; Mon, 18 Dec 2023 05:17:34 -0500 X-MC-Unique: OU-SKVeCPZCcJyX1B71G-Q-1 Received: by mail-yb1-f200.google.com with SMTP id 3f1490d57ef6-db402e6f61dso2730544276.3 for ; Mon, 18 Dec 2023 02:17:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702894653; x=1703499453; 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=gH0iS7BjEOS5zAUICFnmkcxpbHOvpwgXq3uX0FBf858=; b=GJBtI/nIlWqNvYrvY/pVIjoy6FvrPEOZOwDNbyD/Hn38SVo4or0tiJrMeTcIIWxxYi dmEIezFqxcbnpk5K0dles35eJ1YvfTCa/FbFPaPjinCU8Royv8r19+EjEzD9vY+t7hdf Ujqn3tn9ahKRkG7BbXjnSqjlVbQFrP9fhhmF9WQKFSoqE+sIsr67uBhCqk4g3Zln8J2P pdR7uYtF+ml06+NUMRNqQatcKQi2o/S+010HFu9ywImhivmQaLsLrz0oqlagy6BdjLn2 5XfLmg1F6nnQenTn8pvhh9lXTiUDAiNhJw4sw2ud6d1JRry0LtduDhIomdNbfXZYdVqK wFCA== X-Gm-Message-State: AOJu0Yx4mZRlN2g/kEYYB4+igQ0nAoPwwIZGH527xqfeRPvBtUpm36/S NMkZH3XwyNCptzpmEKehA6PhXI66+LMQxSHORjq2znUch148ZvGHg87U8S1G2nYLZLKP1esr19Y ytz9me1UxMh9GsOWAYgwAHntvSOHxwLSWGRQd7RI1 X-Received: by 2002:a05:6902:2412:b0:dbd:13cc:530a with SMTP id dr18-20020a056902241200b00dbd13cc530amr897287ybb.117.1702894653359; Mon, 18 Dec 2023 02:17:33 -0800 (PST) X-Received: by 2002:a05:6902:2412:b0:dbd:13cc:530a with SMTP id dr18-20020a056902241200b00dbd13cc530amr897273ybb.117.1702894652982; Mon, 18 Dec 2023 02:17:32 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231205104609.876194-1-dtatulea@nvidia.com> <20231205104609.876194-5-dtatulea@nvidia.com> <27312106-07b9-4719-970c-b8e1aed7c4eb@oracle.com> <075cf7d1ada0ee4ee30d46b993a1fe21acfe9d92.camel@nvidia.com> <20231214084526-mutt-send-email-mst@kernel.org> <9a6465a3d6c8fde63643fbbdde60d5dd84b921d4.camel@nvidia.com> <9c387650e7c22118370fa0fe3588ee009ce56f11.camel@nvidia.com> <0bfb42ee1248b82eaedd88bdc9e97e83919f2405.camel@nvidia.com> <161c7e63d9c7f64afc959b1ea4a068ee2ddafa6c.camel@nvidia.com> In-Reply-To: <161c7e63d9c7f64afc959b1ea4a068ee2ddafa6c.camel@nvidia.com> From: Eugenio Perez Martin Date: Mon, 18 Dec 2023 11:16:56 +0100 Message-ID: Subject: Re: [PATCH vhost v2 4/8] vdpa/mlx5: Mark vq addrs for modification in hw vq 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" , "mst@redhat.com" , Saeed Mahameed , "jasowang@redhat.com" , "leon@kernel.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Dec 16, 2023 at 12:03=E2=80=AFPM Dragos Tatulea wrote: > > On Fri, 2023-12-15 at 18:56 +0100, Eugenio Perez Martin wrote: > > On Fri, Dec 15, 2023 at 3:13=E2=80=AFPM Dragos Tatulea wrote: > > > > > > On Fri, 2023-12-15 at 12:35 +0000, Dragos Tatulea wrote: > > > > On Thu, 2023-12-14 at 19:30 +0100, Eugenio Perez Martin wrote: > > > > > On Thu, Dec 14, 2023 at 4:51=E2=80=AFPM Dragos Tatulea wrote: > > > > > > > > > > > > On Thu, 2023-12-14 at 08:45 -0500, Michael S. Tsirkin wrote: > > > > > > > On Thu, Dec 14, 2023 at 01:39:55PM +0000, Dragos Tatulea wrot= e: > > > > > > > > On Tue, 2023-12-12 at 15:44 -0800, Si-Wei Liu wrote: > > > > > > > > > > > > > > > > > > On 12/12/2023 11:21 AM, Eugenio Perez Martin wrote: > > > > > > > > > > On Tue, Dec 5, 2023 at 11:46=E2=80=AFAM Dragos Tatulea = wrote: > > > > > > > > > > > Addresses get set by .set_vq_address. hw vq addresses= will be updated on > > > > > > > > > > > next modify_virtqueue. > > > > > > > > > > > > > > > > > > > > > > Signed-off-by: Dragos Tatulea > > > > > > > > > > > Reviewed-by: Gal Pressman > > > > > > > > > > > Acked-by: Eugenio P=C3=A9rez > > > > > > > > > > I'm kind of ok with this patch and the next one about s= tate, but I > > > > > > > > > > didn't ack them in the previous series. > > > > > > > > > > > > > > > > > > > > My main concern is that it is not valid to change the v= q address after > > > > > > > > > > DRIVER_OK in VirtIO, which vDPA follows. Only memory ma= ps are ok to > > > > > > > > > > change at this moment. I'm not sure about vq state in v= DPA, but vhost > > > > > > > > > > forbids changing it with an active backend. > > > > > > > > > > > > > > > > > > > > Suspend is not defined in VirtIO at this moment though,= so maybe it is > > > > > > > > > > ok to decide that all of these parameters may change du= ring suspend. > > > > > > > > > > Maybe the best thing is to protect this with a vDPA fea= ture flag. > > > > > > > > > I think protect with vDPA feature flag could work, while = on the other > > > > > > > > > hand vDPA means vendor specific optimization is possible = around suspend > > > > > > > > > and resume (in case it helps performance), which doesn't = have to be > > > > > > > > > backed by virtio spec. Same applies to vhost user backend= features, > > > > > > > > > variations there were not backed by spec either. Of cours= e, we should > > > > > > > > > try best to make the default behavior backward compatible= with > > > > > > > > > virtio-based backend, but that circles back to no suspend= definition in > > > > > > > > > the current virtio spec, for which I hope we don't cease = development on > > > > > > > > > vDPA indefinitely. After all, the virtio based vdap backe= nd can well > > > > > > > > > define its own feature flag to describe (minor difference= in) the > > > > > > > > > suspend behavior based on the later spec once it is forme= d in future. > > > > > > > > > > > > > > > > > So what is the way forward here? From what I understand the= options are: > > > > > > > > > > > > > > > > 1) Add a vdpa feature flag for changing device properties w= hile suspended. > > > > > > > > > > > > > > > > 2) Drop these 2 patches from the series for now. Not sure i= f this makes sense as > > > > > > > > this. But then Si-Wei's qemu device suspend/resume poc [0] = that exercises this > > > > > > > > code won't work anymore. This means the series would be les= s well tested. > > > > > > > > > > > > > > > > Are there other possible options? What do you think? > > > > > > > > > > > > > > > > [0] https://github.com/siwliu-kernel/qemu/tree/svq-resume-w= ip > > > > > > > > > > > > > > I am fine with either of these. > > > > > > > > > > > > > How about allowing the change only under the following conditio= ns: > > > > > > vhost_vdpa_can_suspend && vhost_vdpa_can_resume && > > > > > > VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK is set > > > > > > > > > > > > ? > > > > > > > > > > I think the best option by far is 1, as there is no hint in the > > > > > combination of these 3 indicating that you can change device > > > > > properties in the suspended state. > > > > > > > > > Sure. Will respin a v3 without these two patches. > > > > > > > > Another series can implement option 2 and add these 2 patches on to= p. > > > Hmm...I misunderstood your statement and sent a erroneus v3. You said= that > > > having a feature flag is the best option. > > > > > > Will add a feature flag in v4: is this similar to the > > > VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK flag? > > > > > > > Right, it should be easy to return it from .get_backend_features op if > > the FW returns that capability, isn't it? > > > Yes, that's easy. But I wonder if we need one feature bit for each type o= f > change: > - VHOST_BACKEND_F_CHANGEABLE_VQ_ADDR_IN_SUSPEND > - VHOST_BACKEND_F_CHANGEABLE_VQ_STATE_IN_SUSPEND > I'd say yes. Although we could configure SVQ initial state in userland as different than 0 for this first step, it would be needed in the long term. > Or would a big one VHOST_BACKEND_F_CAN_RECONFIG_VQ_IN_SUSPEND suffice? > I'd say "reconfig vq" is not valid as mlx driver doesn't allow changing queue sizes, for example, isn't it? To define that it is valid to change "all parameters" seems very confident. > To me having individual feature bits makes sense. But it could also takes= too > many bits if more changes are required. > Yes, that's a good point. Maybe it is valid to define a subset of features that can be changed., but I think it is way clearer to just check for individual feature bits. > Thanks, > Dragos > > > > Thanks, > > > Dragos > > > > > > > > > Thanks, > > > > > > Dragos > > > > > > > > > > > > > > Thanks, > > > > > > > > Dragos > > > > > > > > > > > > > > > > > Regards, > > > > > > > > > -Siwei > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Jason, what do you think? > > > > > > > > > > > > > > > > > > > > Thanks! > > > > > > > > > > > > > > > > > > > > > --- > > > > > > > > > > > drivers/vdpa/mlx5/net/mlx5_vnet.c | 9 +++++++++ > > > > > > > > > > > include/linux/mlx5/mlx5_ifc_vdpa.h | 1 + > > > > > > > > > > > 2 files changed, 10 insertions(+) > > > > > > > > > > > > > > > > > > > > > > diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/driv= ers/vdpa/mlx5/net/mlx5_vnet.c > > > > > > > > > > > index f8f088cced50..80e066de0866 100644 > > > > > > > > > > > --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c > > > > > > > > > > > +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c > > > > > > > > > > > @@ -1209,6 +1209,7 @@ static int modify_virtqueue(str= uct mlx5_vdpa_net *ndev, > > > > > > > > > > > bool state_change =3D false; > > > > > > > > > > > void *obj_context; > > > > > > > > > > > void *cmd_hdr; > > > > > > > > > > > + void *vq_ctx; > > > > > > > > > > > void *in; > > > > > > > > > > > int err; > > > > > > > > > > > > > > > > > > > > > > @@ -1230,6 +1231,7 @@ static int modify_virtqueue(str= uct mlx5_vdpa_net *ndev, > > > > > > > > > > > MLX5_SET(general_obj_in_cmd_hdr, cmd_hdr, ui= d, ndev->mvdev.res.uid); > > > > > > > > > > > > > > > > > > > > > > obj_context =3D MLX5_ADDR_OF(modify_virtio_n= et_q_in, in, obj_context); > > > > > > > > > > > + vq_ctx =3D MLX5_ADDR_OF(virtio_net_q_object, = obj_context, virtio_q_context); > > > > > > > > > > > > > > > > > > > > > > if (mvq->modified_fields & MLX5_VIRTQ_MODIFY= _MASK_STATE) { > > > > > > > > > > > if (!is_valid_state_change(mvq->fw_s= tate, state, is_resumable(ndev))) { > > > > > > > > > > > @@ -1241,6 +1243,12 @@ static int modify_virtqueue(st= ruct mlx5_vdpa_net *ndev, > > > > > > > > > > > state_change =3D true; > > > > > > > > > > > } > > > > > > > > > > > > > > > > > > > > > > + if (mvq->modified_fields & MLX5_VIRTQ_MODIFY_= MASK_VIRTIO_Q_ADDRS) { > > > > > > > > > > > + MLX5_SET64(virtio_q, vq_ctx, desc_add= r, mvq->desc_addr); > > > > > > > > > > > + MLX5_SET64(virtio_q, vq_ctx, used_add= r, mvq->device_addr); > > > > > > > > > > > + MLX5_SET64(virtio_q, vq_ctx, availabl= e_addr, mvq->driver_addr); > > > > > > > > > > > + } > > > > > > > > > > > + > > > > > > > > > > > MLX5_SET64(virtio_net_q_object, obj_context,= modify_field_select, mvq->modified_fields); > > > > > > > > > > > err =3D mlx5_cmd_exec(ndev->mvdev.mdev, in, = inlen, out, sizeof(out)); > > > > > > > > > > > if (err) > > > > > > > > > > > @@ -2202,6 +2210,7 @@ static int mlx5_vdpa_set_vq_add= ress(struct vdpa_device *vdev, u16 idx, u64 desc_ > > > > > > > > > > > mvq->desc_addr =3D desc_area; > > > > > > > > > > > mvq->device_addr =3D device_area; > > > > > > > > > > > mvq->driver_addr =3D driver_area; > > > > > > > > > > > + mvq->modified_fields |=3D MLX5_VIRTQ_MODIFY_M= ASK_VIRTIO_Q_ADDRS; > > > > > > > > > > > return 0; > > > > > > > > > > > } > > > > > > > > > > > > > > > > > > > > > > diff --git a/include/linux/mlx5/mlx5_ifc_vdpa.h b/inc= lude/linux/mlx5/mlx5_ifc_vdpa.h > > > > > > > > > > > index b86d51a855f6..9594ac405740 100644 > > > > > > > > > > > --- a/include/linux/mlx5/mlx5_ifc_vdpa.h > > > > > > > > > > > +++ b/include/linux/mlx5/mlx5_ifc_vdpa.h > > > > > > > > > > > @@ -145,6 +145,7 @@ enum { > > > > > > > > > > > MLX5_VIRTQ_MODIFY_MASK_STATE = =3D (u64)1 << 0, > > > > > > > > > > > MLX5_VIRTQ_MODIFY_MASK_DIRTY_BITMAP_PARAMS = =3D (u64)1 << 3, > > > > > > > > > > > MLX5_VIRTQ_MODIFY_MASK_DIRTY_BITMAP_DUMP_ENA= BLE =3D (u64)1 << 4, > > > > > > > > > > > + MLX5_VIRTQ_MODIFY_MASK_VIRTIO_Q_ADDRS = =3D (u64)1 << 6, > > > > > > > > > > > MLX5_VIRTQ_MODIFY_MASK_DESC_GROUP_MKEY = =3D (u64)1 << 14, > > > > > > > > > > > }; > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > > > > > > 2.42.0 > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >