[Suspend2][ 02/20] [Suspend2] Get number of pcp pages.

Nigel Cunningham
2006-06-26T23:29:58Z

Return the number of pages currently in the pcp lists.

Signed-off-by: Nigel Cunningham <nigel@suspend2.net>

kernel/power/prepare_image.c | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/kernel/power/prepare_image.c b/kernel/power/prepare_image.c
index 9e13418..9f6e96d 100644
--- a/kernel/power/prepare_image.c
+++ b/kernel/power/prepare_image.c
@@ -40,3 +40,36 @@ static long storage_allocated = 0;
static long storage_available = 0;
long extra_pd1_pages_allowance = MIN_EXTRA_PAGES_ALLOWANCE;

+/*
+ * num_pcp_pages: Count pcp pages.
+ */
+static long num_pcp_pages(void)
+{
+ struct zone *zone;
+ long result = 0, i = 0;
+
+ /* PCP lists */
+ for_each_zone(zone) {
+ struct per_cpu_pageset *pset;
+ int cpu;
+
+ if (!zone->present_pages)
+ continue;
+
+ for (cpu = 0; cpu < NR_CPUS; cpu++) {
+ if (!cpu_possible(cpu))
+ continue;
+
+ pset = zone_pcp(zone, cpu);
+
+ for (i = 0; i < ARRAY_SIZE(pset->pcp); i++) {
+ struct per_cpu_pages *pcp;
+
+ pcp = &(pset->pcp[i]);
+ result += pcp->count;
+ }
+ }
+ }
+ return result;