linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Uday Shankar <ushankar@purestorage.com>
Cc: Jens Axboe <axboe@kernel.dk>,
	Caleb Sander Mateos <csander@purestorage.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Shuah Khan <shuah@kernel.org>, Jonathan Corbet <corbet@lwn.net>,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org
Subject: Re: [PATCH v6 4/8] selftests: ublk: kublk: tie sqe allocation to io instead of queue
Date: Fri, 9 May 2025 15:40:39 +0800	[thread overview]
Message-ID: <aB2xd4593ZkWuMbB@fedora> (raw)
In-Reply-To: <20250507-ublk_task_per_io-v6-4-a2a298783c01@purestorage.com>

On Wed, May 07, 2025 at 03:49:38PM -0600, Uday Shankar wrote:
> We currently have a helper ublk_queue_alloc_sqes which the ublk targets
> use to allocate SQEs for their own operations. However, as we move
> towards decoupled ublk_queues and ublk server threads, this helper does
> not make sense anymore. SQEs are allocated from rings, and we will have
> one ring per thread to avoid locking. Change the SQE allocation helper
> to ublk_io_alloc_sqes. Currently this still allocates SQEs from the io's
> queue's ring, but when we fully decouple threads and queues, it will
> allocate from the io's thread's ring instead.
> 
> Signed-off-by: Uday Shankar <ushankar@purestorage.com>
> ---
>  tools/testing/selftests/ublk/fault_inject.c |  2 +-
>  tools/testing/selftests/ublk/file_backed.c  |  6 +++---
>  tools/testing/selftests/ublk/kublk.c        |  3 ++-
>  tools/testing/selftests/ublk/kublk.h        | 11 +++++++----
>  tools/testing/selftests/ublk/null.c         |  2 +-
>  tools/testing/selftests/ublk/stripe.c       |  4 ++--
>  6 files changed, 16 insertions(+), 12 deletions(-)
> 
> diff --git a/tools/testing/selftests/ublk/fault_inject.c b/tools/testing/selftests/ublk/fault_inject.c
> index 6bc8ee519b483ba6a365dccb03ad389425eefd3b..101c6dad6cf1f6dd45bbc46baa793493b97646bf 100644
> --- a/tools/testing/selftests/ublk/fault_inject.c
> +++ b/tools/testing/selftests/ublk/fault_inject.c
> @@ -41,7 +41,7 @@ static int ublk_fault_inject_queue_io(struct ublk_queue *q, int tag)
>  		.tv_nsec = (long long)q->dev->private_data,
>  	};
>  
> -	ublk_queue_alloc_sqes(q, &sqe, 1);
> +	ublk_io_alloc_sqes(ublk_get_io(q, tag), &sqe, 1);
>  	io_uring_prep_timeout(sqe, &ts, 1, 0);
>  	sqe->user_data = build_user_data(tag, ublksrv_get_op(iod), 0, q->q_id, 1);
>  
> diff --git a/tools/testing/selftests/ublk/file_backed.c b/tools/testing/selftests/ublk/file_backed.c
> index 69991ac7a0a947acba7b23ac89348936a3fcef75..563f11a21604bbf5b9531f69f806d09cdd785960 100644
> --- a/tools/testing/selftests/ublk/file_backed.c
> +++ b/tools/testing/selftests/ublk/file_backed.c
> @@ -18,7 +18,7 @@ static int loop_queue_flush_io(struct ublk_queue *q, const struct ublksrv_io_des
>  	unsigned ublk_op = ublksrv_get_op(iod);
>  	struct io_uring_sqe *sqe[1];
>  
> -	ublk_queue_alloc_sqes(q, sqe, 1);
> +	ublk_io_alloc_sqes(ublk_get_io(q, tag), sqe, 1);
>  	io_uring_prep_fsync(sqe[0], 1 /*fds[1]*/, IORING_FSYNC_DATASYNC);
>  	io_uring_sqe_set_flags(sqe[0], IOSQE_FIXED_FILE);
>  	/* bit63 marks us as tgt io */
> @@ -34,7 +34,7 @@ static int loop_queue_tgt_rw_io(struct ublk_queue *q, const struct ublksrv_io_de
>  	struct io_uring_sqe *sqe[3];
>  
>  	if (!zc) {
> -		ublk_queue_alloc_sqes(q, sqe, 1);
> +		ublk_io_alloc_sqes(ublk_get_io(q, tag), sqe, 1);
>  		if (!sqe[0])
>  			return -ENOMEM;
>  
> @@ -48,7 +48,7 @@ static int loop_queue_tgt_rw_io(struct ublk_queue *q, const struct ublksrv_io_de
>  		return 1;
>  	}
>  
> -	ublk_queue_alloc_sqes(q, sqe, 3);
> +	ublk_io_alloc_sqes(ublk_get_io(q, tag), sqe, 3);
>  
>  	io_uring_prep_buf_register(sqe[0], 0, tag, q->q_id, tag);
>  	sqe[0]->flags |= IOSQE_CQE_SKIP_SUCCESS | IOSQE_IO_HARDLINK;
> diff --git a/tools/testing/selftests/ublk/kublk.c b/tools/testing/selftests/ublk/kublk.c
> index d0eaf06fadbbb00c0549bba0a08f1be23baa2359..7b3af98546803134dd7f959c40408cefda7cd45c 100644
> --- a/tools/testing/selftests/ublk/kublk.c
> +++ b/tools/testing/selftests/ublk/kublk.c
> @@ -439,6 +439,7 @@ static int ublk_queue_init(struct ublk_queue *q)
>  	for (i = 0; i < q->q_depth; i++) {
>  		q->ios[i].buf_addr = NULL;
>  		q->ios[i].flags = UBLKSRV_NEED_FETCH_RQ | UBLKSRV_IO_FREE;
> +		q->ios[i].q = q;
>  
>  		if (q->state & UBLKSRV_NO_BUF)
>  			continue;
> @@ -554,7 +555,7 @@ int ublk_queue_io_cmd(struct ublk_queue *q, struct ublk_io *io, unsigned tag)
>  	if (io_uring_sq_space_left(&q->ring) < 1)
>  		io_uring_submit(&q->ring);
>  
> -	ublk_queue_alloc_sqes(q, sqe, 1);
> +	ublk_io_alloc_sqes(ublk_get_io(q, tag), sqe, 1);
>  	if (!sqe[0]) {
>  		ublk_err("%s: run out of sqe %d, tag %d\n",
>  				__func__, q->q_id, tag);
> diff --git a/tools/testing/selftests/ublk/kublk.h b/tools/testing/selftests/ublk/kublk.h
> index 34f92bb2c64d0ddc7690b2654613e0c77b2b8121..7c912116606429215af7dbc2a8ce6b40ef89bfbd 100644
> --- a/tools/testing/selftests/ublk/kublk.h
> +++ b/tools/testing/selftests/ublk/kublk.h
> @@ -119,6 +119,8 @@ struct ublk_io {
>  	unsigned short flags;
>  	unsigned short refs;		/* used by target code only */
>  
> +	struct ublk_queue *q;
> +
>  	int result;

In following patch, you added 'tag' to 'struct ublk_io', then 8bytes 'struct
ublk_queue *q' needn't to be added because it can be figured out by
container_of():

	- queue->ios can be calculated by 'io' address & its tag.
	
	- please add one helper ublk_io_to_queue(io) for it.

Also please try to avoid hole to 'ublk_io'.

Otherwise, this patch looks fine.



thanks,
Ming


  reply	other threads:[~2025-05-09  7:40 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-07 21:49 [PATCH v6 0/8] ublk: decouple server threads from hctxs Uday Shankar
2025-05-07 21:49 ` [PATCH v6 1/8] ublk: have a per-io daemon instead of a per-queue daemon Uday Shankar
2025-05-09  3:29   ` Ming Lei
2025-05-10 23:54     ` Caleb Sander Mateos
2025-05-11  0:17   ` Caleb Sander Mateos
2025-05-07 21:49 ` [PATCH v6 2/8] sbitmap: fix off-by-one when wrapping hint Uday Shankar
2025-05-09  3:51   ` Ming Lei
2025-05-11  0:35   ` Caleb Sander Mateos
2025-05-07 21:49 ` [PATCH v6 3/8] selftests: ublk: kublk: plumb q_id in io_uring user_data Uday Shankar
2025-05-09  7:28   ` Ming Lei
2025-05-07 21:49 ` [PATCH v6 4/8] selftests: ublk: kublk: tie sqe allocation to io instead of queue Uday Shankar
2025-05-09  7:40   ` Ming Lei [this message]
2025-05-07 21:49 ` [PATCH v6 5/8] selftests: ublk: kublk: lift queue initialization out of thread Uday Shankar
2025-05-09  7:44   ` Ming Lei
2025-05-07 21:49 ` [PATCH v6 6/8] selftests: ublk: kublk: move per-thread data out of ublk_queue Uday Shankar
2025-05-09  8:14   ` Ming Lei
2025-05-07 21:49 ` [PATCH v6 7/8] selftests: ublk: kublk: decouple ublk_queues from ublk server threads Uday Shankar
2025-05-09  8:31   ` Ming Lei
2025-05-09  8:46   ` Ming Lei
2025-05-07 21:49 ` [PATCH v6 8/8] Documentation: ublk: document UBLK_F_RR_TAGS Uday Shankar
2025-05-07 23:08   ` Randy Dunlap
2025-05-08  2:08   ` Bagas Sanjaya

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=aB2xd4593ZkWuMbB@fedora \
    --to=ming.lei@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=corbet@lwn.net \
    --cc=csander@purestorage.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=ushankar@purestorage.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 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).