Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1346511

Re: [PATCH v2 2/8] powerpc/module: Only try to generate the ftrace_caller() stub once

From Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2 2/8] powerpc/module: Only try to generate the ftrace_caller() stub once
Date 2016-03-01 11:10 +0100
Message-ID <r7PpF-7Hb-63@gated-at.bofh.it> (permalink)
References <r7sjo-198-3@gated-at.bofh.it> <r7sjp-198-23@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


* Michael Ellerman <mpe@ellerman.id.au> [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@gmail.com>
> Reviewed-by: Torsten Duwe <duwe@suse.de>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---


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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 1/8] powerpc: Create a helper for getting the kernel toc value Michael Ellerman <mpe@ellerman.id.au> - 2016-02-29 10:30 +0100
  [PATCH v2 7/8] powerpc/ftrace: Add support for -mprofile-kernel ftrace ABI Michael Ellerman <mpe@ellerman.id.au> - 2016-02-29 10:30 +0100
  [PATCH v2 8/8] powerpc/ftrace: Add Kconfig & Make glue for mprofile-kernel Michael Ellerman <mpe@ellerman.id.au> - 2016-02-29 10:30 +0100
  [PATCH v2 2/8] powerpc/module: Only try to generate the ftrace_caller() stub once Michael Ellerman <mpe@ellerman.id.au> - 2016-02-29 10:30 +0100
    Re: [PATCH v2 2/8] powerpc/module: Only try to generate the  ftrace_caller() stub once Kamalesh Babulal <kamalesh@linux.vnet.ibm.com> - 2016-03-01 11:10 +0100
    Re: [PATCH v2 2/8] powerpc/module: Only try to generate the  ftrace_caller() stub once Torsten Duwe <duwe@lst.de> - 2016-03-01 13:10 +0100
      Re: [PATCH v2 2/8] powerpc/module: Only try to generate the  ftrace_caller() stub once Michael Ellerman <mpe@ellerman.id.au> - 2016-03-02 03:00 +0100
  [PATCH v2 3/8] powerpc/module: Mark module stubs with a magic value Michael Ellerman <mpe@ellerman.id.au> - 2016-02-29 10:30 +0100
  Re: [PATCH v2 1/8] powerpc: Create a helper for getting the kernel  toc value Kamalesh Babulal <kamalesh@linux.vnet.ibm.com> - 2016-03-01 11:00 +0100
  Re: [PATCH v2 1/8] powerpc: Create a helper for getting the kernel  toc value Torsten Duwe <duwe@lst.de> - 2016-03-01 13:00 +0100

csiph-web