linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Christoph Hellwig <hch@lst.de>
Cc: Avi Kivity <avi@scylladb.com>,
	linux-aio@kvack.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/4] aio: implement IOCB_CMD_POLL
Date: Thu, 2 Aug 2018 22:48:18 +0100	[thread overview]
Message-ID: <20180802214818.GB30522@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20180802161648.GA9676@lst.de>

On Thu, Aug 02, 2018 at 06:16:48PM +0200, Christoph Hellwig wrote:
> On Thu, Aug 02, 2018 at 05:08:38PM +0100, Al Viro wrote:
> > On Thu, Aug 02, 2018 at 06:08:16PM +0200, Christoph Hellwig wrote:
> > > On Thu, Aug 02, 2018 at 05:00:32PM +0100, Al Viro wrote:
> > > > BTW, what happens if we insert into one queue and immediately get
> > > > woken up, even before the damn thing gets to the end of ->poll(),
> > > > which proceeds to call poll_wait() again (on another queue)?
> > > > AFAICS, apt.error will be set by the second callback and completely
> > > > ignored.  And so will the return value of ->poll()...
> > > > 
> > > > Sigh...  Analysis of that thing is bloody painful, mostly because
> > > > it's hard to describe the state...
> > > 
> > > That's the problem with the ->poll interface.  We call it, then
> > > have magic happen underneath where it might or might not get added
> > > to one (or more if we didn't exclude that) waitqueues, and might
> > > have actually been worken before return.  I can't really think of
> > > a good way to do that entirely sanely.
> > > 
> > > Best I can think of is to only allow using file ops that do keyed
> > > wakeups and rely on the keyed wakeups alone.  I've started coming
> > > up with a version of that, but it won't be until tomorrow at least
> > > that I can post it.
> > 
> > What does it buy you?  You still have to deal with trylock failures
> > in wakeup...
> 
> But we'll never re-add an iocb once it has been removed from the
> waitqueue.

Umm...  Frankly, I wonder if the right approach is to declare that if
wakeup has happened at all, submit gives up any responsibility.

IOW, have aio_poll
	* create iocb, feed to ->poll()
	* check if ->head is NULL; if it is, the mask we've got is
*all* we are going to get; complete and bugger off.
	* lock ioctx
	* insert the sucker into ->active_reqs
	* lock the queue
	* check if wakeup has already happened.
	* if it has - go away, it's submitted
	* check apt.error; if set, fail with -EINVAL.
	* check the mask; if nothing of interest is in there, go away
	* dequeue, unlist, complete and bugger off

On cancel side
	* lock queue
	* mark it cancelled
	* removed from queue if it was there
	* unlock queue

On wakeup
	* mark it woken
	* complete or schedule completion, which would be where we check
if it's marked cancelled - both before vfs_poll() (to avoid calling it
if already set) and after (treating cancel during vfs_poll() as "complete
and bugger off").

Comments?

  reply	other threads:[~2018-08-02 23:41 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-30  7:15 aio poll and a new in-kernel poll API V21 (aka 2.0) Christoph Hellwig
2018-07-30  7:15 ` [PATCH 1/4] timerfd: add support for keyed wakeups Christoph Hellwig
2018-07-30  7:15 ` [PATCH 2/4] aio: add a iocb refcount Christoph Hellwig
2018-08-01 23:19   ` Al Viro
2018-08-02  8:59     ` Christoph Hellwig
2018-07-30  7:15 ` [PATCH 3/4] aio: implement IOCB_CMD_POLL Christoph Hellwig
2018-08-01 23:54   ` Al Viro
2018-08-02  9:00     ` Christoph Hellwig
2018-08-02  0:21   ` Al Viro
2018-08-02  9:22     ` Christoph Hellwig
2018-08-02 16:00       ` Al Viro
2018-08-02 16:08         ` Christoph Hellwig
2018-08-02 16:08           ` Al Viro
2018-08-02 16:16             ` Christoph Hellwig
2018-08-02 21:48               ` Al Viro [this message]
2018-07-30  7:15 ` [PATCH 4/4] aio: allow direct aio poll comletions for keyed wakeups Christoph Hellwig
  -- strict thread matches above, loose matches on Subject: below --
2018-08-06  8:30 aio poll V22 (aka 2.0) Christoph Hellwig
2018-08-06  8:30 ` [PATCH 3/4] aio: implement IOCB_CMD_POLL Christoph Hellwig
2018-07-26  8:28 aio poll and a new in-kernel poll API V20 (aka 2.0) Christoph Hellwig
2018-07-26  8:29 ` [PATCH 3/4] aio: implement IOCB_CMD_POLL Christoph Hellwig

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=20180802214818.GB30522@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=avi@scylladb.com \
    --cc=hch@lst.de \
    --cc=linux-aio@kvack.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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).