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

From: Nigel Cunningham
Date: Mon Jun 26 2006 - 19:29:40 EST


Return the number of pages currently in the pcp lists.

Signed-off-by: Nigel Cunningham <nigel@xxxxxxxxxxxx>

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;
+}
+

--
Nigel Cunningham nigel at suspend2 dot net
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/