linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Roman Gushchin <guro@fb.com>
To: "linux-mm@kvack.org" <linux-mm@kvack.org>
Cc: Michal Hocko <mhocko@kernel.org>,
	Johannes Weiner <hannes@cmpxchg.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Kernel Team <Kernel-team@fb.com>,
	Shakeel Butt <shakeelb@google.com>,
	Vladimir Davydov <vdavydov.dev@gmail.com>,
	Waiman Long <longman@redhat.com>
Subject: Re: [PATCH RFC 02/14] mm: memcg: introduce mem_cgroup_ptr
Date: Thu, 5 Sep 2019 22:34:37 +0000	[thread overview]
Message-ID: <20190905223433.GA5686@tower.DHCP.thefacebook.com> (raw)
In-Reply-To: <20190905214553.1643060-3-guro@fb.com>

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.

  reply	other threads:[~2019-09-05 22:35 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-05 21:45 [PATCH RFC 00/14] The new slab memory controller Roman Gushchin
2019-09-05 21:45 ` [PATCH RFC 01/14] mm: memcg: subpage charging API Roman Gushchin
2019-09-16 12:56   ` Johannes Weiner
2019-09-17  2:27     ` Roman Gushchin
2019-09-17  8:50       ` Johannes Weiner
2019-09-17 18:33         ` Roman Gushchin
2019-09-05 21:45 ` [PATCH RFC 02/14] mm: memcg: introduce mem_cgroup_ptr Roman Gushchin
2019-09-05 22:34   ` Roman Gushchin [this message]
2019-09-05 21:45 ` [PATCH RFC 03/14] mm: vmstat: use s32 for vm_node_stat_diff in struct per_cpu_nodestat Roman Gushchin
2019-09-05 21:45 ` [PATCH RFC 04/14] mm: vmstat: convert slab vmstat counter to bytes Roman Gushchin
2019-09-16 12:38   ` Johannes Weiner
2019-09-17  2:08     ` Roman Gushchin
2019-09-05 21:45 ` [PATCH RFC 05/14] mm: memcg/slab: allocate space for memcg ownership data for non-root slabs Roman Gushchin
2019-09-05 21:45 ` [PATCH RFC 06/14] mm: slub: implement SLUB version of obj_to_index() Roman Gushchin
2019-09-05 21:45 ` [PATCH RFC 07/14] mm: memcg/slab: save memcg ownership data for non-root slab objects Roman Gushchin
2019-09-05 21:45 ` [PATCH RFC 08/14] mm: memcg: move memcg_kmem_bypass() to memcontrol.h Roman Gushchin
2019-09-05 21:45 ` [PATCH RFC 09/14] mm: memcg: introduce __mod_lruvec_memcg_state() Roman Gushchin
2019-09-05 22:37 ` [PATCH RFC 02/14] mm: memcg: introduce mem_cgroup_ptr Roman Gushchin
2019-09-17 19:48 ` [PATCH RFC 00/14] The new slab memory controller Waiman Long
2019-09-17 21:24   ` Roman Gushchin
2019-09-19 13:39 ` Suleiman Souhlal
2019-09-19 16:22   ` Roman Gushchin
2019-09-19 21:10     ` Suleiman Souhlal
2019-09-19 21:40       ` Roman Gushchin
2019-10-01 15:12 ` Michal Koutný
2019-10-02  2:09   ` Roman Gushchin
2019-10-02 13:00     ` Suleiman Souhlal
2019-10-03 10:47       ` Michal Koutný
2019-10-03 15:52         ` Roman Gushchin
2019-12-09  9:17 ` [PATCH 00/16] " Bharata B Rao
2019-12-09 11:56   ` Bharata B Rao
2019-12-09 18:04     ` Roman Gushchin
2019-12-10  6:23       ` Bharata B Rao
2019-12-10 18:05         ` Roman Gushchin
2020-01-13  8:47           ` Bharata B Rao
2020-01-13 15:31             ` Roman Gushchin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190905223433.GA5686@tower.DHCP.thefacebook.com \
    --to=guro@fb.com \
    --cc=Kernel-team@fb.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=longman@redhat.com \
    --cc=mhocko@kernel.org \
    --cc=shakeelb@google.com \
    --cc=vdavydov.dev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).