From: Guo Zhi <qtxuning1999@sjtu.edu.cn>
To: eperezma <eperezma@redhat.com>
Cc: jasowang <jasowang@redhat.com>, sgarzare <sgarzare@redhat.com>,
Michael Tsirkin <mst@redhat.com>, netdev <netdev@vger.kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
kvm list <kvm@vger.kernel.org>,
virtualization <virtualization@lists.linux-foundation.org>
Subject: Re: [RFC 3/5] vhost_test: batch used buffer
Date: Tue, 2 Aug 2022 11:08:31 +0800 (CST) [thread overview]
Message-ID: <104238481.4321239.1659409711735.JavaMail.zimbra@sjtu.edu.cn> (raw)
In-Reply-To: <CAJaqyWfgUqdP6mkOUdouvQSst=qc7MOTaigC-EiTg9-gojHqzg@mail.gmail.com>
----- Original Message -----
From: "eperezma" <eperezma@redhat.com>
To: "Guo Zhi" <qtxuning1999@sjtu.edu.cn>
Cc: "jasowang" <jasowang@redhat.com>, "sgarzare" <sgarzare@redhat.com>, "Michael Tsirkin" <mst@redhat.com>, "netdev" <netdev@vger.kernel.org>, "linux-kernel" <linux-kernel@vger.kernel.org>, "kvm list" <kvm@vger.kernel.org>, "virtualization" <virtualization@lists.linux-foundation.org>
Sent: Friday, July 22, 2022 3:12:47 PM
Subject: Re: [RFC 3/5] vhost_test: batch used buffer
On Thu, Jul 21, 2022 at 10:44 AM Guo Zhi <qtxuning1999@sjtu.edu.cn> wrote:
>
> Only add to used ring when a batch a buffer have all been used. And if
> in order feature negotiated, add randomness to the used buffer's order,
> test the ability of vhost to reorder batched buffer.
>
> Signed-off-by: Guo Zhi <qtxuning1999@sjtu.edu.cn>
> ---
> drivers/vhost/test.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/vhost/test.c b/drivers/vhost/test.c
> index bc8e7fb1e..1c9c40c11 100644
> --- a/drivers/vhost/test.c
> +++ b/drivers/vhost/test.c
> @@ -43,6 +43,9 @@ struct vhost_test {
> static void handle_vq(struct vhost_test *n)
> {
> struct vhost_virtqueue *vq = &n->vqs[VHOST_TEST_VQ];
> + struct vring_used_elem *heads = kmalloc(sizeof(*heads)
> + * vq->num, GFP_KERNEL);
> + int batch_idx = 0;
> unsigned out, in;
> int head;
> size_t len, total_len = 0;
> @@ -84,11 +87,21 @@ static void handle_vq(struct vhost_test *n)
> vq_err(vq, "Unexpected 0 len for TX\n");
> break;
> }
> - vhost_add_used_and_signal(&n->dev, vq, head, 0);
> + heads[batch_idx].id = cpu_to_vhost32(vq, head);
> + heads[batch_idx++].len = cpu_to_vhost32(vq, len);
> total_len += len;
> if (unlikely(vhost_exceeds_weight(vq, 0, total_len)))
> break;
> }
> + if (batch_idx) {
> + if (vhost_has_feature(vq, VIRTIO_F_IN_ORDER) && batch_idx >= 2) {
Maybe to add a module parameter to test this? Instead of trusting in
feature negotiation, "unorder_used=1" or something like that.
vhost.c:vhost_add_used_and_signal_n should support receiving buffers
in order or out of order whether F_IN_ORDER is negotiated or not.
Thanks!
Maybe to add a module parameter to test this? Instead of trusting in
feature negotiation, "unorder_used=1" or something like that.
vhost.c:vhost_add_used_and_signal_n should support receiving buffers
in order or out of order whether F_IN_ORDER is negotiated or not.
Thanks!
> + vhost_add_used_and_signal_n(&n->dev, vq, &heads[batch_idx / 2],
> + batch_idx - batch_idx / 2);
> + vhost_add_used_and_signal_n(&n->dev, vq, heads, batch_idx / 2);
> + } else {
> + vhost_add_used_and_signal_n(&n->dev, vq, heads, batch_idx);
> + }
> + }
>
> mutex_unlock(&vq->mutex);
> }
> --
> 2.17.1
>
next prev parent reply other threads:[~2022-08-02 3:08 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-21 8:43 [RFC 0/5] In virtio-spec 1.1, new feature bit VIRTIO_F_IN_ORDER was introduced Guo Zhi
2022-07-21 8:43 ` [RFC 1/5] vhost: reorder used descriptors in a batch Guo Zhi
2022-07-22 7:07 ` Eugenio Perez Martin
2022-08-02 3:30 ` Guo Zhi
2022-07-26 7:36 ` Jason Wang
[not found] ` <2a8838c4-2e6f-6de7-dcdc-572699ff3dc9@sjtu.edu.cn>
2022-07-29 7:32 ` Jason Wang
2022-08-02 3:09 ` Guo Zhi
2022-08-02 14:12 ` Guo Zhi
2022-08-04 5:04 ` Jason Wang
2022-08-11 8:58 ` Guo Zhi
2022-08-02 13:54 ` Guo Zhi
2022-07-21 8:43 ` [RFC 2/5] vhost: announce VIRTIO_F_IN_ORDER support Guo Zhi
2022-07-21 8:43 ` [RFC 3/5] vhost_test: batch used buffer Guo Zhi
2022-07-22 7:12 ` Eugenio Perez Martin
2022-08-02 2:47 ` Guo Zhi
2022-08-02 3:08 ` Guo Zhi [this message]
[not found] ` <1D1ABF88-B503-4BE0-AC83-3326EAA62510@sjtu.edu.cn>
2022-08-02 7:45 ` Stefano Garzarella
2022-07-21 8:43 ` [RFC 4/5] virtio: get desc id in order Guo Zhi
2022-07-26 8:07 ` Jason Wang
2022-07-28 8:12 ` Guo Zhi
2022-08-11 8:49 ` Guo Zhi
2022-07-21 8:43 ` [RFC 5/5] virtio: annouce VIRTIO_F_IN_ORDER support Guo Zhi
2022-07-21 9:17 ` [RFC 0/5] In virtio-spec 1.1, new feature bit VIRTIO_F_IN_ORDER was introduced Jason Wang
2022-07-21 11:54 ` Guo Zhi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=104238481.4321239.1659409711735.JavaMail.zimbra@sjtu.edu.cn \
--to=qtxuning1999@sjtu.edu.cn \
--cc=eperezma@redhat.com \
--cc=jasowang@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=sgarzare@redhat.com \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox