Commit 443c6f145de813518c36ac6b6e4e08d9445337e7
1 parent
4440095c82
Exists in
master
and in
39 other branches
SYSCTL: Add a mutex to the page_alloc zone order sysctl
The zone list code clearly cannot tolerate concurrent writers (I couldn't find any locks for that), so simply add a global mutex. No need for RCU in this case. Signed-off-by: Andi Kleen <ak@linux.intel.com>
Showing 1 changed file with 7 additions and 4 deletions Side-by-side Diff
mm/page_alloc.c
... | ... | @@ -2402,13 +2402,14 @@ |
2402 | 2402 | { |
2403 | 2403 | char saved_string[NUMA_ZONELIST_ORDER_LEN]; |
2404 | 2404 | int ret; |
2405 | + static DEFINE_MUTEX(zl_order_mutex); | |
2405 | 2406 | |
2407 | + mutex_lock(&zl_order_mutex); | |
2406 | 2408 | if (write) |
2407 | - strncpy(saved_string, (char*)table->data, | |
2408 | - NUMA_ZONELIST_ORDER_LEN); | |
2409 | + strcpy(saved_string, (char*)table->data); | |
2409 | 2410 | ret = proc_dostring(table, write, buffer, length, ppos); |
2410 | 2411 | if (ret) |
2411 | - return ret; | |
2412 | + goto out; | |
2412 | 2413 | if (write) { |
2413 | 2414 | int oldval = user_zonelist_order; |
2414 | 2415 | if (__parse_numa_zonelist_order((char*)table->data)) { |
... | ... | @@ -2421,7 +2422,9 @@ |
2421 | 2422 | } else if (oldval != user_zonelist_order) |
2422 | 2423 | build_all_zonelists(); |
2423 | 2424 | } |
2424 | - return 0; | |
2425 | +out: | |
2426 | + mutex_unlock(&zl_order_mutex); | |
2427 | + return ret; | |
2425 | 2428 | } |
2426 | 2429 | |
2427 | 2430 |