[vz7,v2] mm: fix high order allocation warning limits

Submitted by Oleg Babin on March 7, 2018, 2 p.m.

Details

Message ID 1520431248-340087-1-git-send-email-obabin@virtuozzo.com
State New
Series "mm: fix high order allocation warning limits"
Headers show

Commit Message

Oleg Babin March 7, 2018, 2 p.m.
After sysctl parameter 'vm.warn_high_order' is modified it can't be
returned back to the default value MAX_ORDER+1, only to the fixed
value 10.

Set the maximum value to 100 which is always larger than any maximum
order. Also set the default value to MAX_ORDER as it is already the
value which can never be allocated.

Also there is a logic to stop generating the warning after 32 occurences,
but the logic is broken (the warning is generated even after the counter
becomes less than zero). Modify the procedure of checking the counter.

https://jira.sw.ru/browse/PSBM-82202
Signed-off-by: Oleg Babin <obabin@virtuozzo.com>
---
 kernel/sysctl.c | 3 +--
 mm/page_alloc.c | 4 ++--
 2 files changed, 3 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 70f1219..8289ae6 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -128,7 +128,6 @@  static int __maybe_unused one = 1;
 static int __maybe_unused two = 2;
 static int __maybe_unused four = 4;
 static unsigned long one_ul = 1;
-static int ten = 10;
 static int one_hundred = 100;
 #ifdef CONFIG_PRINTK
 static int ten_thousand = 10000;
@@ -1670,7 +1669,7 @@  static struct ctl_table vm_table[] = {
 		.mode		= 0644,
 		.proc_handler	= &proc_warn_high_order,
 		.extra1		= &zero,
-		.extra2		= &ten,
+		.extra2		= &one_hundred,
 	},
 	{ }
 };
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index fed5d87..15575b2 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3168,7 +3168,7 @@  static void __alloc_collect_stats(gfp_t gfp_mask, unsigned int order,
 }
 
 struct static_key warn_high_order_key = STATIC_KEY_INIT_FALSE;
-int warn_order = MAX_ORDER+1;
+int warn_order = MAX_ORDER;
 
 int proc_warn_high_order(struct ctl_table *table, int write,
 			void __user *buffer, size_t *lenp, loff_t *ppos)
@@ -3192,7 +3192,7 @@  static __always_inline void warn_high_order(int order, gfp_t gfp_mask)
 		int tmp_warn_order = smp_load_acquire(&warn_order);
 
 		if (order >= tmp_warn_order && !(gfp_mask & __GFP_NOWARN))
-			WARN(atomic_dec_return(&warn_count),
+			WARN(atomic_dec_if_positive(&warn_count) >= 0,
 				"order %d >= %d, gfp 0x%x\n",
 				order, tmp_warn_order, gfp_mask);
 	}

Comments

Andrey Ryabinin March 7, 2018, 2:08 p.m.
On 03/07/2018 05:00 PM, Oleg Babin wrote:
> After sysctl parameter 'vm.warn_high_order' is modified it can't be
> returned back to the default value MAX_ORDER+1, only to the fixed
> value 10.
> 
> Set the maximum value to 100 which is always larger than any maximum
> order. Also set the default value to MAX_ORDER as it is already the
> value which can never be allocated.
> 
> Also there is a logic to stop generating the warning after 32 occurences,
> but the logic is broken (the warning is generated even after the counter
> becomes less than zero). Modify the procedure of checking the counter.
> 
> https://jira.sw.ru/browse/PSBM-82202
> Signed-off-by: Oleg Babin <obabin@virtuozzo.com>
> ---

Acked-by: Andrey Ryabinin <aryabinin@virtuozzo.com>