Re: [PATCH v2] ftrace: Cleanup ftrace_dyn_arch_init()

From: Michael Ellerman
Date: Mon Sep 06 2021 - 10:23:11 EST


Weizhao Ouyang <o451686892@xxxxxxxxx> writes:
> Most of ARCHs use empty ftrace_dyn_arch_init(), introduce a weak common
> ftrace_dyn_arch_init() to cleanup them.
>
> Signed-off-by: Weizhao Ouyang <o451686892@xxxxxxxxx>
> Acked-by: Heiko Carstens <hca@xxxxxxxxxxxxx> (s390)
>
> ---
>
> Changes in v2:
> -- correct CONFIG_DYNAMIC_FTRACE on PowerPC
> -- add Acked-by tag

> diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h
> index debe8c4f7062..d59f67c0225f 100644
> --- a/arch/powerpc/include/asm/ftrace.h
> +++ b/arch/powerpc/include/asm/ftrace.h
> @@ -61,6 +61,10 @@ struct dyn_arch_ftrace {
> };
> #endif /* __ASSEMBLY__ */
>
> +#ifdef CONFIG_DYNAMIC_FTRACE
> +int __init ftrace_dyn_arch_init(void);
> +#endif /* CONFIG_DYNAMIC_FTRACE */
> +
> #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
> #define ARCH_SUPPORTS_FTRACE_OPS 1
> #endif

That breaks the build for powerpc:

/linux/arch/powerpc/include/asm/ftrace.h: Assembler messages:
/linux/arch/powerpc/include/asm/ftrace.h:65: Error: unrecognized opcode: `int'
make[4]: *** [/linux/scripts/Makefile.build:352: arch/powerpc/kernel/trace/ftrace_64.o] Error 1
make[3]: *** [/linux/scripts/Makefile.build:514: arch/powerpc/kernel/trace] Error 2
make[2]: *** [/linux/scripts/Makefile.build:514: arch/powerpc/kernel] Error 2
make[1]: *** [/linux/Makefile:1861: arch/powerpc] Error 2
make[1]: *** Waiting for unfinished jobs....

It needs to be inside an #ifndef __ASSEMBLY__ section.

cheers