From patchwork Sat Jul 9 09:06:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Torsten Duwe X-Patchwork-Id: 9222051 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9F00460572 for ; Sat, 9 Jul 2016 09:09:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85ADA284BB for ; Sat, 9 Jul 2016 09:09:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A504284E5; Sat, 9 Jul 2016 09:09:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0BE23284BB for ; Sat, 9 Jul 2016 09:08:59 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bLoEB-0002VJ-Mz; Sat, 09 Jul 2016 09:07:11 +0000 Received: from verein.lst.de ([213.95.11.211] helo=newverein.lst.de) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bLoE8-0002TY-LN for linux-arm-kernel@lists.infradead.org; Sat, 09 Jul 2016 09:07:09 +0000 Received: by newverein.lst.de (Postfix, from userid 107) id D787A7F0EE; Sat, 9 Jul 2016 11:06:44 +0200 (CEST) Received: from lst.de (p5B088C13.dip0.t-ipconnect.de [91.8.140.19]) by newverein.lst.de (Postfix) with ESMTPSA id 6305F68C47; Sat, 9 Jul 2016 11:06:38 +0200 (CEST) Date: Sat, 9 Jul 2016 11:06:32 +0200 From: Torsten Duwe To: Steven Rostedt Subject: Re: [PATCH v2 1/2] arm64: implement FTRACE_WITH_REGS Message-ID: <20160709090632.GA2598@lst.de> References: <20160627151500.2247A68D20@newverein.lst.de> <20160627151717.BD25468D26@newverein.lst.de> <20160708145800.GE3556@pathway.suse.cz> <20160708150709.GA8979@lst.de> <20160708152421.GG3556@pathway.suse.cz> <20160708154824.ikq45dgk2auigqn7@treble> <20160708115710.5c657b5f@gandalf.local.home> <20160708202455.GA4580@lst.de> <20160708170808.1ab70ce3@gandalf.local.home> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160708170808.1ab70ce3@gandalf.local.home> User-Agent: Mutt/1.5.24 (2015-08-30) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160709_020708_870296_B2E5C1C6 X-CRM114-Status: GOOD ( 16.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, Petr Mladek , Jungseok Lee , Arnd Bergmann , Catalin Marinas , Christopher Li , Jiri Kosina , Will Deacon , linux-kernel@vger.kernel.org, andrew.wafaa@arm.com, takahiro.akashi@linaro.org, linux-sparse@vger.kernel.org, Ingo Molnar , Li Bin , Josh Poimboeuf , live-patching@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On Fri, Jul 08, 2016 at 05:08:08PM -0400, Steven Rostedt wrote: > On Fri, 8 Jul 2016 22:24:55 +0200 > Torsten Duwe wrote: > > > On Fri, Jul 08, 2016 at 11:57:10AM -0400, Steven Rostedt wrote: > > > On Fri, 8 Jul 2016 10:48:24 -0500 > > > Josh Poimboeuf wrote: > > > > > > > > Here, with -fprolog-pad, it's already a nop, so no change is needed. > > > > > > > > Yes, exactly. > > > > > That's what I was thinking. But as I stated in another email (probably > > > in the air when you wrote this), the call to ftrace_modify_code() may be > > > completely circumvented by ftrace_make_nop() if the addr is MCOUNT_ADDR. > > > > Only on the _first_ invocation. Later on, tracing can be switched on and off, > > and then the instructions need to be changed just like with fentry (or > > profile-kernel ;-) > > > > Understood, but ftrace_modify_code() will only receive addr == > MCOUNT_ADDR on boot up or when a module is loaded. In both cases, with > -fprolog-pad it will already be a nop, hence no need to call > ftrace_modify_code(), in those cases. > > In all other cases, addr will point to a ftrace trampoline. Maybe the code in question can be replaced with the change below, now that there is a preprocessor define in V2? (untested) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 3f743b1..695a646 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -2423,6 +2423,12 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec) if (unlikely(ftrace_disabled)) return 0; +#ifdef CC_USING_PROLOG_PAD + /* If the compiler already generated NOPs instead of + * calls to mcount, we're done here. + */ + return 1; +#endif ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR); if (ret) { ftrace_bug(ret, rec);