From: Mel Gorman <mgorman@techsingularity.net>
To: NeilBrown <neilb@suse.de>
Cc: Linux-MM <linux-mm@kvack.org>,
Andrew Morton <akpm@linux-foundation.org>,
Michal Hocko <mhocko@suse.com>,
Thierry Reding <thierry.reding@gmail.com>,
Matthew Wilcox <willy@infradead.org>,
Vlastimil Babka <vbabka@suse.cz>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/6] mm/page_alloc: Explicitly record high-order atomic allocations in alloc_flags
Date: Mon, 5 Dec 2022 10:27:21 +0000 [thread overview]
Message-ID: <20221205102721.zitekvbhvylogtnv@techsingularity.net> (raw)
In-Reply-To: <167021743246.8267.14900064704332224542@noble.neil.brown.name>
On Mon, Dec 05, 2022 at 04:17:12PM +1100, NeilBrown wrote:
>
> Hi Mel,
> thanks a lot for doing this!
My pleasure.
> I tried reviewing it but "HIGHATOMIC" is new to me and I quickly got
> lost :-(
That's ok, HIGHATOMIC reserves are obscure and internal to the
allocator. It's almost as obscure as granting access to reserves for RT
tasks with the only difference being a lack of data on what sort of RT
tasks needed extra privileges back in the early 2000's but I happened to
remember why highatomic reserves were introduced. It was introduced when
fragmentation avoidance triggered high-order atomic allocations failures
that "happened to work" by accident before fragmentation avoidance (details
in 0aaa29a56e4f). IIRC, there were a storm of bugs, mostly on small embedded
platforms where devices without an IOMMU relied on high-order atomics
to work so a small reserve was created. I was concerned your patch would
trigger this class of bug again even though it might take a few years to
show up as embedded platforms tend to stay on old kernels for ages.
The main point of this patch is identifying these high-order atomic
allocations without relying on __GFP_ATOMIC but it should not be necessary
to understand how high-order atomic reserves work. They still work the
same way, access is just granted differently.
> Maybe one day I'll work it out - now that several names are more
> meaningful, it will likely be easier.
>
> > @@ -4818,7 +4820,7 @@ static void wake_all_kswapds(unsigned int order, gfp_t gfp_mask,
> > }
> >
> > static inline unsigned int
> > -gfp_to_alloc_flags(gfp_t gfp_mask)
> > +gfp_to_alloc_flags(gfp_t gfp_mask, unsigned int order)
> > {
> > unsigned int alloc_flags = ALLOC_WMARK_MIN | ALLOC_CPUSET;
> >
> > @@ -4844,8 +4846,13 @@ gfp_to_alloc_flags(gfp_t gfp_mask)
> > * Not worth trying to allocate harder for __GFP_NOMEMALLOC even
> > * if it can't schedule.
> > */
> > - if (!(gfp_mask & __GFP_NOMEMALLOC))
> > + if (!(gfp_mask & __GFP_NOMEMALLOC)) {
> > alloc_flags |= ALLOC_HARDER;
> > +
> > + if (order > 0)
> > + alloc_flags |= ALLOC_HIGHATOMIC;
> > + }
> > +
> > /*
> > * Ignore cpuset mems for GFP_ATOMIC rather than fail, see the
> > * comment for __cpuset_node_allowed().
This is the most crucial hunk two hunks of the patch. If the series is
merged and we start seeing high-order atomic allocations failure, the key
will be to look at the gfp_flags and determine if this hunk is enough to
accurately detect high-order atomic allocations. If the GFP flags look ok,
then a tracing debugging patch will be created to dump gfp_flags every
time access is granted to high-atomic reserves to determine if access is
given incorrectly and under what circumstances.
The main concern I had with your original patch was that it was too
easy to grant access to high-atomic reserves for requests that were not
high-order atomics requests which might exhaust the reserves. The rest of
the series tries to improve the naming of the ALLOC flags and what they
mean. The actual changes to your patch are minimal. I could have started
with your patch and fixed it up but I preferred this ordering to reduce
use of __GFP_ATOMIC and then delete it. It should be bisection safe.
--
Mel Gorman
SUSE Labs
next prev parent reply other threads:[~2022-12-05 10:27 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-29 15:16 [RFC PATCH 0/6] Discard __GFP_ATOMIC Mel Gorman
2022-11-29 15:16 ` [PATCH 1/6] mm/page_alloc: Rename ALLOC_HIGH to ALLOC_MIN_RESERVE Mel Gorman
2022-12-08 16:12 ` Vlastimil Babka
2022-11-29 15:16 ` [PATCH 2/6] mm/page_alloc: Treat RT tasks similar to GFP_HIGH Mel Gorman
2022-12-08 16:16 ` Vlastimil Babka
2022-11-29 15:16 ` [PATCH 3/6] mm/page_alloc: Explicitly record high-order atomic allocations in alloc_flags Mel Gorman
2022-12-05 5:17 ` NeilBrown
2022-12-05 10:27 ` Mel Gorman [this message]
2022-12-08 16:51 ` Vlastimil Babka
2023-01-04 11:45 ` Mel Gorman
2022-11-29 15:16 ` [PATCH 4/6] mm/page_alloc: Explicitly define what alloc flags deplete min reserves Mel Gorman
2022-12-08 17:55 ` Vlastimil Babka
2023-01-04 12:02 ` Mel Gorman
2022-11-29 15:17 ` [PATCH 5/6] mm/page_alloc: Give GFP_ATOMIC and non-blocking allocations access to reserves Mel Gorman
2022-12-08 18:07 ` Vlastimil Babka
2023-01-04 12:03 ` Mel Gorman
2022-11-29 15:17 ` [PATCH 6/6] mm: discard __GFP_ATOMIC Mel Gorman
2022-12-08 18:17 ` Vlastimil Babka
2023-01-04 12:04 ` Mel Gorman
2023-01-05 13:49 ` Mike Rapoport
2023-01-05 21:53 ` NeilBrown
2023-01-06 9:35 ` Mel Gorman
2023-01-08 9:30 ` Mike Rapoport
2023-01-13 11:12 [PATCH 0/6 v3] Discard __GFP_ATOMIC Mel Gorman
2023-01-13 11:12 ` [PATCH 3/6] mm/page_alloc: Explicitly record high-order atomic allocations in alloc_flags Mel Gorman
2023-01-13 13:02 ` Michal Hocko
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=20221205102721.zitekvbhvylogtnv@techsingularity.net \
--to=mgorman@techsingularity.net \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=neilb@suse.de \
--cc=thierry.reding@gmail.com \
--cc=vbabka@suse.cz \
--cc=willy@infradead.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