From: Guo Zhi <qtxuning1999@sjtu.edu.cn>
To: Eugenio Perez Martin <eperezma@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>,
Michael Tsirkin <mst@redhat.com>,
virtualization <virtualization@lists.linux-foundation.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
Stefano Garzarella <sgarzare@redhat.com>
Subject: Re: [PATCH v3 2/4] virtio_test: use random length scatterlists to test descriptor chain
Date: Sun, 17 Jul 2022 19:33:37 +0800 [thread overview]
Message-ID: <47372b7c-15bf-ba9f-083c-e16bd4d1df04@sjtu.edu.cn> (raw)
In-Reply-To: <CAJaqyWcFbxSSyY81_O_0AaTmw0e7_f+S_6F2Tjs1AHSbv-0jfg@mail.gmail.com>
On 2022/7/11 23:35, Eugenio Perez Martin wrote:
> On Sat, Jul 9, 2022 at 4:28 AM Guo Zhi <qtxuning1999@sjtu.edu.cn> wrote:
>> Prior implementation only use one descriptor for each io event, which
>> does't test code of descriptor chain. More importantly, one descriptor
>> will not use indirect feature even indirect feature is specified. Use
>> random length scatterlists here to test descriptor chain.
>>
>> Signed-off-by: Guo Zhi <qtxuning1999@sjtu.edu.cn>
>> ---
>> v3:
>> - drop fda270fcd virtio_test: move magic number in code as defined constant
>> ---
>> tools/virtio/virtio_test.c | 11 ++++++++---
>> 1 file changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/tools/virtio/virtio_test.c b/tools/virtio/virtio_test.c
>> index 95f78b311..1408a4a20 100644
>> --- a/tools/virtio/virtio_test.c
>> +++ b/tools/virtio/virtio_test.c
>> @@ -20,6 +20,7 @@
>> #include "../../drivers/vhost/test.h"
>>
>> #define RANDOM_BATCH -1
>> +#define MAX_SG_FRAGS 8UL
>>
>> /* Unused */
>> void *__kmalloc_fake, *__kfree_ignore_start, *__kfree_ignore_end;
>> @@ -169,7 +170,8 @@ static void wait_for_interrupt(struct vdev_info *dev)
>> static void run_test(struct vdev_info *dev, struct vq_info *vq,
>> bool delayed, int batch, int reset_n, int bufs)
>> {
>> - struct scatterlist sl;
>> + struct scatterlist sg[MAX_SG_FRAGS];
>> + int sg_size = 0;
>> long started = 0, completed = 0, next_reset = reset_n;
>> long completed_before, started_before;
>> int r, test = 1;
>> @@ -194,8 +196,11 @@ static void run_test(struct vdev_info *dev, struct vq_info *vq,
>>
>> while (started < bufs &&
>> (started - completed) < batch) {
>> - sg_init_one(&sl, dev->buf, dev->buf_size);
>> - r = virtqueue_add_outbuf(vq->vq, &sl, 1,
>> + sg_size = random() % (MAX_SG_FRAGS - 1) + 1;
> I'm wondering if it would be simpler to reuse batch randomness here,
> and make sg_size = MIN(started - completed, MAX_SG_FRAGS). Vhost test
> should go faster because the longer chains, and I guess we should hit
> a good range of chain lengths with the batch tail anyway.
>
> Thanks!
IMHO, if we reuse batch randomness here, the random length of
scatterlist only appears when --batch=random selected.
Otherwise, when we have to specify the batch size(eg, 256), the
scatterlist( as well as the descriptor chain len) will not be randomed.
So I propose decouple the randomness of batch size and descriptor chain
length.
If we have to achive better performance for vhost_test, just enlarge the
MAX_SG_FRAGS is ok.
>> + sg_init_table(sg, sg_size);
>> + for (int i = 0; i < sg_size; ++i)
>> + sg_set_buf(&sg[i], dev->buf + i, 0x1);
>> + r = virtqueue_add_outbuf(vq->vq, sg, sg_size,
>> dev->buf + started,
>> GFP_ATOMIC);
>> if (unlikely(r != 0)) {
>> --
>> 2.17.1
>>
next prev parent reply other threads:[~2022-07-17 11:33 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-09 2:27 [PATCH v3 0/4] virtio/virtio_test Guo Zhi
2022-07-09 2:27 ` [PATCH v3 1/4] virtio_test: kick vhost for a batch of descriptors Guo Zhi
2022-07-09 2:27 ` [PATCH v3 2/4] virtio_test: use random length scatterlists to test descriptor chain Guo Zhi
2022-07-11 15:35 ` Eugenio Perez Martin
2022-07-17 11:33 ` Guo Zhi [this message]
2022-07-09 2:27 ` [PATCH v3 3/4] virtio_test: enable indirection feature Guo Zhi
2022-07-09 2:27 ` [PATCH v3 4/4] virtio_test: pregenerate random numbers Guo Zhi
2022-07-21 11:55 ` [PATCH v3 0/4] virtio/virtio_test Guo Zhi
2022-08-03 9:00 ` 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=47372b7c-15bf-ba9f-083c-e16bd4d1df04@sjtu.edu.cn \
--to=qtxuning1999@sjtu.edu.cn \
--cc=eperezma@redhat.com \
--cc=jasowang@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--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
all inboxes | Powered by JetHome®