Skip to content

Commit 18ea7e7

Browse files
gormanmtorvalds
authored andcommitted
mm: remember what the preferred zone is for zone_statistics
On NUMA, zone_statistics() is used to record events like numa hit, miss and foreign. It assumes that the first zone in a zonelist is the preferred zone. When multiple zonelists are replaced by one that is filtered, this is no longer the case. This patch records what the preferred zone is rather than assuming the first zone in the zonelist is it. This simplifies the reading of later patches in this set. Signed-off-by: Mel Gorman <mel@csn.ul.ie> Signed-off-by: Lee Schermerhorn <lee.schermerhorn@hp.com> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Mel Gorman <mel@csn.ul.ie> Reviewed-by: Christoph Lameter <clameter@sgi.com> Cc: Hugh Dickins <hugh@veritas.com> Cc: Nick Piggin <nickpiggin@yahoo.com.au> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 0e88460 commit 18ea7e7

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

‎include/linux/vmstat.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ static inline unsigned long node_page_state(int node,
174174
zone_page_state(&zones[ZONE_MOVABLE], item);
175175
}
176176

177-
extern void zone_statistics(struct zonelist *, struct zone *);
177+
extern void zone_statistics(struct zone *, struct zone *);
178178

179179
#else
180180

‎mm/page_alloc.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ void split_page(struct page *page, unsigned int order)
10501050
* we cheat by calling it from here, in the order > 0 path. Saves a branch
10511051
* or two.
10521052
*/
1053-
static struct page *buffered_rmqueue(struct zonelist *zonelist,
1053+
static struct page *buffered_rmqueue(struct zone *preferred_zone,
10541054
struct zone *zone, int order, gfp_t gfp_flags)
10551055
{
10561056
unsigned long flags;
@@ -1102,7 +1102,7 @@ static struct page *buffered_rmqueue(struct zonelist *zonelist,
11021102
}
11031103

11041104
__count_zone_vm_events(PGALLOC, zone, 1 << order);
1105-
zone_statistics(zonelist, zone);
1105+
zone_statistics(preferred_zone, zone);
11061106
local_irq_restore(flags);
11071107
put_cpu();
11081108

@@ -1383,7 +1383,7 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order,
13831383
struct zone **z;
13841384
struct page *page = NULL;
13851385
int classzone_idx = zone_idx(zonelist->zones[0]);
1386-
struct zone *zone;
1386+
struct zone *zone, *preferred_zone;
13871387
nodemask_t *allowednodes = NULL;/* zonelist_cache approximation */
13881388
int zlc_active = 0; /* set if using zonelist_cache */
13891389
int did_zlc_setup = 0; /* just call zlc_setup() one time */
@@ -1395,6 +1395,7 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order,
13951395
* See also cpuset_zone_allowed() comment in kernel/cpuset.c.
13961396
*/
13971397
z = zonelist->zones;
1398+
preferred_zone = *z;
13981399

13991400
do {
14001401
/*
@@ -1433,7 +1434,7 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order,
14331434
}
14341435
}
14351436

1436-
page = buffered_rmqueue(zonelist, zone, order, gfp_mask);
1437+
page = buffered_rmqueue(preferred_zone, zone, order, gfp_mask);
14371438
if (page)
14381439
break;
14391440
this_zone_full:

‎mm/vmstat.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,13 +364,13 @@ void refresh_cpu_vm_stats(int cpu)
364364
*
365365
* Must be called with interrupts disabled.
366366
*/
367-
void zone_statistics(struct zonelist *zonelist, struct zone *z)
367+
void zone_statistics(struct zone *preferred_zone, struct zone *z)
368368
{
369-
if (z->zone_pgdat == zonelist->zones[0]->zone_pgdat) {
369+
if (z->zone_pgdat == preferred_zone->zone_pgdat) {
370370
__inc_zone_state(z, NUMA_HIT);
371371
} else {
372372
__inc_zone_state(z, NUMA_MISS);
373-
__inc_zone_state(zonelist->zones[0], NUMA_FOREIGN);
373+
__inc_zone_state(preferred_zone, NUMA_FOREIGN);
374374
}
375375
if (z->node == numa_node_id())
376376
__inc_zone_state(z, NUMA_LOCAL);

0 commit comments

Comments
 (0)