Skip to content

Commit

Permalink
mm: page_alloc: avoid wakeup kswapd on the unintended node
Browse files Browse the repository at this point in the history
When entering the page_alloc slowpath, we wakeup kswapd on every pgdat
according to the zonelist and high_zoneidx.  However, this doesn't take
nodemask into account, and could prematurely wakeup kswapd on some
unintended nodes.

This patch uses for_each_zone_zonelist_nodemask() instead of
for_each_zone_zonelist() in wake_all_kswapds() to avoid the above
situation.

Signed-off-by: Weijie Yang <weijie.yang@samsung.com>
Acked-by: Mel Gorman <mgorman@suse.de>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Weijie Yang authored and torvalds committed Oct 10, 2014
1 parent 81d1b09 commit 7ade3c9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions mm/page_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2471,12 +2471,14 @@ __alloc_pages_high_priority(gfp_t gfp_mask, unsigned int order,
static void wake_all_kswapds(unsigned int order,
struct zonelist *zonelist,
enum zone_type high_zoneidx,
struct zone *preferred_zone)
struct zone *preferred_zone,
nodemask_t *nodemask)
{
struct zoneref *z;
struct zone *zone;

for_each_zone_zonelist(zone, z, zonelist, high_zoneidx)
for_each_zone_zonelist_nodemask(zone, z, zonelist,
high_zoneidx, nodemask)
wakeup_kswapd(zone, order, zone_idx(preferred_zone));
}

Expand Down Expand Up @@ -2574,7 +2576,8 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,

restart:
if (!(gfp_mask & __GFP_NO_KSWAPD))
wake_all_kswapds(order, zonelist, high_zoneidx, preferred_zone);
wake_all_kswapds(order, zonelist, high_zoneidx,
preferred_zone, nodemask);

/*
* OK, we're below the kswapd watermark and have kicked background
Expand Down

0 comments on commit 7ade3c9

Please sign in to comment.