From: Michal Hocko <mhocko@kernel.org>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: js1304@gmail.com, Andrew Morton <akpm@linux-foundation.org>,
Christoph Lameter <cl@linux.com>,
Pekka Enberg <penberg@kernel.org>,
David Rientjes <rientjes@google.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Mel Gorman <mgorman@techsingularity.net>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>
Subject: Re: [PATCH 2/2] mm/slub: don't use reserved memory for optimistic try
Date: Wed, 6 Sep 2017 11:20:14 +0200 [thread overview]
Message-ID: <20170906092014.6z73x5mfxn32lbg6@dhcp22.suse.cz> (raw)
In-Reply-To: <f3af7a0e-d04d-e47d-12c6-8e379d04265a@suse.cz>
On Wed 06-09-17 10:10:22, Vlastimil Babka wrote:
> On 09/06/2017 06:37 AM, js1304@gmail.com wrote:
> > From: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> >
> > High-order atomic allocation is difficult to succeed since we cannot
> > reclaim anything in this context. So, we reserves the pageblock for
> > this kind of request.
> >
> > In slub, we try to allocate higher-order page more than it actually
> > needs in order to get the best performance. If this optimistic try is
> > used with GFP_ATOMIC, alloc_flags will be set as ALLOC_HARDER and
> > the pageblock reserved for high-order atomic allocation would be used.
> > Moreover, this request would reserve the MIGRATE_HIGHATOMIC pageblock
> > ,if succeed, to prepare further request. It would not be good to use
> > MIGRATE_HIGHATOMIC pageblock in terms of fragmentation management
> > since it unconditionally set a migratetype to request's migratetype
> > when unreserving the pageblock without considering the migratetype of
> > used pages in the pageblock.
> >
> > This is not what we don't intend so fix it by unconditionally masking
> > out __GFP_ATOMIC in order to not set ALLOC_HARDER.
> >
> > And, it is also undesirable to use reserved memory for optimistic try
> > so mask out __GFP_HIGH. This patch also adds __GFP_NOMEMALLOC since
> > we don't want to use the reserved memory for optimistic try even if
> > the user has PF_MEMALLOC flag.
> >
> > Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> > ---
> > include/linux/gfp.h | 1 +
> > mm/page_alloc.c | 8 ++++++++
> > mm/slub.c | 6 ++----
> > 3 files changed, 11 insertions(+), 4 deletions(-)
> >
> > diff --git a/include/linux/gfp.h b/include/linux/gfp.h
> > index f780718..1f5658e 100644
> > --- a/include/linux/gfp.h
> > +++ b/include/linux/gfp.h
> > @@ -568,6 +568,7 @@ extern gfp_t gfp_allowed_mask;
> >
> > /* Returns true if the gfp_mask allows use of ALLOC_NO_WATERMARK */
> > bool gfp_pfmemalloc_allowed(gfp_t gfp_mask);
> > +gfp_t gfp_drop_reserves(gfp_t gfp_mask);
> >
> > extern void pm_restrict_gfp_mask(void);
> > extern void pm_restore_gfp_mask(void);
> > diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> > index 6dbc49e..0f34356 100644
> > --- a/mm/page_alloc.c
> > +++ b/mm/page_alloc.c
> > @@ -3720,6 +3720,14 @@ bool gfp_pfmemalloc_allowed(gfp_t gfp_mask)
> > return !!__gfp_pfmemalloc_flags(gfp_mask);
> > }
> >
> > +gfp_t gfp_drop_reserves(gfp_t gfp_mask)
> > +{
> > + gfp_mask &= ~(__GFP_HIGH | __GFP_ATOMIC);
> > + gfp_mask |= __GFP_NOMEMALLOC;
> > +
> > + return gfp_mask;
> > +}
> > +
>
> I think it's wasteful to do a function call for this, inline definition
> in header would be better (gfp_pfmemalloc_allowed() is different as it
> relies on a rather heavyweight __gfp_pfmemalloc_flags().
Agreed. If you do that, feel free to add
Acked-by: Michal Hocko <mhocko@suse.com>
--
Michal Hocko
SUSE Labs
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2017-09-06 9:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-06 4:37 [PATCH 1/2] mm/slub: wake up kswapd for initial high order allocation js1304
2017-09-06 4:37 ` [PATCH 2/2] mm/slub: don't use reserved memory for optimistic try js1304
2017-09-06 8:10 ` Vlastimil Babka
2017-09-06 9:20 ` Michal Hocko [this message]
2017-09-06 15:55 ` Christopher Lameter
2017-09-06 8:07 ` [PATCH 1/2] mm/slub: wake up kswapd for initial high order allocation Vlastimil Babka
2017-09-06 15:59 ` Christopher Lameter
2017-09-06 17:21 ` 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=20170906092014.6z73x5mfxn32lbg6@dhcp22.suse.cz \
--to=mhocko@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=js1304@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=penberg@kernel.org \
--cc=rientjes@google.com \
--cc=vbabka@suse.cz \
/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