aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorMel Gorman <mgorman@suse.de>2011-04-25 21:36:42 +0000
committerZiyan <jaraidaniel@gmail.com>2016-04-03 14:56:05 +0200
commitb81bc2d2bbf06b1794be8720563dcd29c2b7ff3f (patch)
treea325b778e8e07f8abeda1342df37de6fe16a2097 /mm
parente0196c482af5541231d133e244f031f43e98a59d (diff)
downloadkernel_samsung_tuna-b81bc2d2bbf06b1794be8720563dcd29c2b7ff3f.tar.gz
kernel_samsung_tuna-b81bc2d2bbf06b1794be8720563dcd29c2b7ff3f.tar.bz2
kernel_samsung_tuna-b81bc2d2bbf06b1794be8720563dcd29c2b7ff3f.zip
mm: Serialize access to min_free_kbytes
There is a race between the min_free_kbytes sysctl, memory hotplug and transparent hugepage support enablement. Memory hotplug uses a zonelists_mutex to avoid a race when building zonelists. Reuse it to serialise watermark updates. [a.p.zijlstra@chello.nl: Older patch fixed the race with spinlock] Signed-off-by: Mel Gorman <mgorman@suse.de> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Tested-by: Barry Song <Baohua.Song@csr.com>
Diffstat (limited to 'mm')
-rw-r--r--mm/page_alloc.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 53924b67eba..87961bf4dff 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5237,14 +5237,7 @@ static void setup_per_zone_lowmem_reserve(void)
calculate_totalreserve_pages();
}
-/**
- * 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 pages_low = extra_free_kbytes >> (PAGE_SHIFT - 10);
@@ -5305,6 +5298,20 @@ void setup_per_zone_wmarks(void)
calculate_totalreserve_pages();
}
+/**
+ * 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)
+{
+ mutex_lock(&zonelists_mutex);
+ __setup_per_zone_wmarks();
+ mutex_unlock(&zonelists_mutex);
+}
+
/*
* The inactive anon list should be small enough that the VM never has to
* do too much work, but large enough that each inactive page has a chance