summaryrefslogtreecommitdiff
path: root/mm/page_alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/page_alloc.c')
-rw-r--r--mm/page_alloc.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 083cbcb5bdde..12fac9084c48 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -6853,8 +6853,8 @@ static int sysctl_min_slab_ratio_sysctl_handler(const struct ctl_table *table, i
/*
* lowmem_reserve_ratio_sysctl_handler - just a wrapper around
- * proc_dointvec() so that we can call setup_per_zone_lowmem_reserve()
- * whenever sysctl_lowmem_reserve_ratio changes.
+ * proc_dointvec_minmax() so that we can call
+ * setup_per_zone_lowmem_reserve() when the sysctl is written.
*
* The reserve ratio obviously has absolutely no relation with the
* minimum watermarks. The lowmem reserve ratio can only make sense
@@ -6863,16 +6863,27 @@ static int sysctl_min_slab_ratio_sysctl_handler(const struct ctl_table *table, i
static int lowmem_reserve_ratio_sysctl_handler(const struct ctl_table *table,
int write, void *buffer, size_t *length, loff_t *ppos)
{
- int i;
+ struct ctl_table tmp = *table;
+ int ratio[ARRAY_SIZE(sysctl_lowmem_reserve_ratio)];
+ int rc;
- proc_dointvec_minmax(table, write, buffer, length, ppos);
+ if (!write)
+ return proc_dointvec_minmax(table, write, buffer, length, ppos);
- for (i = 0; i < MAX_NR_ZONES; i++) {
- if (sysctl_lowmem_reserve_ratio[i] < 1)
- sysctl_lowmem_reserve_ratio[i] = 0;
- }
+ /*
+ * proc_dointvec_max() works incrementally. Use a buffer and only set
+ * the values if all of them parse cleanly.
+ */
+ memcpy(ratio, sysctl_lowmem_reserve_ratio, sizeof(ratio));
+ tmp.data = ratio;
+
+ rc = proc_dointvec_minmax(&tmp, write, buffer, length, ppos);
+ if (rc)
+ return rc;
+ memcpy(sysctl_lowmem_reserve_ratio, ratio, sizeof(ratio));
setup_per_zone_lowmem_reserve();
+
return 0;
}
@@ -6971,6 +6982,7 @@ static const struct ctl_table page_alloc_sysctl_table[] = {
.maxlen = sizeof(sysctl_lowmem_reserve_ratio),
.mode = 0644,
.proc_handler = lowmem_reserve_ratio_sysctl_handler,
+ .extra1 = SYSCTL_ZERO,
},
#ifdef CONFIG_NUMA
{