From: "Raphael S. Carvalho" <raphaelsc@scylladb.com>
To: linux-xfs@vger.kernel.org, linux-mm@kvack.org,
linux-fsdevel@vger.kernel.org
Cc: djwong@kernel.org, Dave Chinner <david@fromorbit.com>,
hch@lst.de, Avi Kivity <avi@scylladb.com>
Subject: Re: Possible regression with buffered writes + NOWAIT behavior, under memory pressure
Date: Mon, 10 Feb 2025 15:34:07 -0300 [thread overview]
Message-ID: <CAKhLTr1-UpCWuMk2KsJ9=BLSADiRmDAtBU7LoCq6Zq4JFN2LgA@mail.gmail.com> (raw)
In-Reply-To: <CAKhLTr08CK1pPbnahvwJWu-k1wnwVV4ztVMGrmXRY5Yuz03YeA@mail.gmail.com>
> > A possible way to fix it is this one-liner, but I am not well versed
> > in this area, so someone may end up suggesting a better fix:
> > diff --git a/mm/filemap.c b/mm/filemap.c
> > index 804d7365680c..9e698a619545 100644
> > --- a/mm/filemap.c
> > +++ b/mm/filemap.c
> > @@ -1964,7 +1964,7 @@ struct folio *__filemap_get_folio(struct
> > address_space *mapping, pgoff_t index,
> > do {
> > gfp_t alloc_gfp = gfp;
> >
> > - err = -ENOMEM;
> > + err = (fgp_flags & FGP_NOWAIT) ? -ENOMEM : -EAGAIN;
>
> Sorry, I actually meant this:
> + err = (fgp_flags & FGP_NOWAIT) ? -EAGAIN : -ENOMEM;
Digging a bit more, I realized a better patch (assuming regression
indeed exists) is this one, since it accounts for ENOMEM coming from
filemap_add_folio, which might allocate in xas_split_alloc() under
same fgp flags:
diff --git a/mm/filemap.c b/mm/filemap.c
index 804d7365680c..dcf1f57e0a9a 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1984,6 +1984,8 @@ struct folio *__filemap_get_folio(struct
address_space *mapping, pgoff_t index,
folio = NULL;
} while (order-- > min_order);
+ if ((fgp_flags & FGP_NOWAIT) && err == -ENOMEM)
+ return ERR_PTR(-EAGAIN);
if (err == -EEXIST)
goto repeat;
if (err)
next prev parent reply other threads:[~2025-02-10 18:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-10 18:12 Raphael S. Carvalho
2025-02-10 18:20 ` Raphael S. Carvalho
2025-02-10 18:34 ` Raphael S. Carvalho [this message]
2025-02-10 21:09 ` Dave Chinner
2025-02-10 21:18 ` Matthew Wilcox
2025-02-10 21:27 ` Dave Chinner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAKhLTr1-UpCWuMk2KsJ9=BLSADiRmDAtBU7LoCq6Zq4JFN2LgA@mail.gmail.com' \
--to=raphaelsc@scylladb.com \
--cc=avi@scylladb.com \
--cc=david@fromorbit.com \
--cc=djwong@kernel.org \
--cc=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox