* Michael Ellerman <mpe@xxxxxxxxxxxxxx> [2016-02-29 20:26:23]: > Currently we generate the module stub for ftrace_caller() at the bottom > of apply_relocate_add(). However apply_relocate_add() is potentially > called more than once per module, which means we will try to generate > the ftrace_caller() stub multiple times. > > Although the current code deals with that correctly, ie. it only > generates a stub the first time, it would be clearer to only try to > generate the stub once. > > Note also on first reading it may appear that we generate a different > stub for each section that requires relocation, but that is not the > case. The code in stub_for_addr() that searches for an existing stub > uses sechdrs[me->arch.stubs_section], ie. the single stub section for > this module. > > A cleaner approach is to only generate the ftrace_caller() stub once, > from module_finalize(). Although the original code didn't check to see > if the stub was actually generated correctly, it seems prudent to add a > check, so do that. And an additional benefit is we can clean the ifdefs > up a little. > > Finally we must propagate the const'ness of some of the pointers passed > to module_finalize(), but that is also an improvement. > > Reviewed-by: Balbir Singh <bsingharora@xxxxxxxxx> > Reviewed-by: Torsten Duwe <duwe@xxxxxxx> > Signed-off-by: Michael Ellerman <mpe@xxxxxxxxxxxxxx> > --- with !CONFIG_DYNAMIC_FTRACE, build breaks arch/powerpc/kernel/module_64.c:491:13: error: â??squash_toc_save_instâ?? used but never defined [-Werror] static void squash_toc_save_inst(const char *name, unsigned long addr); ^ cc1: all warnings being treated as errors moving squash_toc_save_inst() definition to #else part of #ifdef CONFIG_DYNAMIC_FTRACE helps. arch/powerpc/kernel/module_64.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c index c9c75ceb7ed3..def0b9a013c9 100644 --- a/arch/powerpc/kernel/module_64.c +++ b/arch/powerpc/kernel/module_64.c @@ -774,8 +774,6 @@ static unsigned long create_ftrace_stub(const Elf64_Shdr *sechdrs, struct module return (unsigned long)entry; } #else -static void squash_toc_save_inst(const char *name, unsigned long addr) { } - static unsigned long create_ftrace_stub(const Elf64_Shdr *sechdrs, struct module *me) { return stub_for_addr(sechdrs, (unsigned long)ftrace_caller, me); @@ -792,4 +790,8 @@ int module_finalize_ftrace(struct module *mod, const Elf_Shdr *sechdrs) return 0; } + +#else +static void squash_toc_save_inst(const char *name, unsigned long addr) { } + #endif -- 2.6.0.rc1 -- To unsubscribe from this list: send the line "unsubscribe live-patching" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html