ANDROID: mm: Create an new handler for extra_free_kbytes When modifying extra_free_kbytes, user_min_free_kbytes is modified at the same time, which will cause user_min_free_kbytes to be modified incorrectly. Create an new handler for extra_free_kbytes. Bug: 201480378 Change-Id: Ib30aa846ad4ea17a1ef4d306f82500de6dc2bf10 Signed-off-by: Liangcai Fan <liangcai.fan@unisoc.com>
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 11f0106..9ac53dd9 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h
@@ -961,6 +961,8 @@ static inline int is_highmem(struct zone *zone) struct ctl_table; int min_free_kbytes_sysctl_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *); +int extra_free_kbytes_sysctl_handler(struct ctl_table *, int, + void __user *, size_t *, loff_t *); int watermark_boost_factor_sysctl_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *); int watermark_scale_factor_sysctl_handler(struct ctl_table *, int,
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index e8f0787..8a098896 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c
@@ -1537,7 +1537,7 @@ static struct ctl_table vm_table[] = { .data = &extra_free_kbytes, .maxlen = sizeof(extra_free_kbytes), .mode = 0644, - .proc_handler = min_free_kbytes_sysctl_handler, + .proc_handler = extra_free_kbytes_sysctl_handler, .extra1 = SYSCTL_ZERO, }, {
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 8147f8f..a2f1ccc 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c
@@ -7995,8 +7995,7 @@ postcore_initcall(init_per_zone_wmark_min) /* * min_free_kbytes_sysctl_handler - just a wrapper around proc_dointvec() so - * that we can call two helper functions whenever min_free_kbytes - * or extra_free_kbytes changes. + * that we can call two helper functions whenever min_free_kbytes changes. */ int min_free_kbytes_sysctl_handler(struct ctl_table *table, int write, void __user *buffer, size_t *length, loff_t *ppos) @@ -8014,6 +8013,25 @@ int min_free_kbytes_sysctl_handler(struct ctl_table *table, int write, return 0; } +/* + * extra_free_kbytes_sysctl_handler - just a wrapper around proc_dointvec() so + * that we can call two helper functions whenever extra_free_kbytes changes. + */ +int extra_free_kbytes_sysctl_handler(struct ctl_table *table, int write, + void __user *buffer, size_t *length, loff_t *ppos) +{ + int rc; + + rc = proc_dointvec_minmax(table, write, buffer, length, ppos); + if (rc) + return rc; + + if (write) + setup_per_zone_wmarks(); + + return 0; +} + int watermark_boost_factor_sysctl_handler(struct ctl_table *table, int write, void __user *buffer, size_t *length, loff_t *ppos) {