From patchwork Fri Nov 6 06:44:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 56090 Delivered-To: patch@linaro.org Received: by 10.112.61.134 with SMTP id p6csp829747lbr; Thu, 5 Nov 2015 22:45:42 -0800 (PST) X-Received: by 10.66.102.74 with SMTP id fm10mr15384706pab.33.1446792342693; Thu, 05 Nov 2015 22:45:42 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t13si3492363pas.21.2015.11.05.22.45.42; Thu, 05 Nov 2015 22:45:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032116AbbKFGpk (ORCPT + 28 others); Fri, 6 Nov 2015 01:45:40 -0500 Received: from mail-pa0-f47.google.com ([209.85.220.47]:35223 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032085AbbKFGpi (ORCPT ); Fri, 6 Nov 2015 01:45:38 -0500 Received: by pasz6 with SMTP id z6so117212514pas.2 for ; Thu, 05 Nov 2015 22:45:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IluPZ5buYJoyInavSdRuNHACzE4ZwgzFNFnHwak81SM=; b=bd5Pe1tJ4zI9pvFnRfhmjWxUIRQPJMU3UczrZXLQljbW9m55dO8GtQQ1LzNVfqkDdy Nzw7E5pg32OykeH2GE4DJEr2jy1Hg6/vOge71tCbcIDkQ0DfI9xZWxisRkxU0o9kCS7V QCvlr978jCyK/TEBY+XH1qhq3wwIbcaj7By/D/lc0oGIHvsxM9L+4YXsSfVXpPNuhu5C WTdaKspaI14yDCoqLWoFSWLV1fi+wNhUogZlgrVsVR0v9L829MM4ebLjTX/shzDwAQaK sDPXvv5mAWCcDipGzercWAyC/FLK7ZUl3VsY4HJzgbVJ4mU4u1ShFd0T7MvZWyvq192D JR6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IluPZ5buYJoyInavSdRuNHACzE4ZwgzFNFnHwak81SM=; b=KyqjHsEB21vvJiLVAUwGgGcK8fnvYhjTekM0jasWExRFDzquYO2XViu+3h0S+oREzP Lq4tzZ+LrTu5Vpzt6jYo0S24g906fkJFaTemuVnx7ISMMrK7x5lCmFDd0S7DLp2lNu3D sgcFUcqKAQbcn5AD13wJMyVpNtW6Zp6N2oAXjQ5PMoNeq8Mzc8UVaoqw0ryGu2jVE94R kJLJKMMyBZShtnucCWHzAyfEy8RchCr8fGsannQsTqXPkybxWomfmhx8r+bSiR0kWSJm 8wcJ2Df2W9R2TYhe5PyZQJLWKT9x9XJ7pIOXkMrzBQ462ZGVjOo34dA3VpdI2r+9sgFO GTAg== X-Gm-Message-State: ALoCoQnx3vuvLn2sGKWz7TKEgt5VCaNLSGTVogCJavs7WvJql50cXwiWjCUZ4oKzQQzCXvR3s+ft X-Received: by 10.66.142.161 with SMTP id rx1mr15189926pab.37.1446792338196; Thu, 05 Nov 2015 22:45:38 -0800 (PST) Received: from localhost.localdomain (61-205-2-204m5.grp1.mineo.jp. [61.205.2.204]) by smtp.googlemail.com with ESMTPSA id zi1sm11732096pbc.10.2015.11.05.22.45.33 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 Nov 2015 22:45:36 -0800 (PST) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, rostedt@goodmis.org Cc: jungseoklee85@gmail.com, broonie@kernel.org, david.griego@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro Subject: [PATCH v5 2/6] arm64: ftrace: fix a stack tracer's output under function graph tracer Date: Fri, 6 Nov 2015 15:44:41 +0900 Message-Id: <1446792285-1154-3-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1446792285-1154-1-git-send-email-takahiro.akashi@linaro.org> References: <1446792285-1154-1-git-send-email-takahiro.akashi@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Function graph tracer modifies a return address (LR) in a stack frame to hook a function return. This will result in many useless entries (return_to_handler) showing up in a stack tracer's output. This patch replaces such entries with originals values preserved in current->ret_stack[]. Signed-off-by: AKASHI Takahiro --- arch/arm64/include/asm/ftrace.h | 2 ++ arch/arm64/kernel/stacktrace.c | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/arch/arm64/include/asm/ftrace.h b/arch/arm64/include/asm/ftrace.h index c5534fa..3c60f37 100644 --- a/arch/arm64/include/asm/ftrace.h +++ b/arch/arm64/include/asm/ftrace.h @@ -28,6 +28,8 @@ struct dyn_arch_ftrace { extern unsigned long ftrace_graph_call; +extern void return_to_handler(void); + static inline unsigned long ftrace_call_adjust(unsigned long addr) { /* diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c index ccb6078..5fd3477 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c @@ -17,6 +17,7 @@ */ #include #include +#include #include #include @@ -73,6 +74,9 @@ struct stack_trace_data { struct stack_trace *trace; unsigned int no_sched_functions; unsigned int skip; +#ifdef CONFIG_FUNCTION_GRAPH_TRACER + unsigned int ret_stack_index; +#endif }; static int save_trace(struct stackframe *frame, void *d) @@ -81,6 +85,20 @@ static int save_trace(struct stackframe *frame, void *d) struct stack_trace *trace = data->trace; unsigned long addr = frame->pc; +#ifdef CONFIG_FUNCTION_GRAPH_TRACER + if (addr == (unsigned long)return_to_handler - AARCH64_INSN_SIZE) { + /* + * This is a case where function graph tracer has + * modified a return address (LR) in a stack frame + * to hook a function return. + * So replace it to an original value. + */ + frame->pc = addr = + current->ret_stack[data->ret_stack_index--].ret + - AARCH64_INSN_SIZE; + } +#endif /* CONFIG_FUNCTION_GRAPH_TRACER */ + if (data->no_sched_functions && in_sched_functions(addr)) return 0; if (data->skip) { @@ -100,6 +118,9 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace) data.trace = trace; data.skip = trace->skip; +#ifdef CONFIG_FUNCTION_GRAPH_TRACER + data.ret_stack_index = current->curr_ret_stack; +#endif if (tsk != current) { data.no_sched_functions = 1;