]> git.hungrycats.org Git - linux/commitdiff
[PATCH] introduce __drain_pages() to take a CPU number
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 8 Mar 2004 14:05:53 +0000 (06:05 -0800)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Mon, 8 Mar 2004 14:05:53 +0000 (06:05 -0800)
Extracts core of drain_pages() for hotcpu use.  Trivial.

Hotplug CPU needs to drain pages on a downed CPU (usually it's the
current cpu).  Introduce "__drain_pages", make the CPU an argument,
and expose it if CONFIG_HOTPLUG_CPU as well as CONFIG_PM.

mm/page_alloc.c

index 6ac432fb6029a3a85c95f5fcb78367df02bde186..54c231cf8ba6bd1a96f9cc5d6db5de6881444108 100644 (file)
@@ -390,6 +390,27 @@ static int rmqueue_bulk(struct zone *zone, unsigned int order,
        return allocated;
 }
 
+#if defined(CONFIG_PM) || defined(CONFIG_HOTPLUG_CPU)
+static void __drain_pages(unsigned int cpu)
+{
+       struct zone *zone;
+       int i;
+
+       for_each_zone(zone) {
+               struct per_cpu_pageset *pset;
+
+               pset = &zone->pageset[cpu];
+               for (i = 0; i < ARRAY_SIZE(pset->pcp); i++) {
+                       struct per_cpu_pages *pcp;
+
+                       pcp = &pset->pcp[i];
+                       pcp->count -= free_pages_bulk(zone, pcp->count,
+                                               &pcp->list, 0);
+               }
+       }
+}
+#endif /* CONFIG_PM || CONFIG_HOTPLUG_CPU */
+
 #ifdef CONFIG_PM
 int is_head_of_free_region(struct page *page)
 {
@@ -419,22 +440,9 @@ int is_head_of_free_region(struct page *page)
 void drain_local_pages(void)
 {
        unsigned long flags;
-       struct zone *zone;
-       int i;
 
        local_irq_save(flags);  
-       for_each_zone(zone) {
-               struct per_cpu_pageset *pset;
-
-               pset = &zone->pageset[smp_processor_id()];
-               for (i = 0; i < ARRAY_SIZE(pset->pcp); i++) {
-                       struct per_cpu_pages *pcp;
-
-                       pcp = &pset->pcp[i];
-                       pcp->count -= free_pages_bulk(zone, pcp->count,
-                                               &pcp->list, 0);
-               }
-       }
+       __drain_pages(smp_processor_id());
        local_irq_restore(flags);       
 }
 #endif /* CONFIG_PM */