From: Luis Chamberlain <mcgrof@kernel.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: "Kanchan Joshi" <joshiiitr@gmail.com>,
"Kanchan Joshi" <joshi.k@samsung.com>,
io-uring@vger.kernel.org, linux-nvme@lists.infradead.org,
linux-block@vger.kernel.org, "Christoph Hellwig" <hch@lst.de>,
"Keith Busch" <kbusch@kernel.org>,
"Javier González" <javier@javigon.com>,
"Anuj Gupta" <anuj20.g@samsung.com>,
"Pankaj Raghav" <pankydev8@gmail.com>
Subject: Re: [RFC 01/13] io_uring: add infra for uring_cmd completion in submitter-task
Date: Thu, 17 Feb 2022 09:56:37 -0800 [thread overview]
Message-ID: <Yg6MVe2Qpy92CsNF@bombadil.infradead.org> (raw)
In-Reply-To: <b11ede2b-b737-f99a-7b31-20d6b4eccb42@kernel.dk>
On Thu, Feb 17, 2022 at 08:50:59AM -0700, Jens Axboe wrote:
> On 2/17/22 8:39 AM, Kanchan Joshi wrote:
> > On Thu, Feb 17, 2022 at 7:43 AM Luis Chamberlain <mcgrof@kernel.org> wrote:
> >>
> >> On Mon, Dec 20, 2021 at 07:47:22PM +0530, Kanchan Joshi wrote:
> >>> Completion of a uring_cmd ioctl may involve referencing certain
> >>> ioctl-specific fields, requiring original submitter context.
> >>> Export an API that driver can use for this purpose.
> >>> The API facilitates reusing task-work infra of io_uring, while driver
> >>> gets to implement cmd-specific handling in a callback.
> >>>
> >>> Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>
> >>> Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
> >>> ---
> >>> fs/io_uring.c | 16 ++++++++++++++++
> >>> include/linux/io_uring.h | 8 ++++++++
> >>> 2 files changed, 24 insertions(+)
> >>>
> >>> diff --git a/fs/io_uring.c b/fs/io_uring.c
> >>> index e96ed3d0385e..246f1085404d 100644
> >>> --- a/fs/io_uring.c
> >>> +++ b/fs/io_uring.c
> >>> @@ -2450,6 +2450,22 @@ static void io_req_task_submit(struct io_kiocb *req, bool *locked)
> >>> io_req_complete_failed(req, -EFAULT);
> >>> }
> >>>
> >>> +static void io_uring_cmd_work(struct io_kiocb *req, bool *locked)
> >>> +{
> >>> + req->uring_cmd.driver_cb(&req->uring_cmd);
> >>
> >> If the callback memory area is gone, boom.
> >
> > Why will the memory area be gone?
> > Module removal is protected because try_module_get is done anyway when
> > the namespace was opened.
>
> And the req isn't going away before it's completed.
Groovy, it would be nice to add a little /* comment */ to just remind
the reader?
> >>> +{
> >>> + struct io_kiocb *req = container_of(ioucmd, struct io_kiocb, uring_cmd);
> >>> +
> >>> + req->uring_cmd.driver_cb = driver_cb;
> >>> + req->io_task_work.func = io_uring_cmd_work;
> >>> + io_req_task_work_add(req, !!(req->ctx->flags & IORING_SETUP_SQPOLL));
> >>
> >> This can schedules, and so the callback may go fishing in the meantime.
> >
> > io_req_task_work_add is safe to be called in atomic context. FWIW,
> > io_uring uses this for regular (i.e. direct block) io completion too.
>
> Correct, it doesn't schedule and is safe from irq context as long as the
> task is pinned (which it is, via the req itself).
Great, a kdoc explaining the routine and that it can be called from
atomic context and the rationale would be very useful to users. And ..
so the callback *must* be safe in atomic context too or can it sleep?
Luis
next prev parent reply other threads:[~2022-02-17 17:56 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20211220142227epcas5p280851b0a62baa78379979eb81af7a096@epcas5p2.samsung.com>
2021-12-20 14:17 ` [RFC 00/13] uring-passthru for nvme Kanchan Joshi
2021-12-20 14:17 ` [RFC 01/13] io_uring: add infra for uring_cmd completion in submitter-task Kanchan Joshi
2022-02-17 2:13 ` Luis Chamberlain
2022-02-17 15:39 ` Kanchan Joshi
2022-02-17 15:50 ` Jens Axboe
2022-02-17 17:56 ` Luis Chamberlain [this message]
2022-02-18 17:41 ` Kanchan Joshi
2022-02-17 18:46 ` Luis Chamberlain
2022-02-17 18:53 ` Jens Axboe
2021-12-20 14:17 ` [RFC 02/13] nvme: wire-up support for async-passthru on char-device Kanchan Joshi
2021-12-20 14:17 ` [RFC 03/13] io_uring: mark iopoll not supported for uring-cmd Kanchan Joshi
2022-02-17 2:16 ` Luis Chamberlain
2022-02-17 2:52 ` Jens Axboe
2021-12-20 14:17 ` [RFC 04/13] io_uring: modify unused field in io_uring_cmd to store flags Kanchan Joshi
2021-12-20 14:17 ` [RFC 05/13] io_uring: add flag and helper for fixed-buffer uring-cmd Kanchan Joshi
2021-12-20 14:17 ` [RFC 06/13] io_uring: add support for uring_cmd with fixed-buffer Kanchan Joshi
2021-12-20 14:17 ` [RFC 07/13] nvme: enable passthrough " Kanchan Joshi
2021-12-20 14:17 ` [RFC 08/13] io_uring: plug for async bypass Kanchan Joshi
2021-12-20 14:17 ` [RFC 09/13] block: wire-up support for plugging Kanchan Joshi
2021-12-20 14:17 ` [RFC 10/13] block: factor out helper for bio allocation from cache Kanchan Joshi
2021-12-20 14:17 ` [RFC 11/13] nvme: enable bio-cache for fixed-buffer passthru Kanchan Joshi
2021-12-20 14:17 ` [RFC 12/13] nvme: allow user passthrough commands to poll Kanchan Joshi
2021-12-20 14:17 ` [RFC 13/13] nvme: Add async passthru polling support Kanchan Joshi
2021-12-21 3:45 ` [RFC 00/13] uring-passthru for nvme Jens Axboe
2021-12-21 14:36 ` Kanchan Joshi
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=Yg6MVe2Qpy92CsNF@bombadil.infradead.org \
--to=mcgrof@kernel.org \
--cc=anuj20.g@samsung.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=io-uring@vger.kernel.org \
--cc=javier@javigon.com \
--cc=joshi.k@samsung.com \
--cc=joshiiitr@gmail.com \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=pankydev8@gmail.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