Re: [PATCH] tracing/timerlat: Check tlat_var for NULL in timerlat_fd_release
From: Steven Rostedt
Date: Thu Aug 22 2024 - 10:34:18 EST
On Thu, 22 Aug 2024 08:20:52 -0300
"Luis Claudio R. Goncalves" <lgoncalv@xxxxxxxxxx> 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