* FAILED: patch "[PATCH] fgraph: Fix thresh_return nosleeptime double-adjust" failed to apply to 6.18-stable tree
@ 2026-03-17 12:01 gregkh
2026-03-18 13:13 ` [PATCH 6.18.y] fgraph: Fix thresh_return nosleeptime double-adjust Sasha Levin
0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2026-03-17 12:01 UTC (permalink / raw)
To: hu.shengming, mhiramat, rostedt; +Cc: stable
The patch below does not apply to the 6.18-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y
git checkout FETCH_HEAD
git cherry-pick -x b96d0c59cdbb2a22b2545f6f3d5c6276b05761dd
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026031739-bride-reproduce-be1c@gregkh' --subject-prefix 'PATCH 6.18.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From b96d0c59cdbb2a22b2545f6f3d5c6276b05761dd Mon Sep 17 00:00:00 2001
From: Shengming Hu <hu.shengming@zte.com.cn>
Date: Sat, 21 Feb 2026 11:33:14 +0800
Subject: [PATCH] fgraph: Fix thresh_return nosleeptime double-adjust
trace_graph_thresh_return() called handle_nosleeptime() and then delegated
to trace_graph_return(), which calls handle_nosleeptime() again. When
sleep-time accounting is disabled this double-adjusts calltime and can
produce bogus durations (including underflow).
Fix this by computing rettime once, applying handle_nosleeptime() only
once, using the adjusted calltime for threshold comparison, and writing
the return event directly via __trace_graph_return() when the threshold is
met.
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260221113314048jE4VRwIyZEALiYByGK0My@zte.com.cn
Fixes: 3c9880f3ab52b ("ftrace: Use a running sleeptime instead of saving on shadow stack")
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Shengming Hu <hu.shengming@zte.com.cn>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
index 817d0f1696b6..0d2d3a2ea7dd 100644
--- a/kernel/trace/trace_functions_graph.c
+++ b/kernel/trace/trace_functions_graph.c
@@ -403,8 +403,12 @@ static void trace_graph_thresh_return(struct ftrace_graph_ret *trace,
unsigned long *task_var = fgraph_get_task_var(gops);
struct fgraph_times *ftimes;
struct trace_array *tr;
+ unsigned int trace_ctx;
+ u64 calltime, rettime;
int size;
+ rettime = trace_clock_local();
+
ftrace_graph_addr_finish(gops, trace);
if (*task_var & TRACE_GRAPH_NOTRACE) {
@@ -419,11 +423,13 @@ static void trace_graph_thresh_return(struct ftrace_graph_ret *trace,
tr = gops->private;
handle_nosleeptime(tr, trace, ftimes, size);
- if (tracing_thresh &&
- (trace_clock_local() - ftimes->calltime < tracing_thresh))
+ calltime = ftimes->calltime;
+
+ if (tracing_thresh && (rettime - calltime < tracing_thresh))
return;
- else
- trace_graph_return(trace, gops, fregs);
+
+ trace_ctx = tracing_gen_ctx();
+ __trace_graph_return(tr, trace, trace_ctx, calltime, rettime);
}
static struct fgraph_ops funcgraph_ops = {
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 6.18.y] fgraph: Fix thresh_return nosleeptime double-adjust
2026-03-17 12:01 FAILED: patch "[PATCH] fgraph: Fix thresh_return nosleeptime double-adjust" failed to apply to 6.18-stable tree gregkh
@ 2026-03-18 13:13 ` Sasha Levin
2026-03-20 17:08 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Sasha Levin @ 2026-03-18 13:13 UTC (permalink / raw)
To: stable
Cc: Shengming Hu, Masami Hiramatsu (Google), Steven Rostedt (Google),
Sasha Levin
From: Shengming Hu <hu.shengming@zte.com.cn>
[ Upstream commit b96d0c59cdbb2a22b2545f6f3d5c6276b05761dd ]
trace_graph_thresh_return() called handle_nosleeptime() and then delegated
to trace_graph_return(), which calls handle_nosleeptime() again. When
sleep-time accounting is disabled this double-adjusts calltime and can
produce bogus durations (including underflow).
Fix this by computing rettime once, applying handle_nosleeptime() only
once, using the adjusted calltime for threshold comparison, and writing
the return event directly via __trace_graph_return() when the threshold is
met.
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260221113314048jE4VRwIyZEALiYByGK0My@zte.com.cn
Fixes: 3c9880f3ab52b ("ftrace: Use a running sleeptime instead of saving on shadow stack")
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Shengming Hu <hu.shengming@zte.com.cn>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/trace/trace_functions_graph.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
index a7f4b9a47a71a..0e65d1f452657 100644
--- a/kernel/trace/trace_functions_graph.c
+++ b/kernel/trace/trace_functions_graph.c
@@ -378,9 +378,14 @@ static void trace_graph_thresh_return(struct ftrace_graph_ret *trace,
struct fgraph_ops *gops,
struct ftrace_regs *fregs)
{
+ struct trace_array *tr = gops->private;
struct fgraph_times *ftimes;
+ unsigned int trace_ctx;
+ u64 calltime, rettime;
int size;
+ rettime = trace_clock_local();
+
ftrace_graph_addr_finish(gops, trace);
if (trace_recursion_test(TRACE_GRAPH_NOTRACE_BIT)) {
@@ -394,11 +399,13 @@ static void trace_graph_thresh_return(struct ftrace_graph_ret *trace,
handle_nosleeptime(trace, ftimes, size);
- if (tracing_thresh &&
- (trace_clock_local() - ftimes->calltime < tracing_thresh))
+ calltime = ftimes->calltime;
+
+ if (tracing_thresh && (rettime - calltime < tracing_thresh))
return;
- else
- trace_graph_return(trace, gops, fregs);
+
+ trace_ctx = tracing_gen_ctx();
+ __trace_graph_return(tr, trace, trace_ctx, calltime, rettime);
}
static struct fgraph_ops funcgraph_ops = {
--
2.51.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH 6.18.y] fgraph: Fix thresh_return nosleeptime double-adjust
2026-03-18 13:13 ` [PATCH 6.18.y] fgraph: Fix thresh_return nosleeptime double-adjust Sasha Levin
@ 2026-03-20 17:08 ` Greg KH
0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2026-03-20 17:08 UTC (permalink / raw)
To: Sasha Levin
Cc: stable, Shengming Hu, Masami Hiramatsu (Google),
Steven Rostedt (Google)
On Wed, Mar 18, 2026 at 09:13:53AM -0400, Sasha Levin wrote:
> From: Shengming Hu <hu.shengming@zte.com.cn>
>
> [ Upstream commit b96d0c59cdbb2a22b2545f6f3d5c6276b05761dd ]
>
> trace_graph_thresh_return() called handle_nosleeptime() and then delegated
> to trace_graph_return(), which calls handle_nosleeptime() again. When
> sleep-time accounting is disabled this double-adjusts calltime and can
> produce bogus durations (including underflow).
>
> Fix this by computing rettime once, applying handle_nosleeptime() only
> once, using the adjusted calltime for threshold comparison, and writing
> the return event directly via __trace_graph_return() when the threshold is
> met.
>
> Cc: stable@vger.kernel.org
> Link: https://patch.msgid.link/20260221113314048jE4VRwIyZEALiYByGK0My@zte.com.cn
> Fixes: 3c9880f3ab52b ("ftrace: Use a running sleeptime instead of saving on shadow stack")
> Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> Signed-off-by: Shengming Hu <hu.shengming@zte.com.cn>
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
> kernel/trace/trace_functions_graph.c | 15 +++++++++++----
> 1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
> index a7f4b9a47a71a..0e65d1f452657 100644
> --- a/kernel/trace/trace_functions_graph.c
> +++ b/kernel/trace/trace_functions_graph.c
> @@ -378,9 +378,14 @@ static void trace_graph_thresh_return(struct ftrace_graph_ret *trace,
> struct fgraph_ops *gops,
> struct ftrace_regs *fregs)
> {
> + struct trace_array *tr = gops->private;
> struct fgraph_times *ftimes;
> + unsigned int trace_ctx;
> + u64 calltime, rettime;
> int size;
>
> + rettime = trace_clock_local();
> +
> ftrace_graph_addr_finish(gops, trace);
>
> if (trace_recursion_test(TRACE_GRAPH_NOTRACE_BIT)) {
> @@ -394,11 +399,13 @@ static void trace_graph_thresh_return(struct ftrace_graph_ret *trace,
>
> handle_nosleeptime(trace, ftimes, size);
>
> - if (tracing_thresh &&
> - (trace_clock_local() - ftimes->calltime < tracing_thresh))
> + calltime = ftimes->calltime;
> +
> + if (tracing_thresh && (rettime - calltime < tracing_thresh))
> return;
> - else
> - trace_graph_return(trace, gops, fregs);
> +
> + trace_ctx = tracing_gen_ctx();
> + __trace_graph_return(tr, trace, trace_ctx, calltime, rettime);
> }
>
> static struct fgraph_ops funcgraph_ops = {
> --
> 2.51.0
>
>
Does not apply to the tree :(
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-20 17:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-17 12:01 FAILED: patch "[PATCH] fgraph: Fix thresh_return nosleeptime double-adjust" failed to apply to 6.18-stable tree gregkh
2026-03-18 13:13 ` [PATCH 6.18.y] fgraph: Fix thresh_return nosleeptime double-adjust Sasha Levin
2026-03-20 17:08 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox