On Mon, Feb 10, 2025 at 09:18:04PM +0000, Matthew Wilcox wrote: > On Tue, Feb 11, 2025 at 08:09:31AM +1100, Dave Chinner wrote: > > Better to only do the FGP_NOWAIT check when a failure occurs; that > > puts it in the slow path rather than having to evaluate it > > unnecessarily every time through the function/loop. i.e. > > > > folio = filemap_alloc_folio(gfp, order); > > - if (!folio) > > - return ERR_PTR(-ENOMEM); > > + if (!folio) { > > + if (fgp_flags & FGP_NOWAIT) > > + err = -EAGAIN; > > + else > > + err = -ENOMEM; > > + continue; > > + } > > Or would we be better off handling ENOMEM the same way we handle EAGAIN? > eg something like: > > +++ b/io_uring/io_uring.c > @@ -1842,7 +1842,7 @@ void io_wq_submit_work(struct io_wq_work *work) > > do { > ret = io_issue_sqe(req, issue_flags); > - if (ret != -EAGAIN) > + if (ret != -EAGAIN || ret != -ENOMEM) > break; This still allows -ENOMEM to escape to userspace instead of -EAGAIN via pwritev2(RWF_NOWAIT) and AIO write interfaces. -Dave. -- Dave Chinner david@xxxxxxxxxxxxx