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
6 From: Anton Blanchard <anton@samba.org>
9 [ Upstream commit a7a9dcd882a67b68568868b988289fce5ffd8419 ]
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.
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!
20 A simple exec microbenchmark runs 6% faster on POWER8 with this fix:
26 int main(int argc, char *argv[])
28 unsigned long left = atol(argv[1]);
34 sprintf(leftstr, "%ld", left);
35 execlp(argv[0], argv[0], leftstr, NULL);
36 perror("exec failed\n");
41 Pass the number of iterations on the command line (eg 10000) and time
42 how long it takes to execute.
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>
49 arch/powerpc/mm/fault.c | 2 +-
50 1 file changed, 1 insertion(+), 1 deletion(-)
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
58 - if (user_mode(regs))
59 + if (!is_exec && user_mode(regs))
60 store_update_sp = store_updates_sp(regs);