mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-11-19 00:21:50 +01:00
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. [[email protected]: Older patch fixed the race with spinlock] Signed-off-by: Mel Gorman <[email protected]> Signed-off-by: Marek Szyprowski <[email protected]> Reviewed-by: KAMEZAWA Hiroyuki <[email protected]> Tested-by: Barry Song <[email protected]>
This commit is contained in:
1 parent
0815f3d81d
commit
cfd3da1e49
1 file changed
+15
-8
+15
-8
@@ -5020,14 +5020,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 lowmem_pages = 0;
|
||||
@@ -5082,6 +5075,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
|
||||
|
||||
Reference in new issue
Block a user