[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220709022745.21020-3-qtxuning1999@sjtu.edu.cn>
Date: Sat, 9 Jul 2022 10:27:43 +0800
From: Guo Zhi <qtxuning1999@...u.edu.cn>
To: jasowang@...hat.com, mst@...hat.com
Cc: eperezma@...hat.com, virtualization@...ts.linux-foundation.org,
linux-kernel@...r.kernel.org, sgarzare@...hat.com,
Guo Zhi <qtxuning1999@...u.edu.cn>
Subject: [PATCH v3 2/4] virtio_test: use random length scatterlists to test descriptor chain
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@...u.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;
+ 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
Powered by blists - more mailing lists