Commit a1facd25 authored by Christophe Leroy's avatar Christophe Leroy Committed by Michael Ellerman

powerpc/ftrace: Use is_offset_in_branch_range()

Use is_offset_in_branch_range() instead of create_branch()
to check if a target is within branch range.

This patch together with the previous one improves
ftrace activation time by 7%
Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/912ae51782f5a53c44e435497c8c3fb5cc632387.1652074503.git.christophe.leroy@csgroup.eu
parent 1acbf27e
...@@ -89,11 +89,9 @@ ftrace_modify_code(unsigned long ip, ppc_inst_t old, ppc_inst_t new) ...@@ -89,11 +89,9 @@ ftrace_modify_code(unsigned long ip, ppc_inst_t old, ppc_inst_t new)
*/ */
static int test_24bit_addr(unsigned long ip, unsigned long addr) static int test_24bit_addr(unsigned long ip, unsigned long addr)
{ {
ppc_inst_t op;
addr = ppc_function_entry((void *)addr); addr = ppc_function_entry((void *)addr);
/* use the create_branch to verify that this offset can be branched */ return is_offset_in_branch_range(addr - ip);
return create_branch(&op, (u32 *)ip, addr, 0) == 0;
} }
static int is_bl_op(ppc_inst_t op) static int is_bl_op(ppc_inst_t op)
...@@ -261,7 +259,6 @@ __ftrace_make_nop(struct module *mod, ...@@ -261,7 +259,6 @@ __ftrace_make_nop(struct module *mod,
static unsigned long find_ftrace_tramp(unsigned long ip) static unsigned long find_ftrace_tramp(unsigned long ip)
{ {
int i; int i;
ppc_inst_t instr;
/* /*
* We have the compiler generated long_branch tramps at the end * We have the compiler generated long_branch tramps at the end
...@@ -270,8 +267,7 @@ static unsigned long find_ftrace_tramp(unsigned long ip) ...@@ -270,8 +267,7 @@ static unsigned long find_ftrace_tramp(unsigned long ip)
for (i = NUM_FTRACE_TRAMPS - 1; i >= 0; i--) for (i = NUM_FTRACE_TRAMPS - 1; i >= 0; i--)
if (!ftrace_tramps[i]) if (!ftrace_tramps[i])
continue; continue;
else if (create_branch(&instr, (void *)ip, else if (is_offset_in_branch_range(ftrace_tramps[i] - ip))
ftrace_tramps[i], 0) == 0)
return ftrace_tramps[i]; return ftrace_tramps[i];
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment