Correct. tasklist_lock is only needed to guard for_each_process_thread(); idle tasks are bound to their CPU and are not subject to exit/reparent, so no lock is needed for for_each_present_cpu().
Reviewed-by: Wen Yang <[email protected]> On 5/12/26 22:02, Gabriele Monaco wrote:
The da_monitor_reset_all() function for per-task monitors takes tasklist_lock while iterating over tasks, then keeps it also while iterating over idle tasks (one per CPU). The latter is not necessary since the lock needs to guard only for_each_process_thread(). Use a scoped_guard for more compact syntax and adjust the scope only where the lock is necessary. Fixes: 30984ccf31b7f ("rv: Refactor da_monitor to minimise macros") Fixes: 8259cb14a7068 ("rv: Reset per-task monitors also for idle tasks") Signed-off-by: Gabriele Monaco <[email protected]> --- include/rv/da_monitor.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/rv/da_monitor.h b/include/rv/da_monitor.h index 39765ff6f098..250888812125 100644 --- a/include/rv/da_monitor.h +++ b/include/rv/da_monitor.h @@ -272,12 +272,12 @@ static void da_monitor_reset_all(void) struct task_struct *g, *p; int cpu;- read_lock(&tasklist_lock);- for_each_process_thread(g, p) - da_monitor_reset(da_get_monitor(p)); + scoped_guard(read_lock, &tasklist_lock) { + for_each_process_thread(g, p) + da_monitor_reset(da_get_monitor(p)); + } for_each_present_cpu(cpu) da_monitor_reset(da_get_monitor(idle_task(cpu))); - read_unlock(&tasklist_lock); }/*
