5517d50082
When a static call is updated with __static_call_return0() as target, arch_static_call_transform() set it to use an optimised set of instructions which are meant to lay in the same cacheline. But when initialising a static call with DEFINE_STATIC_CALL_RET0(), we get a branch to the real __static_call_return0() function instead of getting the optimised setup: c00d8120 <__SCT__perf_snapshot_branch_stack>: c00d8120: 4b ff ff f4 b c00d8114 <__static_call_return0> c00d8124: 3d 80 c0 0e lis r12,-16370 c00d8128: 81 8c 81 3c lwz r12,-32452(r12) c00d812c: 7d 89 03 a6 mtctr r12 c00d8130: 4e 80 04 20 bctr c00d8134: 38 60 00 00 li r3,0 c00d8138: 4e 80 00 20 blr c00d813c: 00 00 00 00 .long 0x0 Add ARCH_DEFINE_STATIC_CALL_RET0_TRAMP() defined by each architecture to setup the optimised configuration, and rework DEFINE_STATIC_CALL_RET0() to call it: c00d8120 <__SCT__perf_snapshot_branch_stack>: c00d8120: 48 00 00 14 b c00d8134 <__SCT__perf_snapshot_branch_stack+0x14> c00d8124: 3d 80 c0 0e lis r12,-16370 c00d8128: 81 8c 81 3c lwz r12,-32452(r12) c00d812c: 7d 89 03 a6 mtctr r12 c00d8130: 4e 80 04 20 bctr c00d8134: 38 60 00 00 li r3,0 c00d8138: 4e 80 00 20 blr c00d813c: 00 00 00 00 .long 0x0 Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Josh Poimboeuf <jpoimboe@redhat.com> Link: https://lore.kernel.org/r/1e0a61a88f52a460f62a58ffc2a5f847d1f7d9d8.1647253456.git.christophe.leroy@csgroup.eu
30 lines
1.0 KiB
C
30 lines
1.0 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _ASM_POWERPC_STATIC_CALL_H
|
|
#define _ASM_POWERPC_STATIC_CALL_H
|
|
|
|
#define __PPC_SCT(name, inst) \
|
|
asm(".pushsection .text, \"ax\" \n" \
|
|
".align 5 \n" \
|
|
".globl " STATIC_CALL_TRAMP_STR(name) " \n" \
|
|
STATIC_CALL_TRAMP_STR(name) ": \n" \
|
|
inst " \n" \
|
|
" lis 12,2f@ha \n" \
|
|
" lwz 12,2f@l(12) \n" \
|
|
" mtctr 12 \n" \
|
|
" bctr \n" \
|
|
"1: li 3, 0 \n" \
|
|
" blr \n" \
|
|
"2: .long 0 \n" \
|
|
".type " STATIC_CALL_TRAMP_STR(name) ", @function \n" \
|
|
".size " STATIC_CALL_TRAMP_STR(name) ", . - " STATIC_CALL_TRAMP_STR(name) " \n" \
|
|
".popsection \n")
|
|
|
|
#define PPC_SCT_RET0 20 /* Offset of label 1 */
|
|
#define PPC_SCT_DATA 28 /* Offset of label 2 */
|
|
|
|
#define ARCH_DEFINE_STATIC_CALL_TRAMP(name, func) __PPC_SCT(name, "b " #func)
|
|
#define ARCH_DEFINE_STATIC_CALL_NULL_TRAMP(name) __PPC_SCT(name, "blr")
|
|
#define ARCH_DEFINE_STATIC_CALL_RET0_TRAMP(name) __PPC_SCT(name, "b .+20")
|
|
|
|
#endif /* _ASM_POWERPC_STATIC_CALL_H */
|