Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753272AbcCAKI4 (ORCPT ); Tue, 1 Mar 2016 05:08:56 -0500 Received: from e23smtp03.au.ibm.com ([202.81.31.145]:33393 "EHLO e23smtp03.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753049AbcCAKIu (ORCPT ); Tue, 1 Mar 2016 05:08:50 -0500 X-IBM-Helo: d23dlp03.au.ibm.com X-IBM-MailFrom: kamalesh@linux.vnet.ibm.com X-IBM-RcptTo: linux-kernel@vger.kernel.org;live-patching@vger.kernel.org Date: Tue, 1 Mar 2016 15:37:39 +0530 From: Kamalesh Babulal To: Michael Ellerman Cc: linuxppc-dev@ozlabs.org, bsingharora@gmail.com, duwe@lst.de, linux-kernel@vger.kernel.org, rostedt@goodmis.org, pmladek@suse.com, jeyu@redhat.com, jkosina@suse.cz, live-patching@vger.kernel.org, mbenes@suse.cz Subject: Re: [PATCH v2 2/8] powerpc/module: Only try to generate the ftrace_caller() stub once Message-ID: <20160301100738.GB13436@linux.vnet.ibm.com> Reply-To: Kamalesh Babulal References: <1456737989-8755-1-git-send-email-mpe@ellerman.id.au> <1456737989-8755-2-git-send-email-mpe@ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1456737989-8755-2-git-send-email-mpe@ellerman.id.au> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16030110-0009-0000-0000-000003143F36 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2659 Lines: 69 * Michael Ellerman [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 > Reviewed-by: Torsten Duwe > Signed-off-by: Michael Ellerman > --- 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