Re: [PATCH] kmemleak: Avoid RCU stalls when freeing metadata for per-CPU pointers

Catalin Marinas
2023-12-06T11:31:31Z

On Fri, Dec 01, 2023 at 05:22:26PM -0500, Waiman Long wrote:
> On 12/1/23 14:08, Catalin Marinas wrote:
> > diff --git a/mm/kmemleak.c b/mm/kmemleak.c
> > index 1eacca03bedd..eb6cdc3e9af2 100644
> > --- a/mm/kmemleak.c
> > +++ b/mm/kmemleak.c
> > @@ -14,17 +14,15 @@
> > * The following locks and mutexes are used by kmemleak:
> > *
> > * - kmemleak_lock (raw_spinlock_t): protects the object_list as well as
> > - * del_state modifications and accesses to the object_tree_root (or
> > - * object_phys_tree_root). The object_list is the main list holding the
> > - * metadata (struct kmemleak_object) for the allocated memory blocks.
> > - * The object_tree_root and object_phys_tree_root are red
> > - * black trees used to look-up metadata based on a pointer to the
> > - * corresponding memory block. The object_phys_tree_root is for objects
> > - * allocated with physical address. The kmemleak_object structures are
> > - * added to the object_list and object_tree_root (or object_phys_tree_root)
> > - * in the create_object() function called from the kmemleak_alloc() (or
> > - * kmemleak_alloc_phys()) callback and removed in delete_object() called from
> > - * the kmemleak_free() callback
> > + * del_state modifications and accesses to the object trees
> > + * (object_tree_root, object_phys_tree_root, object_percpu_tree_root). The
> > + * object_list is the main list holding the metadata (struct
> > + * kmemleak_object) for the allocated memory blocks. The object trees are
> > + * red black trees used to look-up metadata based on a pointer to the
> > + * corresponding memory block. The kmemleak_object structures are added to
> > + * the object_list and the object tree root in the create_object() function
> > + * called from the kmemleak_alloc() (or kmemleak_alloc_phys()) callback and
> > + * removed in delete_object() called from the kmemleak_free() callback
>
> Just a minor nit. For completeness, should we mention
> kmemleak_alloc_percpu() and kmemleak_free_percpu() here?

Yeah, I was too lazy. I added some shell-style patterns and repost a v2.

> Anyway, I won't mind if you want to keep it as it is.
>
> Reviewed-by: Waiman Long <longman@redhat.com>

Thanks.

--
Catalin