Cleanup per cpu pages a bit - Replace ARRAY_SIZE(xxx->pcp) with NR_PER_CPU_PAGES - Use string array for temperature descriptions. - Index pcp arrays with PER_CPU_HOT and PER_CPU_COLD - Use common index i to index pcps in show_free_areas Signed-off-by: Christoph Lameter Index: linux-2.6.16-rc1-mm3/mm/page_alloc.c =================================================================== --- linux-2.6.16-rc1-mm3.orig/mm/page_alloc.c 2006-01-25 10:02:09.000000000 -0800 +++ linux-2.6.16-rc1-mm3/mm/page_alloc.c 2006-01-26 10:19:32.000000000 -0800 @@ -610,7 +610,7 @@ void drain_remote_pages(void) continue; pset = zone_pcp(zone, smp_processor_id()); - for (i = 0; i < ARRAY_SIZE(pset->pcp); i++) { + for (i = 0; i < NR_PER_CPU_PAGES; i++) { struct per_cpu_pages *pcp; pcp = &pset->pcp[i]; @@ -633,7 +633,7 @@ static void __drain_pages(unsigned int c struct per_cpu_pageset *pset; pset = zone_pcp(zone, cpu); - for (i = 0; i < ARRAY_SIZE(pset->pcp); i++) { + for (i = 0; i < NR_PER_CPU_PAGES; i++) { struct per_cpu_pages *pcp; pcp = &pset->pcp[i]; @@ -1452,6 +1452,8 @@ void si_meminfo_node(struct sysinfo *val #define K(x) ((x) << (PAGE_SHIFT-10)) +static const char *temperature_descr[] = { "cold", "hot" }; + /* * Show free area list (used inside shift_scroll-lock stuff) * We also calculate the percentage fragmentation. We do this by counting the @@ -1460,7 +1462,7 @@ void si_meminfo_node(struct sysinfo *val void show_free_areas(void) { struct page_state ps; - int cpu, temperature; + int cpu; unsigned long active; unsigned long inactive; unsigned long free; @@ -1478,16 +1480,17 @@ void show_free_areas(void) for_each_online_cpu(cpu) { struct per_cpu_pageset *pageset; + int i; pageset = zone_pcp(zone, cpu); - for (temperature = 0; temperature < 2; temperature++) + for (i = 0; i < NR_PER_CPU_PAGES; i++) printk("cpu %d %s: high %d, batch %d used:%d\n", cpu, - temperature ? "cold" : "hot", - pageset->pcp[temperature].high, - pageset->pcp[temperature].batch, - pageset->pcp[temperature].count); + temperature_descr[i], + pageset->pcp[i].high, + pageset->pcp[i].batch, + pageset->pcp[i].count); } } @@ -1929,13 +1932,13 @@ inline void setup_pageset(struct per_cpu memset(p, 0, sizeof(*p)); - pcp = &p->pcp[0]; /* hot */ + pcp = &p->pcp[PER_CPU_HOT]; pcp->count = 0; pcp->high = 6 * batch; pcp->batch = max(1UL, 1 * batch); INIT_LIST_HEAD(&pcp->list); - pcp = &p->pcp[1]; /* cold*/ + pcp = &p->pcp[PER_CPU_COLD]; pcp->count = 0; pcp->high = 2 * batch; pcp->batch = max(1UL, batch/2); @@ -2342,13 +2345,13 @@ static int zoneinfo_show(struct seq_file int j; pageset = zone_pcp(zone, i); - for (j = 0; j < ARRAY_SIZE(pageset->pcp); j++) { + for (j = 0; j < NR_PER_CPU_PAGES; j++) { if (pageset->pcp[j].count) break; } - if (j == ARRAY_SIZE(pageset->pcp)) + if (j == NR_PER_CPU_PAGES) continue; - for (j = 0; j < ARRAY_SIZE(pageset->pcp); j++) { + for (j = 0; j < NR_PER_CPU_PAGES; j++) { seq_printf(m, "\n cpu: %i pcp: %i" "\n count: %i" Index: linux-2.6.16-rc1-mm3/include/linux/mmzone.h =================================================================== --- linux-2.6.16-rc1-mm3.orig/include/linux/mmzone.h 2006-01-25 10:02:09.000000000 -0800 +++ linux-2.6.16-rc1-mm3/include/linux/mmzone.h 2006-01-26 10:14:35.000000000 -0800 @@ -22,6 +22,12 @@ #define MAX_ORDER CONFIG_FORCE_MAX_ZONEORDER #endif +#define NR_PER_CPU_PAGES 2 + +/* Types of per cpu pages */ +#define PER_CPU_HOT 0 +#define PER_CPU_COLD 1 + struct free_area { struct list_head free_list; unsigned long nr_free; @@ -52,7 +58,7 @@ struct per_cpu_pages { }; struct per_cpu_pageset { - struct per_cpu_pages pcp[2]; /* 0: hot. 1: cold */ + struct per_cpu_pages pcp[NR_PER_CPU_PAGES]; #ifdef CONFIG_NUMA unsigned long numa_hit; /* allocated in intended node */ unsigned long numa_miss; /* allocated in non intended node */