x86/ftrace: Tidy create_trampoline()
PATCH 1/1 x86/ftrace: Tidy create_trampoline()
create_trampoline() returns 2 values that the (only) caller simply assigns to ops members. Amend create_trampoline() to make the assignments instead, which simplifies the code.
Signed-off-by Adrian Hunter <[email protected]>
--- arch/x86/kernel/ftrace.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
arch/x86/kernel/ftrace.c +9 -12
@@ -307,8 +307,7 @@ union ftrace_op_code_union {#define RET_SIZE 1 -static unsigned long -create_trampoline (struct ftrace_ops *ops,unsigned int *tramp_size) +static void create_trampoline (struct ftrace_ops *ops) {unsigned long start_offset;unsigned long end_offset;
@@ -319,6 +318,7 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)unsigned long size;unsigned long retq;unsigned long *ptr; +unsigned int tramp_size;void *trampoline;void *ip;/* 48 8b 15 <offset> is movq <offset>(%rip), %rdx */
@@ -347,10 +347,10 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)*/ trampoline =alloc_tramp (size +RET_SIZE +sizeof (void *));if (!trampoline) -return 0 ; +return ; - *tramp_size = size +RET_SIZE +sizeof (void *); - npages =DIV_ROUND_UP (*tramp_size,PAGE_SIZE ); + tramp_size = size +RET_SIZE +sizeof (void *); + npages =DIV_ROUND_UP (tramp_size,PAGE_SIZE );/* Copy ftrace_caller onto the trampoline memory */ ret =probe_kernel_read (trampoline, (void *)start_offset, size);
@@ -403,15 +403,16 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)/* ALLOC_TRAMP flags lets us know we created it */ ops->flags |=FTRACE_OPS_FL_ALLOC_TRAMP ; + ops->trampoline = (unsigned long )trampoline; + ops->trampoline_size = tramp_size;set_vm_flush_reset_perms (trampoline);set_memory_ro ((unsigned long )trampoline, npages);set_memory_x ((unsigned long )trampoline, npages); -return (unsigned long )trampoline; +return ; fail:tramp_free (trampoline); -return 0 ; }static unsigned long calc_trampoline_call_offset (bool save_regs)
@@ -435,14 +436,10 @@ void arch_ftrace_update_trampoline(struct ftrace_ops *ops)ftrace_func_t func;unsigned long offset;unsigned long ip; -unsigned int size;const char *new;if (!ops->trampoline) { - ops->trampoline =create_trampoline (ops, &size); -if (!ops->trampoline) -return ; - ops->trampoline_size = size; +create_trampoline (ops);return ; }
Signature · 1 line
2.17.1
Quoted 5 lines · Adrian Hunter
create_trampoline()returns 2 values that the (only) caller simply assigns to ops members. Amendcreate_trampoline()to make the assignments instead, which simplifies the code.Signed-off-by Adrian Hunter <[email protected]>