lkml.org 
[lkml]   [2019]   [Sep]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH RFC 02/14] mm: memcg: introduce mem_cgroup_ptr
Date
On Thu, Sep 05, 2019 at 02:45:46PM -0700, Roman Gushchin wrote:
> This commit introduces mem_cgroup_ptr structure and corresponding API.
> It implements a pointer to a memory cgroup with a built-in reference
> counter. The main goal of it is to implement reparenting efficiently.
>
> If a number of objects (e.g. slab pages) have to keep a pointer and
> a reference to a memory cgroup, they can use mem_cgroup_ptr instead.
> On reparenting, only one mem_cgroup_ptr->memcg pointer has to be
> changed, instead of walking over all accounted objects.
>
> mem_cgroup_ptr holds a single reference to the corresponding memory
> cgroup. Because it's initialized before the css reference counter,
> css's refcounter can't be bumped at allocation time. Instead, it's
> bumped on reparenting which happens during offlining. A cgroup is
> never released online, so it's fine.
>
> mem_cgroup_ptr is released using rcu, so memcg->kmem_memcg_ptr can
> be accessed in a rcu read section. On reparenting it's atomically
> switched to NULL. If the reader gets NULL, it can just read parent's
> kmem_memcg_ptr instead.
>
> Each memory cgroup contains a list of kmem_memcg_ptrs. On reparenting
> the list is spliced into the parent's list. The list is protected
> using the css set lock.
>
> Signed-off-by: Roman Gushchin <guro@fb.com>
> ---
> include/linux/memcontrol.h | 50 ++++++++++++++++++++++
> mm/memcontrol.c | 87 ++++++++++++++++++++++++++++++++++++--
> 2 files changed, 133 insertions(+), 4 deletions(-)
>
> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
> index 120d39066148..dd5ebfe5a86c 100644
> --- a/include/linux/memcontrol.h
> +++ b/include/linux/memcontrol.h
> @@ -23,6 +23,7 @@
> #include <linux/page-flags.h>
>
> struct mem_cgroup;
> +struct mem_cgroup_ptr;
> struct page;
> struct mm_struct;
> struct kmem_cache;
> @@ -197,6 +198,22 @@ struct memcg_cgwb_frn {
> int memcg_id; /* memcg->css.id of foreign inode */
> u64 at; /* jiffies_64 at the time of dirtying */
> struct wb_completion done; /* tracks in-flight foreign writebacks */
> +}

Oops, a semicolon has been lost during the final rebase.
I'll send a correct version of this patch separately.

Sorry for the mess.

\
 
 \ /
  Last update: 2019-09-06 00:35    [W:0.759 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site