All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Sachin Sant <sachinp@linux.ibm.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 3/3] io_uring: Refactor io_uring01 to use common code
Date: Mon, 23 Mar 2026 17:32:44 +0100	[thread overview]
Message-ID: <acFrLJYeI3U4Fc1k@yuki.lan> (raw)
In-Reply-To: <20260320124742.75946-4-sachinp@linux.ibm.com>

Hi!
> -static int setup_io_uring_test(struct submitter *s, struct tcase *tc)
> +static int setup_io_uring_test(struct io_uring_submit *s, struct tcase *tc)
>  {
>  	struct io_sq_ring *sring = &s->sq_ring;
>  	struct io_cq_ring *cring = &s->cq_ring;
> @@ -83,43 +46,42 @@ static int setup_io_uring_test(struct submitter *s, struct tcase *tc)
>  		return 1;
>  	}
>  
> -	sptr_size = p.sq_off.array + p.sq_entries * sizeof(unsigned int);
> +	s->sq_ptr_size = p.sq_off.array + p.sq_entries * sizeof(unsigned int);
>  
>  	/* Submission queue ring buffer mapping */
> -	sptr = SAFE_MMAP(0, sptr_size,
> -			PROT_READ | PROT_WRITE,
> -			MAP_SHARED | MAP_POPULATE,
> -			s->ring_fd, IORING_OFF_SQ_RING);
> +	s->sq_ptr = SAFE_MMAP(0, s->sq_ptr_size,
> +			      PROT_READ | PROT_WRITE,
> +			      MAP_SHARED | MAP_POPULATE,
> +			      s->ring_fd, IORING_OFF_SQ_RING);
>  
>  	/* Save global submission queue struct info */
> -	sring->head = sptr + p.sq_off.head;
> -	sring->tail = sptr + p.sq_off.tail;
> -	sring->ring_mask = sptr + p.sq_off.ring_mask;
> -	sring->ring_entries = sptr + p.sq_off.ring_entries;
> -	sring->flags = sptr + p.sq_off.flags;
> -	sring->array = sptr + p.sq_off.array;
> +	sring->head = s->sq_ptr + p.sq_off.head;
> +	sring->tail = s->sq_ptr + p.sq_off.tail;
> +	sring->ring_mask = s->sq_ptr + p.sq_off.ring_mask;
> +	sring->ring_entries = s->sq_ptr + p.sq_off.ring_entries;
> +	sring->flags = s->sq_ptr + p.sq_off.flags;
> +	sring->array = s->sq_ptr + p.sq_off.array;
>  
>  	/* Submission queue entries ring buffer mapping */
> -	s->sqes = SAFE_MMAP(0, p.sq_entries *
> -			sizeof(struct io_uring_sqe),
> -			PROT_READ | PROT_WRITE,
> -			MAP_SHARED | MAP_POPULATE,
> -			s->ring_fd, IORING_OFF_SQES);
> +	s->sqes = SAFE_MMAP(0, p.sq_entries * sizeof(struct io_uring_sqe),
> +			    PROT_READ | PROT_WRITE,
> +			    MAP_SHARED | MAP_POPULATE,
> +			    s->ring_fd, IORING_OFF_SQES);
>  
> -	cptr_size = p.cq_off.cqes + p.cq_entries * sizeof(struct io_uring_cqe);
> +	s->cq_ptr_size = p.cq_off.cqes + p.cq_entries * sizeof(struct io_uring_cqe);
>  
>  	/* Completion queue ring buffer mapping */
> -	cptr = SAFE_MMAP(0, cptr_size,
> -			PROT_READ | PROT_WRITE,
> -			MAP_SHARED | MAP_POPULATE,
> -			s->ring_fd, IORING_OFF_CQ_RING);
> +	s->cq_ptr = SAFE_MMAP(0, s->cq_ptr_size,
> +			      PROT_READ | PROT_WRITE,
> +			      MAP_SHARED | MAP_POPULATE,
> +			      s->ring_fd, IORING_OFF_CQ_RING);
>  
>  	/* Save global completion queue struct info */
> -	cring->head = cptr + p.cq_off.head;
> -	cring->tail = cptr + p.cq_off.tail;
> -	cring->ring_mask = cptr + p.cq_off.ring_mask;
> -	cring->ring_entries = cptr + p.cq_off.ring_entries;
> -	cring->cqes = cptr + p.cq_off.cqes;
> +	cring->head = s->cq_ptr + p.cq_off.head;
> +	cring->tail = s->cq_ptr + p.cq_off.tail;
> +	cring->ring_mask = s->cq_ptr + p.cq_off.ring_mask;
> +	cring->ring_entries = s->cq_ptr + p.cq_off.ring_entries;
> +	cring->cqes = s->cq_ptr + p.cq_off.cqes;
>  
>  	return 0;
>  }

Isn't this nearly identical to the io uring setup in the common header?

I was hoping of unifying that part as well.

> @@ -139,7 +101,7 @@ static void check_buffer(char *buffer, size_t len)
>  		tst_res(TPASS, "Buffer filled in correctly");
>  }
>  
> -static void drain_uring_cq(struct submitter *s, unsigned int exp_events)
> +static void drain_uring_cq(struct io_uring_submit *s, unsigned int exp_events)
>  {
>  	struct io_cq_ring *cring = &s->cq_ring;
>  	unsigned int head = *cring->head;
> @@ -175,7 +137,7 @@ static void drain_uring_cq(struct submitter *s, unsigned int exp_events)
>  	        events, exp_events);
>  }
>  
> -static int submit_to_uring_sq(struct submitter *s, struct tcase *tc)
> +static int submit_to_uring_sq(struct io_uring_submit *s, struct tcase *tc)
>  {
>  	unsigned int index = 0, tail = 0, next_tail = 0;
>  	struct io_sq_ring *sring = &s->sq_ring;
> @@ -229,23 +191,20 @@ static int submit_to_uring_sq(struct submitter *s, struct tcase *tc)
>  
>  static void cleanup_io_uring_test(void)
>  {
> -	io_uring_register(s->ring_fd, IORING_UNREGISTER_BUFFERS,
> +	io_uring_register(s.ring_fd, IORING_UNREGISTER_BUFFERS,
>  			  NULL, QUEUE_DEPTH);
> -	SAFE_MUNMAP(s->sqes, sizeof(struct io_uring_sqe));
> -	SAFE_MUNMAP(cptr, cptr_size);
> -	SAFE_MUNMAP(sptr, sptr_size);
> -	SAFE_CLOSE(s->ring_fd);
> +	io_uring_cleanup_queue(&s, QUEUE_DEPTH);
>  }
>  
>  static void run(unsigned int n)
>  {
>  	struct tcase *tc = &tcases[n];
>  
> -	if (setup_io_uring_test(s, tc))
> +	if (setup_io_uring_test(&s, tc))
>  		return;
>  
> -	if (!submit_to_uring_sq(s, tc))
> -		drain_uring_cq(s, 1);
> +	if (!submit_to_uring_sq(&s, tc))
> +		drain_uring_cq(&s, 1);
>  
>  	cleanup_io_uring_test();
>  }
> -- 
> 2.39.1
> 

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

      reply	other threads:[~2026-03-23 16:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-20 12:47 [LTP] [PATCH 0/3] io_uring READ(V), WRITE(v) operation tests Sachin Sant
2026-03-20 12:47 ` [LTP] [PATCH 1/3] io_uring: Test IORING READ and WRITE operations Sachin Sant
2026-03-23 12:46   ` Cyril Hrubis
2026-03-23 15:46     ` Sachin Sant
2026-03-20 12:47 ` [LTP] [PATCH 2/3] io_uring: Test READV and WRITEV operations Sachin Sant
2026-03-23 16:22   ` Cyril Hrubis
2026-03-24  5:15     ` Sachin Sant
2026-03-20 12:47 ` [LTP] [PATCH 3/3] io_uring: Refactor io_uring01 to use common code Sachin Sant
2026-03-23 16:32   ` Cyril Hrubis [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=acFrLJYeI3U4Fc1k@yuki.lan \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=sachinp@linux.ibm.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.