From patchwork Fri Oct 30 05:25:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 55817 Delivered-To: patch@linaro.org Received: by 10.112.61.134 with SMTP id p6csp965688lbr; Thu, 29 Oct 2015 22:27:39 -0700 (PDT) X-Received: by 10.50.78.7 with SMTP id x7mr1108456igw.54.1446182859534; Thu, 29 Oct 2015 22:27:39 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s9si923314igh.85.2015.10.29.22.27.39; Thu, 29 Oct 2015 22:27:39 -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; 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 S1758513AbbJ3F1h (ORCPT + 28 others); Fri, 30 Oct 2015 01:27:37 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:36554 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758489AbbJ3F1e (ORCPT ); Fri, 30 Oct 2015 01:27:34 -0400 Received: by pacfv9 with SMTP id fv9so65565245pac.3 for ; Thu, 29 Oct 2015 22:27:34 -0700 (PDT) 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=jdql3RuO439C8xN0eg+3vJeUMHl4cwvjFP6wO/f93Tc=; b=v6RIY2RG8bho2TfUfDIFpwjQAAGd/cEpK2aZ+X7cB1Dn4TarYWmy8eUgZ/uAsLxvHt XpNPqbZzszyXt663q2nVCkZqUoeRMnXRt6gxXdmSH4onhPdgCz/zLTAALHdQR/srhkqo xiWiSg2mXIPXisy9N0s0lmdxvd2KbrPBGk/zpiQ5rKQ9bd+jqIJAUGTeraHh2auWSdp+ s7B3b7EnvsKOayqv4sURRKdRsdPSzmZG7O3DWwMfNwYs91ZTNCEl/JFwXB9hUCzSbrDi O1DZgaP1HAP2eU2hzuvvEx8vPb/3u7cb4kbeXZlw+M8N09ec/uFgtVttzLFHu09+LjU3 GCvw== 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=jdql3RuO439C8xN0eg+3vJeUMHl4cwvjFP6wO/f93Tc=; b=ZwNfaCWJwwnQrMuy6ioCdhbF/qJODSQd/3LlqDH2zWfzaEpb7xvTez/6KRkeFE9FsZ UvTeBwLbhOePeGSxQYvAYcKW4ojml+yV62m0OBVvWCCOnWnA+p7y4z+L8lnLKeJtKQSK 2dYrI2VNKM0J7Ntlpi9IjpBhP6uLSuegh1jlyn14AUh54T+iAGhaoQ4ANVwKgCZBEpKk TCbrgCVfLBLj3/G2wAR+bg9yO4xYtPqwGy6CJjnFgQN5cq0NYNykEU0KjkDv+8ck0iVD 3TLqmT/f4lUBE2mqa6FqmWHGryBKmuVg1T5HLzMJS3rP/+suxcj+Gxv1IGw724R/VxUO eqwA== X-Gm-Message-State: ALoCoQk2nEEeEqqr2l3z7mEtMGrRzEpZH74gqJEXDElhIdGUGb59dfFXab/EuT8Sv/VGNiT2hEWs X-Received: by 10.68.69.72 with SMTP id c8mr6366908pbu.2.1446182854234; Thu, 29 Oct 2015 22:27:34 -0700 (PDT) Received: from localhost.localdomain (61-205-6-54m5.grp1.mineo.jp. [61.205.6.54]) by smtp.googlemail.com with ESMTPSA id ho3sm5571377pbb.18.2015.10.29.22.27.29 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Oct 2015 22:27:33 -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 v4 3/6] arm64: ftrace: fix a stack tracer's output under function graph tracer Date: Fri, 30 Oct 2015 14:25:38 +0900 Message-Id: <1446182741-31019-4-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1446182741-31019-1-git-send-email-takahiro.akashi@linaro.org> References: <1446182741-31019-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 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..631c49d 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c @@ -17,6 +17,7 @@ */ #include #include +#include #include #include @@ -78,6 +79,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 +90,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 +123,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;