On 8/19/21 3:01 AM, Christoph Hellwig wrote: > On Wed, Aug 18, 2021 at 10:54:45AM -0600, Jens Axboe wrote: >> We previously enabled this for O_DIRECT polled IO, however io_uring >> completes all IO from task context these days, so it can be enabled for >> that path too. This requires moving the bio_put() from IRQ context, and >> this can be accomplished by passing the ownership back to the issuer. >> >> Use kiocb->private for that, which should be (as far as I can tell) free >> once we get to the completion side of things. Add a IOCB_PUT_CACHE flag >> to tell the issuer that we passed back the ownership, then the issuer >> can put the bio from a safe context. >> >> Like the polled IO ditto, this is good for a 10% performance increase. >> >> Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> >> >> --- >> >> Just hacked this up and tested it, Works For Me. Would welcome input on >> alternative methods here, if anyone has good suggestions. > > 10% performance improvement looks really nice, but I don't think we can > just hardcode assumptions about bios in iomap->private. The easiest > would be to call back into the file systems for the freeing, but that > would add an indirect call. That's why it's an RFC - while it's not the prettiest, the ->ki_complete assigner is also the one that sets IOCB_ALLOC_CACHE, and hence it's not that hard to verify that it does IOCB_PUT_CACHE correctly too. That said, I would prefer a better way of passing the bio back. There are other optimizations that could be done if we do that. But I have no good ideas on how to do the passing differently right now. -- Jens Axboe