Message ID | 20230203142501.300125-1-eperezma@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp869699wrn; Fri, 3 Feb 2023 06:30:31 -0800 (PST) X-Google-Smtp-Source: AK7set9m6xWPrOkqzBiqTmjVqpI5wh+vM/Zbx7VC9amf0LaE9bompIH2N8CoFzAbp5do24062dUO X-Received: by 2002:a05:6a20:8c05:b0:b6:9c33:c3c1 with SMTP id j5-20020a056a208c0500b000b69c33c3c1mr9688002pzh.10.1675434631685; Fri, 03 Feb 2023 06:30:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675434631; cv=none; d=google.com; s=arc-20160816; b=yr8hudXP6Amy6pnkEhhQhoqzSSpdO7zMIfDqV7CYnSCdSeV6+8ZuPaQr0U4h+pST1E hmSeBQFEicgYEK0Z3ZxWmPqMJnfsX+UmbVcLmyvtoSxtsoYrnUO3S65xhxXJ85UBd/Sa FAOkyAyxSpFIhcWIB+mi29a5gC2JQpKU8lYAhS6xVV5Kv2rhYQxZfqIuXdhXRey55FW3 f2fPXuFRj+I7MOeKpS/PmHhJU0nHzLwh+5HNnfOvIlSDORoP4m4RWo19zPDK+sEzUktO sIlisQmlUTw6FsK8GOCMARZGN3Y5K9vM1MdON1zP3Qx3nTTELkjO5ES6J0lJb5i/HpjR WN4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=9N2hOTys/+lGMc2Icse9u7NTCoYhCX2MBJqWpddTKDI=; b=eR5JcelrK7LUeN9V7zaKlu4oP2UkM9DWtDbOFEJ/8bKSIdMsAb17oousqNXgnqruDw c7SGHie20DbU+1RBnQvOBgsSx9AM0uwNsnfMwYehr8dMye7QUm0Ezfu2UkRFy006Si5g cW9pJ3zenYFC708wGWw2aTe1gvHwzQ0wp/3yedMy6EA+9u/FAZZ7CjlG6PguD2zfNa7i qCzjog2W8NBAB2Z//m37gqlMGP+OXolO43irxSQLM3OUoOacyiVKAXls6Y3lXyBgvkl4 eF3kJLJ2AxALvcRKfabA7jahOEfrE3d7l4dKbvPLeZPg8X60g3ucUhde6fEJDW2kgaqU 3Zyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AAdkG8Ir; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bw23-20020a056a00409700b0058dada4ac9esi2652404pfb.251.2023.02.03.06.30.17; Fri, 03 Feb 2023 06:30:31 -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=AAdkG8Ir; 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 S232633AbjBCO0D (ORCPT <rfc822;il.mystafa@gmail.com> + 99 others); Fri, 3 Feb 2023 09:26:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232736AbjBCOZ5 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 3 Feb 2023 09:25:57 -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 74AE323304 for <linux-kernel@vger.kernel.org>; Fri, 3 Feb 2023 06:25:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675434309; 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=9N2hOTys/+lGMc2Icse9u7NTCoYhCX2MBJqWpddTKDI=; b=AAdkG8IrAuQkb1JviOzELj/QI1oGtvYoTuypHi89t+lxgSsB/30wZxjh7pK6/pDgddROmf UiztBOwvWOlzA0JcUgLFkcYGG9ER2tAX0CLhrcLuq8YRe9uTdOTXxY/6tG5m32GYuVwuxW Llb5tWZaNWP/q6B0CmFksQFJdLWEdbs= 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-44-Zt1xpZnCO8i2hEkM63CUWA-1; Fri, 03 Feb 2023 09:25:06 -0500 X-MC-Unique: Zt1xpZnCO8i2hEkM63CUWA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EC29C802314; Fri, 3 Feb 2023 14:25:05 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD6172026D37; Fri, 3 Feb 2023 14:25:02 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= <eperezma@redhat.com> To: mst@redhat.com Cc: lulu@redhat.com, virtualization@lists.linux-foundation.org, si-wei.liu@oracle.com, leiyang@redhat.com, Gautam Dawar <gdawar@xilinx.com>, Eli Cohen <elic@nvidia.com>, longpeng2@huawei.com, parav@nvidia.com, linux-kernel@vger.kernel.org, sgarzare@redhat.com, Zhu Lingshan <lingshan.zhu@intel.com>, alvaro.karsz@solid-run.com, Laurent Vivier <lvivier@redhat.com> Subject: [PATCH v2] vdpa_sim: set last_used_idx as last_avail_idx in vdpasim_queue_ready Date: Fri, 3 Feb 2023 15:25:01 +0100 Message-Id: <20230203142501.300125-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756819766620056874?= X-GMAIL-MSGID: =?utf-8?q?1756820544255423065?= |
Series |
[v2] vdpa_sim: set last_used_idx as last_avail_idx in vdpasim_queue_ready
|
|
Commit Message
Eugenio Perez Martin
Feb. 3, 2023, 2:25 p.m. UTC
Starting from an used_idx different than 0 is needed in use cases like
virtual machine migration. Not doing so and letting the caller set an
avail idx different than 0 causes destination device to try to use old
buffers that source driver already recover and are not available
anymore.
Since vdpa_sim does not support receive inflight descriptors as a
destination of a migration, let's set both avail_idx and used_idx the
same at vq start. This is how vhost-user works in a
VHOST_SET_VRING_BASE call.
Although the simple fix is to set last_used_idx at vdpasim_set_vq_state,
it would be reset at vdpasim_queue_ready. The last_avail_idx case is
fixed with commit a09f493c ("vdpa_sim: not reset state in
vdpasim_queue_ready"). Since the only option is to make it equal to
last_avail_idx, adding the only change needed here.
This was discovered and tested live migrating the vdpa_sim_net device.
Fixes: 2c53d0f64c06 ("vdpasim: vDPA device simulator")
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
Cherry-picked from patch 2/2 of the series [1]. Differences are:
* Set the value of used_idx at vdpasim_queue_ready instead of fetching
from the guest vring like vhost-kernel.
v2: Actually update last_used_idx only at vdpasim_queue_ready.
Note that commit id present in the patch text is not in master but in
git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git.
[1] https://lkml.org/lkml/2023/1/18/1041
---
drivers/vdpa/vdpa_sim/vdpa_sim.c | 1 +
1 file changed, 1 insertion(+)
Comments
On Fri, Feb 03, 2023 at 03:25:01PM +0100, Eugenio Pérez wrote: >Starting from an used_idx different than 0 is needed in use cases like >virtual machine migration. Not doing so and letting the caller set an >avail idx different than 0 causes destination device to try to use old >buffers that source driver already recover and are not available >anymore. > >Since vdpa_sim does not support receive inflight descriptors as a >destination of a migration, let's set both avail_idx and used_idx the >same at vq start. This is how vhost-user works in a >VHOST_SET_VRING_BASE call. > >Although the simple fix is to set last_used_idx at vdpasim_set_vq_state, >it would be reset at vdpasim_queue_ready. The last_avail_idx case is >fixed with commit a09f493c ("vdpa_sim: not reset state in >vdpasim_queue_ready"). Since the only option is to make it equal to >last_avail_idx, adding the only change needed here. > >This was discovered and tested live migrating the vdpa_sim_net device. > >Fixes: 2c53d0f64c06 ("vdpasim: vDPA device simulator") >Signed-off-by: Eugenio Pérez <eperezma@redhat.com> >--- >Cherry-picked from patch 2/2 of the series [1]. Differences are: >* Set the value of used_idx at vdpasim_queue_ready instead of fetching > from the guest vring like vhost-kernel. > >v2: Actually update last_used_idx only at vdpasim_queue_ready. > >Note that commit id present in the patch text is not in master but in >git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git. > >[1] https://lkml.org/lkml/2023/1/18/1041 >--- > drivers/vdpa/vdpa_sim/vdpa_sim.c | 1 + > 1 file changed, 1 insertion(+) > >diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c >index 6a0a65814626..79ac585e40b9 100644 >--- a/drivers/vdpa/vdpa_sim/vdpa_sim.c >+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c >@@ -68,6 +68,7 @@ static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx) > (uintptr_t)vq->device_addr); > > vq->vring.last_avail_idx = last_avail_idx; >+ vq->vring.last_used_idx = last_avail_idx; > vq->vring.notify = vdpasim_vq_notify; > } > >-- 2.31.1 > If you need to resend, I'd add a comment in the code following the commit description. Anyway, the patch LGTM: Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> Thanks, Stefano
On Fri, Feb 03, 2023 at 03:25:01PM +0100, Eugenio Pérez wrote: > Starting from an used_idx different than 0 is needed in use cases like > virtual machine migration. Not doing so and letting the caller set an > avail idx different than 0 causes destination device to try to use old > buffers that source driver already recover and are not available > anymore. > > Since vdpa_sim does not support receive inflight descriptors as a > destination of a migration, let's set both avail_idx and used_idx the > same at vq start. This is how vhost-user works in a > VHOST_SET_VRING_BASE call. > > Although the simple fix is to set last_used_idx at vdpasim_set_vq_state, > it would be reset at vdpasim_queue_ready. The last_avail_idx case is > fixed with commit a09f493c ("vdpa_sim: not reset state in > vdpasim_queue_ready"). Since the only option is to make it equal to > last_avail_idx, adding the only change needed here. > > This was discovered and tested live migrating the vdpa_sim_net device. > > Fixes: 2c53d0f64c06 ("vdpasim: vDPA device simulator") > Signed-off-by: Eugenio Pérez <eperezma@redhat.com> > --- > Cherry-picked from patch 2/2 of the series [1]. Differences are: > * Set the value of used_idx at vdpasim_queue_ready instead of fetching > from the guest vring like vhost-kernel. > > v2: Actually update last_used_idx only at vdpasim_queue_ready. > > Note that commit id present in the patch text is not in master but in > git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git. > > [1] https://lkml.org/lkml/2023/1/18/1041 Can you post with a fixed hash please? > --- > drivers/vdpa/vdpa_sim/vdpa_sim.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c > index 6a0a65814626..79ac585e40b9 100644 > --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c > +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c > @@ -68,6 +68,7 @@ static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx) > (uintptr_t)vq->device_addr); > > vq->vring.last_avail_idx = last_avail_idx; > + vq->vring.last_used_idx = last_avail_idx; > vq->vring.notify = vdpasim_vq_notify; > } > > -- > 2.31.1
On Tue, Feb 28, 2023 at 11:56 AM Stefano Garzarella <sgarzare@redhat.com> wrote: > > On Fri, Feb 03, 2023 at 03:25:01PM +0100, Eugenio Pérez wrote: > >Starting from an used_idx different than 0 is needed in use cases like > >virtual machine migration. Not doing so and letting the caller set an > >avail idx different than 0 causes destination device to try to use old > >buffers that source driver already recover and are not available > >anymore. > > > >Since vdpa_sim does not support receive inflight descriptors as a > >destination of a migration, let's set both avail_idx and used_idx the > >same at vq start. This is how vhost-user works in a > >VHOST_SET_VRING_BASE call. > > > >Although the simple fix is to set last_used_idx at vdpasim_set_vq_state, > >it would be reset at vdpasim_queue_ready. The last_avail_idx case is > >fixed with commit a09f493c ("vdpa_sim: not reset state in > >vdpasim_queue_ready"). Since the only option is to make it equal to > >last_avail_idx, adding the only change needed here. > > > >This was discovered and tested live migrating the vdpa_sim_net device. > > > >Fixes: 2c53d0f64c06 ("vdpasim: vDPA device simulator") > >Signed-off-by: Eugenio Pérez <eperezma@redhat.com> > >--- > >Cherry-picked from patch 2/2 of the series [1]. Differences are: > >* Set the value of used_idx at vdpasim_queue_ready instead of fetching > > from the guest vring like vhost-kernel. > > > >v2: Actually update last_used_idx only at vdpasim_queue_ready. > > > >Note that commit id present in the patch text is not in master but in > >git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git. > > > >[1] https://lkml.org/lkml/2023/1/18/1041 > >--- > > drivers/vdpa/vdpa_sim/vdpa_sim.c | 1 + > > 1 file changed, 1 insertion(+) > > > >diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c > >index 6a0a65814626..79ac585e40b9 100644 > >--- a/drivers/vdpa/vdpa_sim/vdpa_sim.c > >+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c > >@@ -68,6 +68,7 @@ static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx) > > (uintptr_t)vq->device_addr); > > > > vq->vring.last_avail_idx = last_avail_idx; > >+ vq->vring.last_used_idx = last_avail_idx; > > vq->vring.notify = vdpasim_vq_notify; > > } > > > >-- 2.31.1 > > > > If you need to resend, I'd add a comment in the code following the > commit description. > > Anyway, the patch LGTM: > > Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> > Added in v3, thanks for the review! > Thanks, > Stefano >
On Tue, Feb 28, 2023 at 1:13 PM Michael S. Tsirkin <mst@redhat.com> wrote: > > On Fri, Feb 03, 2023 at 03:25:01PM +0100, Eugenio Pérez wrote: > > Starting from an used_idx different than 0 is needed in use cases like > > virtual machine migration. Not doing so and letting the caller set an > > avail idx different than 0 causes destination device to try to use old > > buffers that source driver already recover and are not available > > anymore. > > > > Since vdpa_sim does not support receive inflight descriptors as a > > destination of a migration, let's set both avail_idx and used_idx the > > same at vq start. This is how vhost-user works in a > > VHOST_SET_VRING_BASE call. > > > > Although the simple fix is to set last_used_idx at vdpasim_set_vq_state, > > it would be reset at vdpasim_queue_ready. The last_avail_idx case is > > fixed with commit a09f493c ("vdpa_sim: not reset state in > > vdpasim_queue_ready"). Since the only option is to make it equal to > > last_avail_idx, adding the only change needed here. > > > > This was discovered and tested live migrating the vdpa_sim_net device. > > > > Fixes: 2c53d0f64c06 ("vdpasim: vDPA device simulator") > > Signed-off-by: Eugenio Pérez <eperezma@redhat.com> > > --- > > Cherry-picked from patch 2/2 of the series [1]. Differences are: > > * Set the value of used_idx at vdpasim_queue_ready instead of fetching > > from the guest vring like vhost-kernel. > > > > v2: Actually update last_used_idx only at vdpasim_queue_ready. > > > > Note that commit id present in the patch text is not in master but in > > git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git. > > > > [1] https://lkml.org/lkml/2023/1/18/1041 > > > Can you post with a fixed hash please? > Sent v3, please let me know if I need to do further modifications. Thanks! > > --- > > drivers/vdpa/vdpa_sim/vdpa_sim.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c > > index 6a0a65814626..79ac585e40b9 100644 > > --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c > > +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c > > @@ -68,6 +68,7 @@ static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx) > > (uintptr_t)vq->device_addr); > > > > vq->vring.last_avail_idx = last_avail_idx; > > + vq->vring.last_used_idx = last_avail_idx; > > vq->vring.notify = vdpasim_vq_notify; > > } > > > > -- > > 2.31.1 >
diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c index 6a0a65814626..79ac585e40b9 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c @@ -68,6 +68,7 @@ static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx) (uintptr_t)vq->device_addr); vq->vring.last_avail_idx = last_avail_idx; + vq->vring.last_used_idx = last_avail_idx; vq->vring.notify = vdpasim_vq_notify; }