Re: [PATCH] tracing/timerlat: Check tlat_var for NULL in timerlat_fd_release
From: Tomas Glozar
Date: Thu Sep 05 2024 - 06:39:12 EST
st 4. 9. 2024 v 16:23 odesílatel Steven Rostedt <rostedt@xxxxxxxxxxx> napsal:
>
> When running my tests, the second one would end up deadlocking and
> triggering lockdep. I found a way to do basically the same thing with a
> cpumask and no added locking. I'm currently testing it and will be sending
> out a patch later today (if it passes the tests).
>
> -- Steve
>
Oh that's unfortunate. Your cpumask patch does protect from timerlat
trying to stop a user workload thread via kthread_stop, but I don't
think it prevents this race in the code from the other patch:
static int timerlat_fd_release(struct inode *inode, struct file *file)
{
...
mutex_lock(&interface_lock);
<-- this can now run at the same time as tlat_var_reset(), since
the latter is not done under interface_lock in the latest version
...
if (tlat_var->kthread)
<-- if tlat_var is zeroed here, we still panic on NULL dereference
hrtimer_cancel(&tlat_var->timer);
...
}
Either way, the results are much better: before, the kernel panicked
in <10 iterations of the while loop of the reproducer; with the
cpumask patch and the tlat_var->kthread check patch, it has been
running on my test VM for a few hours already with no panic.
Tomas