From patchwork Tue Mar 1 10:07:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kamalesh Babulal X-Patchwork-Id: 590446 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 9326B140BA3 for ; Tue, 1 Mar 2016 21:09:44 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 72D701A0B73 for ; Tue, 1 Mar 2016 21:09:44 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from ozlabs.org (ozlabs.org [103.22.144.67]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id A6E0C1A06C2 for ; Tue, 1 Mar 2016 21:08:40 +1100 (AEDT) Received: by ozlabs.org (Postfix) id 90C4B140BA5; Tue, 1 Mar 2016 21:08:40 +1100 (AEDT) Delivered-To: linuxppc-dev@ozlabs.org Received: from e23smtp01.au.ibm.com (e23smtp01.au.ibm.com [202.81.31.143]) (using TLSv1.2 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 69431140BA3 for ; Tue, 1 Mar 2016 21:08:40 +1100 (AEDT) Received: from localhost by e23smtp01.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 1 Mar 2016 20:08:40 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp01.au.ibm.com (202.81.31.207) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 1 Mar 2016 20:08:37 +1000 X-IBM-Helo: d23dlp02.au.ibm.com X-IBM-MailFrom: kamalesh@linux.vnet.ibm.com X-IBM-RcptTo: linuxppc-dev@ozlabs.org Received: from d23relay09.au.ibm.com (d23relay09.au.ibm.com [9.185.63.181]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 6E21F2BB0059 for ; Tue, 1 Mar 2016 21:08:36 +1100 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay09.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u21A8SoS47120596 for ; Tue, 1 Mar 2016 21:08:36 +1100 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u21A83Jx027068 for ; Tue, 1 Mar 2016 21:08:03 +1100 Received: from linux.vnet.ibm.com ([9.124.158.69]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u21A7urn026033 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Tue, 1 Mar 2016 21:07:59 +1100 Date: Tue, 1 Mar 2016 15:37:39 +0530 From: Kamalesh Babulal To: Michael Ellerman 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> 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-Disposition: inline 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-1618-0000-0000-00002721320F X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Kamalesh Babulal Cc: pmladek@suse.com, jeyu@redhat.com, jkosina@suse.cz, linux-kernel@vger.kernel.org, rostedt@goodmis.org, linuxppc-dev@ozlabs.org, duwe@lst.de, live-patching@vger.kernel.org, mbenes@suse.cz Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" * 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