Re: [PATCH] mm/kmemleak: rely on rcu for task stack scanning

From: Catalin Marinas
Date: Fri Aug 21 2020 - 14:09:39 EST


On Thu, Aug 20, 2020 at 01:39:02PM -0700, Davidlohr Bueso wrote:
> kmemleak_scan() currently relies on the big tasklist_lock
> hammer to stabilize iterating through the tasklist. Instead,
> this patch proposes simply using rcu along with the rcu-safe
> for_each_process_thread flavor (without changing scan semantics),
> which doesn't make use of next_thread/p->thread_group and thus
> cannot race with exit. Furthermore, any races with fork()
> and not seeing the new child should be benign as it's not
> running yet and can also be detected by the next scan.
>
> Signed-off-by: Davidlohr Bueso <dbueso@xxxxxxx>

As long as the kernel thread stack is still around (kmemleak does use
try_get_task_stack()), I'm fine with the change:

Acked-by: Catalin Marinas <catalin.marinas@xxxxxxx>