Thread (19 messages) 19 messages, 3 authors, 2024-09-05

Re: [PATCH] tracing/timerlat: Check tlat_var for NULL in timerlat_fd_release

From: Steven Rostedt <rostedt@goodmis.org>
Date: 2024-08-22 14:34:13
Also in: lkml
Subsystem: the rest, tracing, tracing os noise / latency tracers · Maintainers: Linus Torvalds, Steven Rostedt, Masami Hiramatsu

On Thu, 22 Aug 2024 08:20:52 -0300
"Luis Claudio R. Goncalves" [off-list ref] wrote:
You mean the 

+	if (!tlat_var->kthread) {
+		/* the fd has been closed already */

bit or the kthread handling in rtla itself?

As Tomas already said, thank you for testing and reviewing the suggested fix!
The close only happens once, but the kthread does get freed elsewhere.

I used my new persistent ring buffer to debug this! I'll be posting some
more patches that allow trace_printk() and friends to use the persistent
ring buffer (or any instance) soon.

For this bug, I would recommend instead doing:
diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
index 66a871553d4a..53de719f35cb 100644
--- a/kernel/trace/trace_osnoise.c
+++ b/kernel/trace/trace_osnoise.c
@@ -2579,7 +2587,8 @@ static int timerlat_fd_release(struct inode *inode, struct file *file)
 	osn_var = per_cpu_ptr(&per_cpu_osnoise_var, cpu);
 	tlat_var = per_cpu_ptr(&per_cpu_timerlat_var, cpu);
 
-	hrtimer_cancel(&tlat_var->timer);
+	if (tlat_var->kthread)
+		hrtimer_cancel(&tlat_var->timer);
 	memset(tlat_var, 0, sizeof(*tlat_var));
 
 	osn_var->sampling = 0;

-- Steve
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help