All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Ankit Kumar <ankit.kumar@samsung.com>
Cc: fio@vger.kernel.org, krish.reddy@samsung.com,
	joshi.k@samsung.com, anuj20.g@samsung.com
Subject: Re: [PATCH v3 5/9] engines/io_uring: add new I/O engine for uring passthrough support
Date: Wed, 1 Jun 2022 22:19:55 -0600	[thread overview]
Message-ID: <e5abe6c3-ae66-dae2-8039-b7ec6bb9f054@kernel.dk> (raw)
In-Reply-To: <20220531133155.17493-6-ankit.kumar@samsung.com>

On 5/31/22 7:31 AM, Ankit Kumar wrote:
> From: Anuj Gupta <anuj20.g@samsung.com>
> 
> Add a new I/O engine (io_uring_cmd) for sending uring passthrough
> commands. It will also use most of the existing helpers from the
> I/O engine io_uring. The I/O preparation, completion, file open,
> file close and post init paths are going to differ and hence
> io_uring_cmd will have its own helper for them.
> 
> Add a new io_uring_cmd engine specific option to support nvme
> passthrough commands. Filename name for this specific option
> must specify nvme-ns generic character device (dev/ngXnY).
> This provides io_uring_cmd I/O engine a bandwidth to support
> various passthrough commands in future.
> 
> The engine_pos and engine_data fields in struct fio_file are
> separated now. This will help I/O engine io_uring_cmd to store
> specific data as well as keep track of register files.
> 
> Added a new option cmd_type. This specifies the type of uring
> command to submit. Currently it only supports nvme uring command

A few minor nits which we don't need to respin this for, unless other
changes end up being required. In general this to me looks like it's
ready to go, people please holler if they agree / disagree so we can get
this finished up.

> +static int fio_ioring_cmd_prep(struct thread_data *td, struct io_u *io_u)
> +{
> +	struct ioring_data *ld = td->io_ops_data;
> +	struct ioring_options *o = td->eo;
> +	struct fio_file *f = io_u->file;
> +	struct io_uring_sqe *sqe;
> +	int ret;
> +
> +	/* nvme_uring_cmd case */
> +	if (o->cmd_type == FIO_URING_CMD_NVME) {
> +		struct nvme_uring_cmd *cmd;

This should just be:

	if (o->cmd_type != FIO_URING_CMD_NVME)
		return -EINVAL;

	... other case ...

to prevent unnecessary nesting.


> @@ -728,6 +829,61 @@ retry:
>  	return fio_ioring_mmap(ld, &p);
>  }
>  
> +static int fio_ioring_cmd_queue_init(struct thread_data *td)
> +{
> +	struct ioring_data *ld = td->io_ops_data;
> +	struct ioring_options *o = td->eo;
> +	int depth = td->o.iodepth;
> +	struct io_uring_params p;
> +	int ret;
> +
> +	memset(&p, 0, sizeof(p));
> +
> +	if (o->hipri)
> +		p.flags |= IORING_SETUP_IOPOLL;
> +	if (o->sqpoll_thread) {
> +		p.flags |= IORING_SETUP_SQPOLL;
> +		if (o->sqpoll_set) {
> +			p.flags |= IORING_SETUP_SQ_AFF;
> +			p.sq_thread_cpu = o->sqpoll_cpu;
> +		}
> +	}
> +	if (o->cmd_type == FIO_URING_CMD_NVME) {
> +		p.flags |= IORING_SETUP_SQE128;
> +		p.flags |= IORING_SETUP_CQE32;
> +	}
> +
> +	/*
> +	 * Clamp CQ ring size at our SQ ring size, we don't need more entries
> +	 * than that.
> +	 */
> +	p.flags |= IORING_SETUP_CQSIZE;
> +	p.cq_entries = depth;
> +
> +retry:
> +	ret = syscall(__NR_io_uring_setup, depth, &p);
> +	if (ret < 0) {
> +		if (errno == EINVAL && p.flags & IORING_SETUP_CQSIZE) {
> +			p.flags &= ~IORING_SETUP_CQSIZE;
> +			goto retry;
> +		}
> +		return ret;
> +	}

This retry doesn't really have any reason for existing anymore, as we
know we have SETUP_CQSIZE if we have SQE128/CQE32. Hence I think it
should just go away, and we should probably have a nice warning print of
some sort if we get EINVAL as it means the kernel is too old to support
SQE128/CQE32 and hence passthrough in general.

That prevents people from emailing me that it doesn't work just because
their kernel is too old.

Apart from that, this looks good to me.

-- 
Jens Axboe


  reply	other threads:[~2022-06-02  4:20 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20220531133739epcas5p31aa9479d49d5ae82a85b493bd0bb4e47@epcas5p3.samsung.com>
2022-05-31 13:31 ` [PATCH v3 0/9] Add support for uring passthrough commands Ankit Kumar
     [not found]   ` <CGME20220531133740epcas5p1e7c1049ef44fc7d25b78f239f035a29d@epcas5p1.samsung.com>
2022-05-31 13:31     ` [PATCH v3 1/9] io_uring.h: add IORING_SETUP_SQE128 and IORING_SETUP_CQE32 Ankit Kumar
     [not found]   ` <CGME20220531133741epcas5p16383da97824ffedd50f5e3231d09430e@epcas5p1.samsung.com>
2022-05-31 13:31     ` [PATCH v3 2/9] configure: check nvme uring command support Ankit Kumar
     [not found]   ` <CGME20220531133743epcas5p4d400c341f29489c51e3ee5590415420c@epcas5p4.samsung.com>
2022-05-31 13:31     ` [PATCH v3 3/9] init: return error incase an invalid value is passed as option Ankit Kumar
     [not found]   ` <CGME20220531133745epcas5p3546b36e799931251c4020e4fe13fa14d@epcas5p3.samsung.com>
2022-05-31 13:31     ` [PATCH v3 4/9] nvme: add nvme opcodes, structures and helper functions Ankit Kumar
     [not found]   ` <CGME20220531133746epcas5p36ec535b219f3e2008b14d2adc59e30f2@epcas5p3.samsung.com>
2022-05-31 13:31     ` [PATCH v3 5/9] engines/io_uring: add new I/O engine for uring passthrough support Ankit Kumar
2022-06-02  4:19       ` Jens Axboe [this message]
     [not found]   ` <CGME20220531133747epcas5p4a9a89962301b8853ca13ba017546ae38@epcas5p4.samsung.com>
2022-05-31 13:31     ` [PATCH v3 6/9] docs: document options for io_uring_cmd I/O engine Ankit Kumar
     [not found]   ` <CGME20220531133748epcas5p1e2d8f913398d3ea8c165e1044e6914d8@epcas5p1.samsung.com>
2022-05-31 13:31     ` [PATCH v3 7/9] zbd: Check for direct flag only if its block device Ankit Kumar
2022-06-01 20:32       ` Vincent Fu
2022-06-02  1:53         ` Shinichiro Kawasaki
2022-06-02  0:55       ` Shinichiro Kawasaki
     [not found]   ` <CGME20220531133750epcas5p1602001843ff6971719f2435faf631cf4@epcas5p1.samsung.com>
2022-05-31 13:31     ` [PATCH v3 8/9] engines/io_uring: Enable zone device support for io_uring_cmd I/O engine Ankit Kumar
     [not found]   ` <CGME20220531133751epcas5p3819dec97a26ac12bf81d03d947a7272d@epcas5p3.samsung.com>
2022-05-31 13:31     ` [PATCH v3 9/9] examples: add 2 example job file for io_uring_cmd engine Ankit Kumar
2022-06-02  8:24   ` [PATCH v3 0/9] Add support for uring passthrough commands Jens Axboe

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=e5abe6c3-ae66-dae2-8039-b7ec6bb9f054@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=ankit.kumar@samsung.com \
    --cc=anuj20.g@samsung.com \
    --cc=fio@vger.kernel.org \
    --cc=joshi.k@samsung.com \
    --cc=krish.reddy@samsung.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.