create_branch() is a good candidate for inlining because:
- Flags can be folded in.
- Range tests are likely to be already done.

Hence reducing the create_branch() to only a set of instructions.

So inline it.

It improves ftrace activation by 10%.

Signed-off-by: Christophe Leroy <christophe.le...@csgroup.eu>
---
 arch/powerpc/include/asm/code-patching.h | 22 ++++++++++++++++++++--
 arch/powerpc/lib/code-patching.c         | 20 --------------------
 2 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/arch/powerpc/include/asm/code-patching.h 
b/arch/powerpc/include/asm/code-patching.h
index e7c5df50cb4e..4260e89f62b1 100644
--- a/arch/powerpc/include/asm/code-patching.h
+++ b/arch/powerpc/include/asm/code-patching.h
@@ -49,8 +49,26 @@ static inline bool is_offset_in_cond_branch_range(long 
offset)
        return offset >= -0x8000 && offset <= 0x7fff && !(offset & 0x3);
 }
 
-int create_branch(ppc_inst_t *instr, const u32 *addr,
-                 unsigned long target, int flags);
+static inline int create_branch(ppc_inst_t *instr, const u32 *addr,
+                               unsigned long target, int flags)
+{
+       long offset;
+
+       *instr = ppc_inst(0);
+       offset = target;
+       if (! (flags & BRANCH_ABSOLUTE))
+               offset = offset - (unsigned long)addr;
+
+       /* Check we can represent the target in the instruction format */
+       if (!is_offset_in_branch_range(offset))
+               return 1;
+
+       /* Mask out the flags and target, so they don't step on each other. */
+       *instr = ppc_inst(0x48000000 | (flags & 0x3) | (offset & 0x03FFFFFC));
+
+       return 0;
+}
+
 int create_cond_branch(ppc_inst_t *instr, const u32 *addr,
                       unsigned long target, int flags);
 int patch_branch(u32 *addr, unsigned long target, int flags);
diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c
index 58262c7e447c..7adbdb05fee7 100644
--- a/arch/powerpc/lib/code-patching.c
+++ b/arch/powerpc/lib/code-patching.c
@@ -230,26 +230,6 @@ bool is_conditional_branch(ppc_inst_t instr)
 }
 NOKPROBE_SYMBOL(is_conditional_branch);
 
-int create_branch(ppc_inst_t *instr, const u32 *addr,
-                 unsigned long target, int flags)
-{
-       long offset;
-
-       *instr = ppc_inst(0);
-       offset = target;
-       if (! (flags & BRANCH_ABSOLUTE))
-               offset = offset - (unsigned long)addr;
-
-       /* Check we can represent the target in the instruction format */
-       if (!is_offset_in_branch_range(offset))
-               return 1;
-
-       /* Mask out the flags and target, so they don't step on each other. */
-       *instr = ppc_inst(0x48000000 | (flags & 0x3) | (offset & 0x03FFFFFC));
-
-       return 0;
-}
-
 int create_cond_branch(ppc_inst_t *instr, const u32 *addr,
                       unsigned long target, int flags)
 {
-- 
2.35.1

Reply via email to