FAILED: patch "[PATCH] fgraph: Fix thresh_return nosleeptime double-adjust" failed to apply to 6.18-stable tree
Subsystems (2)
[email protected]
maintainerThe 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 <[email protected]>.
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 '<[email protected]>' --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 <[email protected]>
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.
kernel/trace/trace_functions_graph.c +10 -4
@@ -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 = {
Sasha Levin
maintainerPATCH 1/1 fgraph: Fix thresh_return nosleeptime double-adjust
From: Shengming Hu <[email protected]>
[ 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.
--- kernel/trace/trace_functions_graph.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
kernel/trace/trace_functions_graph.c +11 -4
@@ -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 = {
Signature · 1 line
2.51.0
Re: [PATCH 6.18.y] fgraph: Fix thresh_return nosleeptime double-adjust
Quoted 66 lines · Sasha Levin
From: Shengming Hu <[email protected]>
[ Upstream commit
b96d0c59cdbb2a22b2545f6f3d5c6276b05761dd]
trace_graph_thresh_return()calledhandle_nosleeptime()and then delegated totrace_graph_return(), which callshandle_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.Fixes 3c9880f3ab52b ("ftrace: Use a running sleeptime instead of saving on shadow stack")Signed-off-by Shengming Hu <[email protected]>Signed-off-by Steven Rostedt (Google) <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- kernel/trace/trace_functions_graph.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)kernel/trace/trace_functions_graph.c +11
-4@@ -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 = {Signature · 1 line
2.51.0
Does not apply to the tree :(