Re: [PATCH v2 4/5] mm: kmem: scoped objcg protection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Oct 09, 2023 at 05:09:28PM -0700, Roman Gushchin wrote:
> Switch to a scope-based protection of the objcg pointer on slab/kmem
> allocation paths. Instead of using the get_() semantics in the
> pre-allocation hook and put the reference afterwards, let's rely
> on the fact that objcg is pinned by the scope.
> 
> It's possible because:
> 1) if the objcg is received from the current task struct, the task is
>    keeping a reference to the objcg.
> 2) if the objcg is received from an active memcg (remote charging),
>    the memcg is pinned by the scope and has a reference to the
>    corresponding objcg.
> 
> Signed-off-by: Roman Gushchin (Cruise) <roman.gushchin@xxxxxxxxx>

Other than one nit below:

Acked-by: Shakeel Butt <shakeelb@xxxxxxxxxx>

> ---
>  include/linux/memcontrol.h |  6 +++++
>  mm/memcontrol.c            | 47 ++++++++++++++++++++++++++++++++++++--
>  mm/slab.h                  | 10 +++-----
>  3 files changed, 54 insertions(+), 9 deletions(-)
> 
> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
> index 277690af383d..0e53b890f063 100644
> --- a/include/linux/memcontrol.h
> +++ b/include/linux/memcontrol.h
> @@ -1769,6 +1769,12 @@ bool mem_cgroup_kmem_disabled(void);
>  int __memcg_kmem_charge_page(struct page *page, gfp_t gfp, int order);
>  void __memcg_kmem_uncharge_page(struct page *page, int order);
>  
> +/*
> + * The returned objcg pointer is safe to use without additional
> + * protection within a scope, refer to the implementation for the
> + * additional details.
> + */

Let's add the definition of scope in the above comment as well like
set_active_memcg and slab memcg hooks.





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux