[RHEL7,COMMIT] mm: fix high order allocation warning limits

Submitted by Konstantin Khorenko on March 15, 2018, 10:35 a.m.

Details

Message ID 201803151035.w2FAZRdO013356@finist_ce7.work
State New
Series "mm: fix high order allocation warning limits"
Headers show

Commit Message

Konstantin Khorenko March 15, 2018, 10:35 a.m.
The commit is pushed to "branch-rh7-3.10.0-693.17.1.vz7.45.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.17.1.vz7.45.7
------>
commit e3879dff17b99d28afb34acf9341cd53b4778975
Author: Oleg Babin <obabin@virtuozzo.com>
Date:   Thu Mar 15 13:35:26 2018 +0300

    mm: fix high order allocation warning limits
    
    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.
    
    Fixes: 1ab81385c03f ("mm: add warning about high order allocations")
    
    https://jira.sw.ru/browse/PSBM-82202
    
    Signed-off-by: Oleg Babin <obabin@virtuozzo.com>
    Acked-by: Andrey Ryabinin <aryabinin@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 70f1219103a5..8289ae6263db 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 fed5d879179f..15575b24a97c 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);
 	}