From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>,
Michael Ellerman <mpe@ellerman.id.au>,
naveen.n.rao@linux.vnet.ibm.com
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>,
linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Subject: [PATCH v2 07/25] powerpc/ftrace: Use patch_instruction() return directly
Date: Sat, 7 May 2022 08:46:09 +0200 [thread overview]
Message-ID: <49a8597230713e2633e7d9d7b56140787c4a7e20.1651905939.git.christophe.leroy@csgroup.eu> (raw)
In-Reply-To: <cover.1651905939.git.christophe.leroy@csgroup.eu>
Instead of returning -EPERM when patch_instruction() fails,
just return what patch_instruction returns.
That simplifies ftrace_modify_code():
0: 94 21 ff c0 stwu r1,-64(r1)
4: 93 e1 00 3c stw r31,60(r1)
8: 7c 7f 1b 79 mr. r31,r3
c: 40 80 00 30 bge 3c <ftrace_modify_code+0x3c>
10: 93 c1 00 38 stw r30,56(r1)
14: 7c 9e 23 78 mr r30,r4
18: 7c a4 2b 78 mr r4,r5
1c: 80 bf 00 00 lwz r5,0(r31)
20: 7c 1e 28 40 cmplw r30,r5
24: 40 82 00 34 bne 58 <ftrace_modify_code+0x58>
28: 83 c1 00 38 lwz r30,56(r1)
2c: 7f e3 fb 78 mr r3,r31
30: 83 e1 00 3c lwz r31,60(r1)
34: 38 21 00 40 addi r1,r1,64
38: 48 00 00 00 b 38 <ftrace_modify_code+0x38>
38: R_PPC_REL24 patch_instruction
Before:
0: 94 21 ff c0 stwu r1,-64(r1)
4: 93 e1 00 3c stw r31,60(r1)
8: 7c 7f 1b 79 mr. r31,r3
c: 40 80 00 4c bge 58 <ftrace_modify_code+0x58>
10: 93 c1 00 38 stw r30,56(r1)
14: 7c 9e 23 78 mr r30,r4
18: 7c a4 2b 78 mr r4,r5
1c: 80 bf 00 00 lwz r5,0(r31)
20: 7c 08 02 a6 mflr r0
24: 90 01 00 44 stw r0,68(r1)
28: 7c 1e 28 40 cmplw r30,r5
2c: 40 82 00 48 bne 74 <ftrace_modify_code+0x74>
30: 7f e3 fb 78 mr r3,r31
34: 48 00 00 01 bl 34 <ftrace_modify_code+0x34>
34: R_PPC_REL24 patch_instruction
38: 80 01 00 44 lwz r0,68(r1)
3c: 20 63 00 00 subfic r3,r3,0
40: 83 c1 00 38 lwz r30,56(r1)
44: 7c 63 19 10 subfe r3,r3,r3
48: 7c 08 03 a6 mtlr r0
4c: 83 e1 00 3c lwz r31,60(r1)
50: 38 21 00 40 addi r1,r1,64
54: 4e 80 00 20 blr
It improves ftrace activation/deactivation duration by about 3%.
Modify patch_instruction() return on failure to -EPERM in order to
match with ftrace expectations. Other users of patch_instruction()
do not care about the exact error value returned.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
v2: Make patch_instruction() return -EPERM in case of failure
---
arch/powerpc/kernel/trace/ftrace.c | 5 +----
arch/powerpc/lib/code-patching.c | 2 +-
2 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftrace.c
index 98e82fa4980f..1b05d33f96c6 100644
--- a/arch/powerpc/kernel/trace/ftrace.c
+++ b/arch/powerpc/kernel/trace/ftrace.c
@@ -78,10 +78,7 @@ ftrace_modify_code(unsigned long ip, ppc_inst_t old, ppc_inst_t new)
}
/* replace the text with the new text */
- if (patch_instruction((u32 *)ip, new))
- return -EPERM;
-
- return 0;
+ return patch_instruction((u32 *)ip, new);
}
/*
diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c
index 7adbdb05fee7..cd25c07df23c 100644
--- a/arch/powerpc/lib/code-patching.c
+++ b/arch/powerpc/lib/code-patching.c
@@ -32,7 +32,7 @@ static int __patch_instruction(u32 *exec_addr, ppc_inst_t instr, u32 *patch_addr
return 0;
failed:
- return -EFAULT;
+ return -EPERM;
}
int raw_patch_instruction(u32 *addr, ppc_inst_t instr)
--
2.35.1
next prev parent reply other threads:[~2022-05-07 6:48 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-07 6:46 [PATCH v2 00/25] powerpc: ftrace optimisation and cleanup and more [v2] Christophe Leroy
2022-05-07 6:46 ` [PATCH v2 01/25] powerpc/ftrace: Refactor prepare_ftrace_return() Christophe Leroy
2022-05-07 6:46 ` [PATCH v2 02/25] powerpc/ftrace: Remove redundant create_branch() calls Christophe Leroy
2022-05-07 6:46 ` [PATCH v2 03/25] powerpc/code-patching: Inline is_offset_in_{cond}_branch_range() Christophe Leroy
2022-05-07 6:46 ` [PATCH v2 04/25] powerpc/ftrace: Use is_offset_in_branch_range() Christophe Leroy
2022-05-07 6:46 ` [PATCH v2 05/25] powerpc/code-patching: Inline create_branch() Christophe Leroy
2022-05-07 6:46 ` [PATCH v2 06/25] powerpc/ftrace: Inline ftrace_modify_code() Christophe Leroy
2022-05-07 6:46 ` Christophe Leroy [this message]
2022-05-07 6:46 ` [PATCH v2 08/25] powerpc: Add CONFIG_PPC64_ELF_ABI_V1 and CONFIG_PPC64_ELF_ABI_V2 Christophe Leroy
2022-05-07 6:46 ` [PATCH v2 09/25] powerpc: Replace PPC64_ELF_ABI_v{1/2} by CONFIG_PPC64_ELF_ABI_V{1/2} Christophe Leroy
2022-05-07 6:46 ` [PATCH v2 10/25] powerpc: Finalise cleanup around ABI use Christophe Leroy
2022-05-07 6:46 ` [PATCH v2 11/25] powerpc/ftrace: Make __ftrace_make_{nop/call}() common to PPC32 and PPC64 Christophe Leroy
2022-05-07 6:46 ` [PATCH v2 12/25] powerpc/ftrace: Don't include ftrace.o for CONFIG_FTRACE_SYSCALLS Christophe Leroy
2022-05-07 6:46 ` [PATCH v2 13/25] powerpc/ftrace: Use CONFIG_FUNCTION_TRACER instead of CONFIG_DYNAMIC_FTRACE Christophe Leroy
2022-05-07 6:46 ` [PATCH v2 14/25] powerpc/ftrace: Remove ftrace_plt_tramps[] Christophe Leroy
2022-05-07 6:46 ` [PATCH v2 15/25] powerpc/ftrace: Use BRANCH_SET_LINK instead of value 1 Christophe Leroy
2022-05-07 6:46 ` [PATCH v2 16/25] powerpc/ftrace: Use PPC_RAW_xxx() macros instead of opencoding Christophe Leroy
2022-05-07 6:46 ` [PATCH v2 17/25] powerpc/ftrace: Use size macro " Christophe Leroy
2022-05-07 6:46 ` [PATCH v2 18/25] powerpc/ftrace: Simplify expected_nop_sequence() Christophe Leroy
2022-05-07 6:46 ` [PATCH v2 19/25] powerpc/ftrace: Minimise number of #ifdefs Christophe Leroy
2022-05-07 6:46 ` [PATCH v2 20/25] powerpc/inst: Add __copy_inst_from_kernel_nofault() Christophe Leroy
2022-05-07 6:46 ` [PATCH v2 21/25] powerpc/ftrace: Don't use copy_from_kernel_nofault() in module_trampoline_target() Christophe Leroy
2022-05-07 11:29 ` kernel test robot
2022-05-07 6:46 ` [PATCH v2 22/25] powerpc/inst: Remove PPC_INST_BRANCH Christophe Leroy
2022-05-07 6:46 ` [PATCH v2 23/25] powerpc/modules: Use PPC_LI macros instead of opencoding Christophe Leroy
2022-05-07 6:46 ` [PATCH v2 24/25] powerpc/inst: Remove PPC_INST_BL Christophe Leroy
2022-05-07 6:46 ` [PATCH v2 25/25] powerpc/opcodes: Remove unused PPC_INST_XXX macros Christophe Leroy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49a8597230713e2633e7d9d7b56140787c4a7e20.1651905939.git.christophe.leroy@csgroup.eu \
--to=christophe.leroy@csgroup.eu \
--cc=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=naveen.n.rao@linux.vnet.ibm.com \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).