From: David Rientjes <rientjes@google.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>,
linux-mm@kvack.org, hannes@cmpxchg.org, mel@csn.ul.ie,
ming.lei@canonical.com
Subject: Re: [patch 2/6] mm/page_alloc.c:__alloc_pages_nodemask(): don't alter arg gfp_mask
Date: Wed, 17 Dec 2014 16:22:30 -0800 (PST) [thread overview]
Message-ID: <alpine.DEB.2.10.1412171608300.16260@chino.kir.corp.google.com> (raw)
In-Reply-To: <20141215154323.08cc8e7d18ef78f19e5ecce2@linux-foundation.org>
On Mon, 15 Dec 2014, Andrew Morton wrote:
> Well it was already wrong because the first allocation attempt uses
> gfp_mask|__GFP_HARDWAL, but we only trace gfp_mask.
>
> This?
>
> --- a/mm/page_alloc.c~mm-page_allocc-__alloc_pages_nodemask-dont-alter-arg-gfp_mask-fix
> +++ a/mm/page_alloc.c
> @@ -2877,6 +2877,7 @@ __alloc_pages_nodemask(gfp_t gfp_mask, u
> unsigned int cpuset_mems_cookie;
> int alloc_flags = ALLOC_WMARK_LOW|ALLOC_CPUSET|ALLOC_FAIR;
> int classzone_idx;
> + gfp_t mask;
>
> gfp_mask &= gfp_allowed_mask;
>
> @@ -2910,23 +2911,24 @@ retry_cpuset:
> classzone_idx = zonelist_zone_idx(preferred_zoneref);
>
> /* First allocation attempt */
> - page = get_page_from_freelist(gfp_mask|__GFP_HARDWALL, nodemask, order,
> - zonelist, high_zoneidx, alloc_flags,
> - preferred_zone, classzone_idx, migratetype);
> + mask = gfp_mask|__GFP_HARDWALL;
> + page = get_page_from_freelist(mask, nodemask, order, zonelist,
> + high_zoneidx, alloc_flags, preferred_zone,
> + classzone_idx, migratetype);
> if (unlikely(!page)) {
> /*
> * Runtime PM, block IO and its error handling path
> * can deadlock because I/O on the device might not
> * complete.
> */
> - gfp_t mask = memalloc_noio_flags(gfp_mask);
> + mask = memalloc_noio_flags(gfp_mask);
>
> page = __alloc_pages_slowpath(mask, order,
> zonelist, high_zoneidx, nodemask,
> preferred_zone, classzone_idx, migratetype);
> }
>
> - trace_mm_page_alloc(page, order, gfp_mask, migratetype);
> + trace_mm_page_alloc(page, order, mask, migratetype);
>
> out:
> /*
I'm not sure I understand why we need a local variable to hold the context
mask vs. what was passed to the function. We should only be allocating
with a single gfp_mask that is passed to the function and modify it as
necessary, and that becomes the context mask that can be traced.
The above is wrong because it unconditionally sets __GFP_HARDWALL as the
gfp mask for __alloc_pages_slowpath() when we actually only want that for
the first allocation attempt, it's needed for the implementation of
__cpuset_node_allowed().
The page allocator slowpath is always called from the fastpath if the
first allocation didn't succeed, so we don't know from which we allocated
the page at this tracepoint.
I'm afraid the original code before either of these patches was more
correct. The use of memalloc_noio_flags() for "subsequent allocation
attempts" doesn't really matter since neither __GFP_FS nor __GFP_IO
matters for fastpath allocation (we aren't reclaiming).
--
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:[~2014-12-18 0:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-15 23:03 akpm
2014-12-15 23:32 ` Yasuaki Ishimatsu
2014-12-15 23:43 ` Andrew Morton
2014-12-16 0:08 ` Yasuaki Ishimatsu
2014-12-17 10:47 ` Vlastimil Babka
2014-12-18 0:22 ` David Rientjes [this message]
2014-12-18 0:29 ` Andrew Morton
2014-12-18 0:51 ` David Rientjes
2014-12-18 21:10 ` Andrew Morton
2015-01-06 17:58 ` Vlastimil Babka
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=alpine.DEB.2.10.1412171608300.16260@chino.kir.corp.google.com \
--to=rientjes@google.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=isimatu.yasuaki@jp.fujitsu.com \
--cc=linux-mm@kvack.org \
--cc=mel@csn.ul.ie \
--cc=ming.lei@canonical.com \
/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