]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.13/mm-mprotect-add-a-cond_resched-inside-change_pmd_range.patch
Fix up backported ptrace patch
[thirdparty/kernel/stable-queue.git] / releases / 4.14.13 / mm-mprotect-add-a-cond_resched-inside-change_pmd_range.patch
1 From 4991c09c7c812dba13ea9be79a68b4565bb1fa4e Mon Sep 17 00:00:00 2001
2 From: Anshuman Khandual <khandual@linux.vnet.ibm.com>
3 Date: Thu, 4 Jan 2018 16:17:52 -0800
4 Subject: mm/mprotect: add a cond_resched() inside change_pmd_range()
5
6 From: Anshuman Khandual <khandual@linux.vnet.ibm.com>
7
8 commit 4991c09c7c812dba13ea9be79a68b4565bb1fa4e upstream.
9
10 While testing on a large CPU system, detected the following RCU stall
11 many times over the span of the workload. This problem is solved by
12 adding a cond_resched() in the change_pmd_range() function.
13
14 INFO: rcu_sched detected stalls on CPUs/tasks:
15 154-....: (670 ticks this GP) idle=022/140000000000000/0 softirq=2825/2825 fqs=612
16 (detected by 955, t=6002 jiffies, g=4486, c=4485, q=90864)
17 Sending NMI from CPU 955 to CPUs 154:
18 NMI backtrace for cpu 154
19 CPU: 154 PID: 147071 Comm: workload Not tainted 4.15.0-rc3+ #3
20 NIP: c0000000000b3f64 LR: c0000000000b33d4 CTR: 000000000000aa18
21 REGS: 00000000a4b0fb44 TRAP: 0501 Not tainted (4.15.0-rc3+)
22 MSR: 8000000000009033 <SF,EE,ME,IR,DR,RI,LE> CR: 22422082 XER: 00000000
23 CFAR: 00000000006cf8f0 SOFTE: 1
24 GPR00: 0010000000000000 c00003ef9b1cb8c0 c0000000010cc600 0000000000000000
25 GPR04: 8e0000018c32b200 40017b3858fd6e00 8e0000018c32b208 40017b3858fd6e00
26 GPR08: 8e0000018c32b210 40017b3858fd6e00 8e0000018c32b218 40017b3858fd6e00
27 GPR12: ffffffffffffffff c00000000fb25100
28 NIP [c0000000000b3f64] plpar_hcall9+0x44/0x7c
29 LR [c0000000000b33d4] pSeries_lpar_flush_hash_range+0x384/0x420
30 Call Trace:
31 flush_hash_range+0x48/0x100
32 __flush_tlb_pending+0x44/0xd0
33 hpte_need_flush+0x408/0x470
34 change_protection_range+0xaac/0xf10
35 change_prot_numa+0x30/0xb0
36 task_numa_work+0x2d0/0x3e0
37 task_work_run+0x130/0x190
38 do_notify_resume+0x118/0x120
39 ret_from_except_lite+0x70/0x74
40 Instruction dump:
41 60000000 f8810028 7ca42b78 7cc53378 7ce63b78 7d074378 7d284b78 7d495378
42 e9410060 e9610068 e9810070 44000022 <7d806378> e9810028 f88c0000 f8ac0008
43
44 Link: http://lkml.kernel.org/r/20171214140551.5794-1-khandual@linux.vnet.ibm.com
45 Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
46 Suggested-by: Nicholas Piggin <npiggin@gmail.com>
47 Acked-by: Michal Hocko <mhocko@suse.com>
48 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
49 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
50 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
51
52 ---
53 mm/mprotect.c | 6 ++++--
54 1 file changed, 4 insertions(+), 2 deletions(-)
55
56 --- a/mm/mprotect.c
57 +++ b/mm/mprotect.c
58 @@ -166,7 +166,7 @@ static inline unsigned long change_pmd_r
59 next = pmd_addr_end(addr, end);
60 if (!is_swap_pmd(*pmd) && !pmd_trans_huge(*pmd) && !pmd_devmap(*pmd)
61 && pmd_none_or_clear_bad(pmd))
62 - continue;
63 + goto next;
64
65 /* invoke the mmu notifier if the pmd is populated */
66 if (!mni_start) {
67 @@ -188,7 +188,7 @@ static inline unsigned long change_pmd_r
68 }
69
70 /* huge pmd was handled */
71 - continue;
72 + goto next;
73 }
74 }
75 /* fall through, the trans huge pmd just split */
76 @@ -196,6 +196,8 @@ static inline unsigned long change_pmd_r
77 this_pages = change_pte_range(vma, pmd, addr, next, newprot,
78 dirty_accountable, prot_numa);
79 pages += this_pages;
80 +next:
81 + cond_resched();
82 } while (pmd++, addr = next, addr != end);
83
84 if (mni_start)