Thread (51 messages) 51 messages, 10 authors, 2016-03-20

Re: [PATCH 07/13] aio: enabled thread based async fsync

From: Dave Chinner <david@fromorbit.com>
Date: 2016-01-23 04:39:22
Also in: linux-fsdevel, linux-mm, lkml

On Wed, Jan 20, 2016 at 03:07:26PM -0800, Linus Torvalds wrote:
On Jan 20, 2016 1:46 PM, "Dave Chinner" [off-list ref] wrote:
quoted
quoted
quoted
That said, I also agree that it would be interesting to hear what the
performance impact is for existing performance-sensitive users. Could
we make that "aio_may_use_threads()" case be unconditional, making
things simpler?
Making it unconditional is a goal, but some work is required before that
can be the case.  The O_DIRECT issue is one such matter -- it requires
some
quoted
quoted
changes to the filesystems to ensure that they adhere to the
non-blocking
quoted
quoted
nature of the new interface (ie taking i_mutex is a Bad Thing that users
really do not want to be exposed to; if taking it blocks, the code
should
quoted
quoted
punt to a helper thread).
Filesystems *must take locks* in the IO path.
I agree.

I also would prefer to make the aio code have as little interaction and
magic flags with the filesystem code as humanly possible.

I wonder if we could make the rough rule be that the only synchronous case
the aio code ever has is more or less entirely in the generic vfs caches?
IOW, could we possibly aim to make the rule be that if we call down to the
filesystem layer, we do that within a thread?
We have to go through the filesystem layer locking even on page
cache hits, and even if we get into the page cache copy-in/copy-out
code we can still get stuck on things like page locks and page
faults. Even if hte pages are cached, we can still get caught on
deeper filesystem locks for block mapping. e.g. read from a hole,
get zeros back, page cache is populated. Write data into range,
fetch page, realise it's unmapped, need to do block/delayed
allocation which requires filesystem locks and potentially
transactions and IO....
We could do things like that for the name loopkup for openat() too, where
we could handle the successful RCU loopkup synchronously, but then if we
fall out of RCU mode we'd do the thread.
We'd have to do quite a bit of work to unwind back out to the AIO
layer before we can dispatch the open operation again in a thread,
wouldn't we?

So I'm not convinced that conditional thread dispatch makes sense. I
think the simplest thing to do is make all AIO use threads/
workqueues by default, and if the application is smart enough to
only do things that minimise blocking they can turn off the threaded
dispatch and get the same behaviour they get now.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

--
To unsubscribe, send a message with 'unsubscribe linux-aio' in
the body to majordomo@kvack.org.  For more info on Linux AIO,
see: http://www.kvack.org/aio/
Don't email: <a href=mailto:"aart@kvack.org">aart@kvack.org</a>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help