From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756210AbcHXNpu (ORCPT ); Wed, 24 Aug 2016 09:45:50 -0400 Received: from terminus.zytor.com ([198.137.202.10]:49906 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756085AbcHXNpd (ORCPT ); Wed, 24 Aug 2016 09:45:33 -0400 Date: Wed, 24 Aug 2016 06:06:04 -0700 From: tip-bot for Josh Poimboeuf Message-ID: Cc: torvalds@linux-foundation.org, dvlasenk@redhat.com, tglx@linutronix.de, byungchul.park@lge.com, rostedt@goodmis.org, brgerst@gmail.com, linux-kernel@vger.kernel.org, peterz@infradead.org, hpa@zytor.com, fweisbec@gmail.com, luto@amacapital.net, nilayvaish@gmail.com, mingo@kernel.org, jpoimboe@redhat.com, keescook@chromium.org, luto@kernel.org, bp@alien8.de Reply-To: nilayvaish@gmail.com, jpoimboe@redhat.com, mingo@kernel.org, keescook@chromium.org, bp@alien8.de, luto@kernel.org, tglx@linutronix.de, dvlasenk@redhat.com, torvalds@linux-foundation.org, rostedt@goodmis.org, byungchul.park@lge.com, brgerst@gmail.com, peterz@infradead.org, linux-kernel@vger.kernel.org, fweisbec@gmail.com, luto@amacapital.net, hpa@zytor.com In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/asm] x86/dumpstack/ftrace: Mark function graph handler function as unreliable Git-Commit-ID: 6f727b84e23421721025f4eb1b4f6cea1d4d723a X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 6f727b84e23421721025f4eb1b4f6cea1d4d723a Gitweb: http://git.kernel.org/tip/6f727b84e23421721025f4eb1b4f6cea1d4d723a Author: Josh Poimboeuf AuthorDate: Fri, 19 Aug 2016 06:53:01 -0500 Committer: Ingo Molnar CommitDate: Wed, 24 Aug 2016 12:15:15 +0200 x86/dumpstack/ftrace: Mark function graph handler function as unreliable When function graph tracing is enabled for a function, its return address on the stack is replaced with the address of an ftrace handler (return_to_handler). Currently 'return_to_handler' can be reported as reliable. That's not ideal, and can actually be misleading. When saving or dumping the stack, you normally only care about what led up to that point (the call path), rather than what will happen in the future (the return path). That's especially true in the non-oops stack trace case, which isn't used for debugging. For example, in a perf profiling operation, reporting return_to_handler() in the trace would just be confusing. And in the oops case, where debugging is important, "unreliable" is also more appropriate there because it serves as a hint that graph tracing was involved, instead of trying to imply that return_to_handler() was the real caller. Signed-off-by: Josh Poimboeuf Acked-by: Steven Rostedt Cc: Andy Lutomirski Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Byungchul Park Cc: Denys Vlasenko Cc: Frederic Weisbecker Cc: H. Peter Anvin Cc: Kees Cook Cc: Linus Torvalds Cc: Nilay Vaish Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/f8af15749c7d632d3e7f815995831d5b7f82950d.1471607358.git.jpoimboe@redhat.com Signed-off-by: Ingo Molnar --- arch/x86/kernel/dumpstack.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c index 9bf3d02..6aad8d4 100644 --- a/arch/x86/kernel/dumpstack.c +++ b/arch/x86/kernel/dumpstack.c @@ -87,12 +87,21 @@ print_context_stack(struct task_struct *task, bp = (unsigned long) frame; } - ops->address(data, addr, reliable); - + /* + * When function graph tracing is enabled for a + * function, its return address on the stack is + * replaced with the address of an ftrace handler + * (return_to_handler). In that case, before printing + * the "real" address, we want to print the handler + * address as an "unreliable" hint that function graph + * tracing was involved. + */ real_addr = ftrace_graph_ret_addr(task, graph, addr, stack); if (real_addr != addr) - ops->address(data, real_addr, 1); + ops->address(data, addr, 0); + + ops->address(data, real_addr, reliable); } stack++; } @@ -116,12 +125,11 @@ print_context_stack_bp(struct task_struct *task, if (!__kernel_text_address(addr)) break; - if (ops->address(data, addr, 1)) - break; - real_addr = ftrace_graph_ret_addr(task, graph, addr, retp); - if (real_addr != addr) - ops->address(data, real_addr, 1); + if (real_addr != addr && ops->address(data, addr, 0)) + break; + if (ops->address(data, real_addr, 1)) + break; frame = frame->next_frame; retp = &frame->return_address;