Sorry for the late reply. Ritesh Harjani <ritesh.list@xxxxxxxxx> 于2025年8月23日周六 12:35写道: > > Matthew Wilcox <willy@xxxxxxxxxxxxx> writes: > > > On Fri, Aug 22, 2025 at 09:37:32PM +0530, Ritesh Harjani wrote: > >> Matthew Wilcox <willy@xxxxxxxxxxxxx> writes: > >> > On Fri, Aug 22, 2025 at 08:05:50AM -0700, Darrick J. Wong wrote: > >> >> Is there a reason /not/ to use the per-cpu bio cache unconditionally? > >> > > >> > AIUI it's not safe because completions might happen on a different CPU > >> > from the submission. > >> > >> At max the bio de-queued from cpu X can be returned to cpu Y cache, this > >> shouldn't be unsafe right? e.g. bio_put_percpu_cache(). > >> Not optimal for performance though. > >> > >> Also even for io-uring the IRQ completions (non-polling requests) can > >> get routed to a different cpu then the submitting cpu, correct? > >> Then the completions (bio completion processing) are handled via IPIs on > >> the submtting cpu or based on the cache topology, right? > >> > >> > At least, there's nowhere that sets REQ_ALLOC_CACHE unconditionally. > >> > > >> > This could do with some better documentation .. > >> > >> Agreed. Looking at the history this got added for polling mode first but > >> later got enabled for even irq driven io-uring rw requests [1]. So it > >> make sense to understand if this can be added unconditionally for DIO > >> requests or not. > > > > So why does the flag now exist at all? Why not use the cache > > unconditionally? I think it's a history problem. When REQ_ALLOC_CACHE flag first add in https://lore.kernel.org/all/20220324203526.62306-2-snitzer@xxxxxxxxxx/, it's rename from BIOSET_PERCPU_CACHE, only work for iopoll, "If REQ_ALLOC_CACHE is set, the final put of the bio MUST be done from process context, not hard/soft IRQ." and from https://lore.kernel.org/all/cover.1667384020.git.asml.silence@xxxxxxxxx/, remove this limit, percpu bio caching can used for IRQ I/O. "Currently, it's only enabled for previous REQ_ALLOC_CACHE users but will be turned on system-wide later." > > I am hoping the author of this patch or folks with io-uring expertise > (which added the per-cpu bio cache in the first place) could answer > this better. i.e. > > Now that per-cpu bio cache is being used by io-uring rw requests for > both polled and non-polled I/O. Does that mean, we can kill > IOCB_ALLOC_CACHE check from iomap dio path completely and use per-cpu > bio cache unconditionally by passing REQ_ALLOC_CACHE flag? That means > all DIO requests via iomap can now use this per-cpu bio cache and not > just the one initiated via io-uring path. > > Or are there still restrictions in using this per-cpu bio cache, which > limits it to be only used via io-uring path? If yes, what are they? And > can this be documented somewhere? No restrictions for now, I think we can enable this by default. Maybe better solution is modify in bio.c? Let me do some test first. > > -ritesh >