From: AKASHI Takahiro <takahiro.akashi@linaro.org> 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 <takahiro.akashi@linaro.org> Subject: [PATCH v4 2/6] arm64: ftrace: modify a stack frame in a safe way Date: Fri, 30 Oct 2015 14:25:37 +0900 [thread overview] Message-ID: <1446182741-31019-3-git-send-email-takahiro.akashi@linaro.org> (raw) In-Reply-To: <1446182741-31019-1-git-send-email-takahiro.akashi@linaro.org> Function graph tracer modifies a return address (LR) in a stack frame by calling ftrace_prepare_return() in a traced function's function prologue. The current code does this modification before preserving an original address at ftrace_push_return_trace() and there is always a small window of inconsistency when an interrupt occurs. This doesn't matter, as far as an interrupt stack is introduced, because stack tracer won't be invoked in an interrupt context. But it would be better to proactively minimize such a window by moving the LR modification after ftrace_push_return_trace(). Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> --- arch/arm64/kernel/ftrace.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c index c851be7..314f82d 100644 --- a/arch/arm64/kernel/ftrace.c +++ b/arch/arm64/kernel/ftrace.c @@ -125,23 +125,20 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr, * on other archs. It's unlikely on AArch64. */ old = *parent; - *parent = return_hooker; trace.func = self_addr; trace.depth = current->curr_ret_stack + 1; /* Only trace if the calling function expects to */ - if (!ftrace_graph_entry(&trace)) { - *parent = old; + if (!ftrace_graph_entry(&trace)) return; - } err = ftrace_push_return_trace(old, self_addr, &trace.depth, frame_pointer); - if (err == -EBUSY) { - *parent = old; + if (err == -EBUSY) return; - } + else + *parent = return_hooker; } #ifdef CONFIG_DYNAMIC_FTRACE -- 1.7.9.5
WARNING: multiple messages have this Message-ID (diff)
From: takahiro.akashi@linaro.org (AKASHI Takahiro) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 2/6] arm64: ftrace: modify a stack frame in a safe way Date: Fri, 30 Oct 2015 14:25:37 +0900 [thread overview] Message-ID: <1446182741-31019-3-git-send-email-takahiro.akashi@linaro.org> (raw) In-Reply-To: <1446182741-31019-1-git-send-email-takahiro.akashi@linaro.org> Function graph tracer modifies a return address (LR) in a stack frame by calling ftrace_prepare_return() in a traced function's function prologue. The current code does this modification before preserving an original address at ftrace_push_return_trace() and there is always a small window of inconsistency when an interrupt occurs. This doesn't matter, as far as an interrupt stack is introduced, because stack tracer won't be invoked in an interrupt context. But it would be better to proactively minimize such a window by moving the LR modification after ftrace_push_return_trace(). Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> --- arch/arm64/kernel/ftrace.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c index c851be7..314f82d 100644 --- a/arch/arm64/kernel/ftrace.c +++ b/arch/arm64/kernel/ftrace.c @@ -125,23 +125,20 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr, * on other archs. It's unlikely on AArch64. */ old = *parent; - *parent = return_hooker; trace.func = self_addr; trace.depth = current->curr_ret_stack + 1; /* Only trace if the calling function expects to */ - if (!ftrace_graph_entry(&trace)) { - *parent = old; + if (!ftrace_graph_entry(&trace)) return; - } err = ftrace_push_return_trace(old, self_addr, &trace.depth, frame_pointer); - if (err == -EBUSY) { - *parent = old; + if (err == -EBUSY) return; - } + else + *parent = return_hooker; } #ifdef CONFIG_DYNAMIC_FTRACE -- 1.7.9.5
next prev parent reply other threads:[~2015-10-30 5:27 UTC|newest] Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-10-30 5:25 [PATCH v4 0/6] arm64: ftrace: fix incorrect output from stack tracer AKASHI Takahiro 2015-10-30 5:25 ` AKASHI Takahiro 2015-10-30 5:25 ` [PATCH v4 1/6] arm64: ftrace: adjust callsite addresses examined by " AKASHI Takahiro 2015-10-30 5:25 ` AKASHI Takahiro 2015-10-30 11:16 ` Will Deacon 2015-10-30 11:16 ` Will Deacon 2015-11-02 18:20 ` Steven Rostedt 2015-11-02 18:20 ` Steven Rostedt 2015-11-02 18:29 ` Mark Rutland 2015-11-02 18:29 ` Mark Rutland 2015-11-02 18:41 ` Will Deacon 2015-11-02 18:41 ` Will Deacon 2015-11-02 18:43 ` Mark Rutland 2015-11-02 18:43 ` Mark Rutland 2015-10-30 5:25 ` AKASHI Takahiro [this message] 2015-10-30 5:25 ` [PATCH v4 2/6] arm64: ftrace: modify a stack frame in a safe way AKASHI Takahiro 2015-10-30 5:25 ` [PATCH v4 3/6] arm64: ftrace: fix a stack tracer's output under function graph tracer AKASHI Takahiro 2015-10-30 5:25 ` AKASHI Takahiro 2015-11-01 8:00 ` Jungseok Lee 2015-11-01 8:00 ` Jungseok Lee 2015-11-04 7:49 ` AKASHI Takahiro 2015-11-04 7:49 ` AKASHI Takahiro 2015-10-30 5:25 ` [PATCH v4 4/6] ftrace: allow arch-specific stack tracer AKASHI Takahiro 2015-10-30 5:25 ` AKASHI Takahiro 2015-10-30 5:25 ` [PATCH v4 5/6] arm64: insn: add instruction decoders for ldp/stp and add/sub AKASHI Takahiro 2015-10-30 5:25 ` AKASHI Takahiro 2015-10-30 5:25 ` [PATCH v4 6/6] arm64: ftrace: add arch-specific stack tracer AKASHI Takahiro 2015-10-30 5:25 ` AKASHI Takahiro 2015-11-01 8:30 ` Jungseok Lee 2015-11-01 8:30 ` Jungseok Lee 2015-11-04 8:01 ` AKASHI Takahiro 2015-11-04 8:01 ` AKASHI Takahiro 2015-11-04 8:42 ` yalin wang 2015-11-04 8:42 ` yalin wang
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1446182741-31019-3-git-send-email-takahiro.akashi@linaro.org \ --to=takahiro.akashi@linaro.org \ --cc=broonie@kernel.org \ --cc=catalin.marinas@arm.com \ --cc=david.griego@linaro.org \ --cc=jungseoklee85@gmail.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=olof@lixom.net \ --cc=rostedt@goodmis.org \ --cc=will.deacon@arm.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.