]> Git Repo - linux.git/commitdiff
mm/hotplug: free zone->pageset when a zone becomes empty
authorJiang Liu <[email protected]>
Tue, 31 Jul 2012 23:43:32 +0000 (16:43 -0700)
committerLinus Torvalds <[email protected]>
Wed, 1 Aug 2012 01:42:44 +0000 (18:42 -0700)
When a zone becomes empty after memory offlining, free zone->pageset.
Otherwise it will cause memory leak when adding memory to the empty zone
again because build_all_zonelists() will allocate zone->pageset for an
empty zone.

Signed-off-by: Jiang Liu <[email protected]>
Signed-off-by: Wei Wang <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Minchan Kim <[email protected]>
Cc: Rusty Russell <[email protected]>
Cc: Yinghai Lu <[email protected]>
Cc: Tony Luck <[email protected]>
Cc: KAMEZAWA Hiroyuki <[email protected]>
Cc: KOSAKI Motohiro <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Keping Chen <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
include/linux/mm.h
mm/memory_hotplug.c
mm/page_alloc.c

index 3955bedeeed1c3c21cd2e573410d7e70fa3b03a4..7c6dfd2faa696839b775d072365e84d800cc01c6 100644 (file)
@@ -1331,6 +1331,7 @@ void warn_alloc_failed(gfp_t gfp_mask, int order, const char *fmt, ...);
 extern void setup_per_cpu_pageset(void);
 
 extern void zone_pcp_update(struct zone *zone);
+extern void zone_pcp_reset(struct zone *zone);
 
 /* nommu.c */
 extern atomic_long_t mmap_pages_allocated;
index 597d371329d390267e1ad194e7979bc79466cf0b..3ad25f9d1fc134dc09e9672fad40f508e12e9502 100644 (file)
@@ -966,6 +966,9 @@ repeat:
 
        init_per_zone_wmark_min();
 
+       if (!populated_zone(zone))
+               zone_pcp_reset(zone);
+
        if (!node_present_pages(node)) {
                node_clear_state(node, N_HIGH_MEMORY);
                kswapd_stop(node);
index 9ad6866ac49c0425d815ddb747a04cbece93506c..9c9a31665a78e3301fd5de4756a2172f424fd7da 100644 (file)
@@ -5894,6 +5894,19 @@ void free_contig_range(unsigned long pfn, unsigned nr_pages)
 #endif
 
 #ifdef CONFIG_MEMORY_HOTREMOVE
+void zone_pcp_reset(struct zone *zone)
+{
+       unsigned long flags;
+
+       /* avoid races with drain_pages()  */
+       local_irq_save(flags);
+       if (zone->pageset != &boot_pageset) {
+               free_percpu(zone->pageset);
+               zone->pageset = &boot_pageset;
+       }
+       local_irq_restore(flags);
+}
+
 /*
  * All pages in the range must be isolated before calling this.
  */
This page took 0.073598 seconds and 4 git commands to generate.