2010-07-07 11:12:45 +00:00
|
|
|
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
|
|
|
|
Subject: [PATCH 01/31] mm: serialize access to min_free_kbytes
|
|
|
|
Patch-mainline: not yet
|
|
|
|
|
|
|
|
There is a small race between the procfs caller and the memory hotplug caller
|
|
|
|
of setup_per_zone_wmarks(). Not a big deal, but the next patch will add yet
|
|
|
|
another caller. Time to close the gap.
|
|
|
|
|
|
|
|
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
|
|
|
|
Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de>
|
|
|
|
---
|
|
|
|
mm/page_alloc.c | 16 +++++++++++++---
|
|
|
|
1 file changed, 13 insertions(+), 3 deletions(-)
|
|
|
|
|
|
|
|
--- a/mm/page_alloc.c
|
|
|
|
+++ b/mm/page_alloc.c
|
2011-04-19 20:09:59 +00:00
|
|
|
@@ -165,6 +165,7 @@ static char * const zone_names[MAX_NR_ZO
|
2010-07-07 11:12:45 +00:00
|
|
|
"Movable",
|
|
|
|
};
|
|
|
|
|
|
|
|
+static DEFINE_SPINLOCK(min_free_lock);
|
|
|
|
int min_free_kbytes = 1024;
|
|
|
|
|
|
|
|
static unsigned long __meminitdata nr_kernel_pages;
|
2011-04-19 20:09:59 +00:00
|
|
|
@@ -4845,13 +4846,13 @@ static void setup_per_zone_lowmem_reserv
|
2010-07-07 11:12:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
- * setup_per_zone_wmarks - called when min_free_kbytes changes
|
|
|
|
+ * __setup_per_zone_wmarks - called when min_free_kbytes changes
|
|
|
|
* or when memory is hot-{added|removed}
|
|
|
|
*
|
|
|
|
* Ensures that the watermark[min,low,high] values for each zone are set
|
|
|
|
* correctly with respect to min_free_kbytes.
|
|
|
|
*/
|
|
|
|
-void setup_per_zone_wmarks(void)
|
|
|
|
+static void __setup_per_zone_wmarks(void)
|
|
|
|
{
|
|
|
|
unsigned long pages_min = min_free_kbytes >> (PAGE_SHIFT - 10);
|
|
|
|
unsigned long lowmem_pages = 0;
|
2011-04-19 20:09:59 +00:00
|
|
|
@@ -4949,6 +4950,15 @@ static void __init setup_per_zone_inacti
|
2010-07-07 11:12:45 +00:00
|
|
|
calculate_zone_inactive_ratio(zone);
|
|
|
|
}
|
|
|
|
|
|
|
|
+void setup_per_zone_wmarks(void)
|
|
|
|
+{
|
|
|
|
+ unsigned long flags;
|
|
|
|
+
|
|
|
|
+ spin_lock_irqsave(&min_free_lock, flags);
|
|
|
|
+ __setup_per_zone_wmarks();
|
|
|
|
+ spin_unlock_irqrestore(&min_free_lock, flags);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
/*
|
|
|
|
* Initialise min_free_kbytes.
|
|
|
|
*
|
2011-04-19 20:09:59 +00:00
|
|
|
@@ -4984,7 +4994,7 @@ static int __init init_per_zone_wmark_mi
|
2010-07-07 11:12:45 +00:00
|
|
|
min_free_kbytes = 128;
|
|
|
|
if (min_free_kbytes > 65536)
|
|
|
|
min_free_kbytes = 65536;
|
|
|
|
- setup_per_zone_wmarks();
|
|
|
|
+ __setup_per_zone_wmarks();
|
|
|
|
setup_per_zone_lowmem_reserve();
|
|
|
|
setup_per_zone_inactive_ratio();
|
|
|
|
return 0;
|