From patchwork Thu Oct 8 10:01:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 54654 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by patches.linaro.org (Postfix) with ESMTPS id EED6922FF4 for ; Thu, 8 Oct 2015 10:03:49 +0000 (UTC) Received: by lbbti1 with SMTP id ti1sf21162220lbb.3 for ; Thu, 08 Oct 2015 03:03:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=KT+1Nzh72oARmou8sKT0kYoEC4hbj9nRBvDEDcrCN00=; b=GQh1q1NoZ+35Z2I3mhJcZE3jfXhJEybmYdHUFqAIVr+zLykWq5GeKDp1OKkJV78xX/ R0VUjDjrWbyRoFfYAyAYTcnSY3InYquj8AzKc2EYWbiwS29ty6Z1bKvCEwFvmblMc++H Kuol0xWBwGfvdShhv1U6FvwaxkBUG/HcUn7mdYOtJWMmfLFtVxnJlb7WVQ5zGXwhDdkP 4mwf6EXM99lFs0FSImVbk2Cq56Lu/RMVJ0iursuuM/8nN6Bs65k/qr2VgNjFPRcHXkbb CvkonGqMPsOsda1in43ZjZNcEo2/GO8kDU6MUi/zXOAnrtLifuHFg0NKtOs7pGSv4v18 8zeQ== X-Gm-Message-State: ALoCoQmSbHTowpbEFFfO178YwVWPXOtdG6O9J5mea8wq6X1Z49R9fFQ+owgDPoag5sickbmUUiCE X-Received: by 10.180.35.132 with SMTP id h4mr519778wij.5.1444298628955; Thu, 08 Oct 2015 03:03:48 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.16.92 with SMTP id f89ls154396lfi.25.gmail; Thu, 08 Oct 2015 03:03:48 -0700 (PDT) X-Received: by 10.25.142.203 with SMTP id q194mr2026804lfd.83.1444298628776; Thu, 08 Oct 2015 03:03:48 -0700 (PDT) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id as1si29045875lbc.94.2015.10.08.03.03.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Oct 2015 03:03:48 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by lbbwt4 with SMTP id wt4so41101015lbb.1 for ; Thu, 08 Oct 2015 03:03:48 -0700 (PDT) X-Received: by 10.112.146.104 with SMTP id tb8mr3215147lbb.35.1444298628601; Thu, 08 Oct 2015 03:03:48 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp482803lbq; Thu, 8 Oct 2015 03:03:35 -0700 (PDT) X-Received: by 10.50.50.139 with SMTP id c11mr2816979igo.10.1444298614349; Thu, 08 Oct 2015 03:03:34 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o19si6073495igt.21.2015.10.08.03.03.34; Thu, 08 Oct 2015 03:03:34 -0700 (PDT) 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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755644AbbJHKDa (ORCPT + 30 others); Thu, 8 Oct 2015 06:03:30 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:32859 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755482AbbJHKD1 (ORCPT ); Thu, 8 Oct 2015 06:03:27 -0400 Received: by pacex6 with SMTP id ex6so50902232pac.0 for ; Thu, 08 Oct 2015 03:03:27 -0700 (PDT) X-Received: by 10.68.181.130 with SMTP id dw2mr7234357pbc.70.1444298607387; Thu, 08 Oct 2015 03:03:27 -0700 (PDT) Received: from localhost.localdomain (61-205-1-208m5.grp1.mineo.jp. [61.205.1.208]) by smtp.googlemail.com with ESMTPSA id ya10sm44431428pbc.69.2015.10.08.03.03.21 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Oct 2015 03:03:25 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, rostedt@goodmis.org Cc: jungseoklee85@gmail.com, olof@lixom.net, broonie@kernel.org, david.griego@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro Subject: [PATCH v3 3/7] arm64: ftrace: fix a stack tracer's output under function graph tracer Date: Thu, 8 Oct 2015 19:01:40 +0900 Message-Id: <1444298504-10392-4-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1444298504-10392-1-git-send-email-takahiro.akashi@linaro.org> References: <1444298504-10392-1-git-send-email-takahiro.akashi@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: takahiro.akashi@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/arch/arm64/include/asm/ftrace.h b/arch/arm64/include/asm/ftrace.h index 2b43e20..b7d597c 100644 --- a/arch/arm64/include/asm/ftrace.h +++ b/arch/arm64/include/asm/ftrace.h @@ -29,6 +29,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 bc0689a..1555a8b 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c @@ -78,6 +78,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) @@ -86,6 +89,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) { @@ -105,6 +122,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;