public inbox for [email protected]
 help / color / mirror / Atom feed
From: Ming Lei <[email protected]>
To: Jens Axboe <[email protected]>
Cc: Bernd Schubert <[email protected]>,
	"[email protected]" <[email protected]>,
	Pavel Begunkov <[email protected]>,
	[email protected]
Subject: Re: SQPOLL / uring_cmd_iopoll
Date: Sun, 23 Apr 2023 09:06:12 +0800	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

On Sat, Apr 22, 2023 at 08:08:41AM -0600, Jens Axboe wrote:
> On 4/22/23 6:55?AM, Ming Lei wrote:
> > On Fri, Apr 21, 2023 at 10:09:36PM +0000, Bernd Schubert wrote:
> >> Hello,
> >>
> >> I was wondering if I could set up SQPOLL for fuse/IORING_OP_URING_CMD 
> >> and what would be the latency win. Now I get a bit confused what the 
> >> f_op->uring_cmd_iopoll() function is supposed to do.
> >>
> >> Is it just there to check if SQEs are can be completed as CQE? In rw.c 
> >> io_do_iopoll() it looks like this. I don't follow all code paths in 
> >> __io_sq_thread yet, but it looks a like it already checks if the ring 
> >> has new entries
> >>
> >> to_submit = io_sqring_entries(ctx);
> >> ...
> >> ret = io_submit_sqes(ctx, to_submit);
> >>
> >>    --> it will eventually call into ->uring_cmd() ?
> >>
> >> And then io_do_iopoll ->  file->f_op->uring_cmd_iopoll is supposed to 
> >> check for available cq entries and will submit these? I.e. I just return 
> >> 1 if when the request is ready? And also ensure that 
> >> req->iopoll_completed is set?
> >>
> >>
> >> I'm also not sure what I should do with struct io_comp_batch * - I don't 
> >> have struct request *req_list anywhere in my fuse-uring changes, seems 
> >> to be blk-mq specific? So I should just ignore that parameter?
> >>
> >>
> >> Btw, this might be useful for ublk as well?
> > 
> > For the in-tree ublk driver, we need to copy data inside ->uring_cmd()
> > between block request pages and user buffer, so SQPOLL may not be done
> > because it isn't efficient for the kthread to copy on remote task mm
> > space. However, ublk user copy feature[1](posted recently) doesn't
> > need the copy in ->uring_cmd() any more, so SQPOLL becomes possible for
> > ublk uring cmd.
> 
> That hasn't been true for a long time, and isn't even true in
> 5.10-stable anymore or anything newer. The SQPOLL thread is not a
> kthread, and it doesn't need to do anything to copy the data that the
> inline submission wouldn't also do. There is no "remote task mm". The
> cost would be the same, outside of caching effects.

OK, thanks for the clarification, and create_io_thread() does pass
CLONE_VM, so there isn't remote task mm problem.

However, ublk still can't use SETUP_SQPOLL so far, and problem is that
ublk driver has to be bound with the user task for canceling pending commands
when the ctx is gone[1]. When this issue is solved, SETUP_SQPOLL should
work just fine.

Given fuse takes similar approach with ublk, I believe fuse has similar
limit too.

Actually I was working on adding notifiers in io_uring[2] for addressing
this issue so that driver needn't to use the trick for tracking io_uring
context destroying. Just see one request double free issue(same request freed
in io_submit_flush_completions<-io_fallback_req_func() twice) in case of
DEFER_TASKRUN only, but driver actually calls io_uring_cmd_done() just once.
Will investigate the issue further.


[1] https://lore.kernel.org/linux-fsdevel/[email protected]/
[2] https://github.com/ming1/linux/commits/for-6.4/io_uring_block


Thanks, 
Ming


      reply	other threads:[~2023-04-23  1:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-21 22:09 SQPOLL / uring_cmd_iopoll Bernd Schubert
2023-04-22  2:13 ` Jens Axboe
2023-04-22 13:40   ` Bernd Schubert
2023-04-24 12:55     ` Bernd Schubert
2023-04-22 12:55 ` Ming Lei
2023-04-22 14:08   ` Jens Axboe
2023-04-23  1:06     ` Ming Lei [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 \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /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