On Wed, Jan 20, 2016 at 03:07:26PM -0800, Linus Torvalds wrote: > On Jan 20, 2016 1:46 PM, "Dave Chinner" <david@xxxxxxxxxxxxx> wrote: > > > > > > > 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 > > > changes to the filesystems to ensure that they adhere to the > non-blocking > > > 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 > > > 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@xxxxxxxxxxxxx -- To unsubscribe from this list: send the line "unsubscribe linux-api" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html