virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Guo Zhi <qtxuning1999@sjtu.edu.cn>
Cc: eperezma@redhat.com, linux-kernel@vger.kernel.org,
	virtualization@lists.linux-foundation.org
Subject: Re: [PATCH v2 3/4] virtio_test: use random length scatterlists to test descriptor chain
Date: Thu, 7 Jul 2022 01:16:38 -0400	[thread overview]
Message-ID: <20220707011015-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20220707024409.1869-4-qtxuning1999@sjtu.edu.cn>

On Thu, Jul 07, 2022 at 10:44:08AM +0800, Guo Zhi 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>
> ---
>  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 1ecd64271..363695b33 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
>  #define ALIGN 4096
>  #define RINGSIZE   256
>  #define TEST_BUF_NUM 0x100000
> @@ -172,7 +173,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;
> @@ -197,8 +199,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)) {

random on data path is pretty expensive.
I would suggest get an array size from user (and maybe a seed?) and
pregenerate some numbers, then reuse.


> -- 
> 2.17.1

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

      parent reply	other threads:[~2022-07-07  5:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220707024409.1869-1-qtxuning1999@sjtu.edu.cn>
     [not found] ` <20220707024409.1869-5-qtxuning1999@sjtu.edu.cn>
2022-07-07  4:59   ` [PATCH v2 4/4] virtio_test: enable indirection feature Michael S. Tsirkin
     [not found]     ` <2ff418ad-0ab8-1474-4308-2d163c1e6652@sjtu.edu.cn>
2022-07-07  5:59       ` Michael S. Tsirkin
     [not found] ` <20220707024409.1869-3-qtxuning1999@sjtu.edu.cn>
2022-07-07  5:09   ` [PATCH v2 2/4] virtio_test: move magic number in code as defined constant Michael S. Tsirkin
     [not found]     ` <8c15f97f-df6d-9ec5-b9d3-c42350cde887@sjtu.edu.cn>
2022-07-07  7:36       ` Michael S. Tsirkin
     [not found] ` <20220707024409.1869-4-qtxuning1999@sjtu.edu.cn>
2022-07-07  5:16   ` Michael S. Tsirkin [this message]

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=20220707011015-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=eperezma@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=qtxuning1999@sjtu.edu.cn \
    --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;
as well as URLs for NNTP newsgroup(s).