]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.18.101/powerpc-avoid-taking-a-data-miss-on-every-userspace-instruction-miss.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.18.101 / powerpc-avoid-taking-a-data-miss-on-every-userspace-instruction-miss.patch
1 From foo@baz Mon Mar 19 10:11:52 CET 2018
2 From: Anton Blanchard <anton@samba.org>
3 Date: Mon, 3 Apr 2017 16:41:02 +1000
4 Subject: powerpc: Avoid taking a data miss on every userspace instruction miss
5
6 From: Anton Blanchard <anton@samba.org>
7
8
9 [ Upstream commit a7a9dcd882a67b68568868b988289fce5ffd8419 ]
10
11 Early on in do_page_fault() we call store_updates_sp(), regardless of
12 the type of exception. For an instruction miss this doesn't make
13 sense, because we only use this information to detect if a data miss
14 is the result of a stack expansion instruction or not.
15
16 Worse still, it results in a data miss within every userspace
17 instruction miss handler, because we try and load the very instruction
18 we are about to install a pte for!
19
20 A simple exec microbenchmark runs 6% faster on POWER8 with this fix:
21
22 #include <stdlib.h>
23 #include <stdio.h>
24 #include <unistd.h>
25
26 int main(int argc, char *argv[])
27 {
28 unsigned long left = atol(argv[1]);
29 char leftstr[16];
30
31 if (left-- == 0)
32 return 0;
33
34 sprintf(leftstr, "%ld", left);
35 execlp(argv[0], argv[0], leftstr, NULL);
36 perror("exec failed\n");
37
38 return 0;
39 }
40
41 Pass the number of iterations on the command line (eg 10000) and time
42 how long it takes to execute.
43
44 Signed-off-by: Anton Blanchard <anton@samba.org>
45 Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
46 Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
47 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
48 ---
49 arch/powerpc/mm/fault.c | 2 +-
50 1 file changed, 1 insertion(+), 1 deletion(-)
51
52 --- a/arch/powerpc/mm/fault.c
53 +++ b/arch/powerpc/mm/fault.c
54 @@ -294,7 +294,7 @@ int __kprobes do_page_fault(struct pt_re
55 * can result in fault, which will cause a deadlock when called with
56 * mmap_sem held
57 */
58 - if (user_mode(regs))
59 + if (!is_exec && user_mode(regs))
60 store_update_sp = store_updates_sp(regs);
61
62 if (user_mode(regs))