From: Roman Gushchin <guro@fb.com>
To: Muchun Song <songmuchun@bytedance.com>
Cc: <viro@zeniv.linux.org.uk>, <jack@suse.cz>, <amir73il@gmail.com>,
<ast@kernel.org>, <daniel@iogearbox.net>, <andrii@kernel.org>,
<kafai@fb.com>, <songliubraving@fb.com>, <yhs@fb.com>,
<john.fastabend@gmail.com>, <kpsingh@kernel.org>,
<mingo@redhat.com>, <peterz@infradead.org>,
<juri.lelli@redhat.com>, <vincent.guittot@linaro.org>,
<dietmar.eggemann@arm.com>, <rostedt@goodmis.org>,
<bsegall@google.com>, <mgorman@suse.de>, <bristot@redhat.com>,
<hannes@cmpxchg.org>, <mhocko@kernel.org>,
<vdavydov.dev@gmail.com>, <akpm@linux-foundation.org>,
<shakeelb@google.com>, <alex.shi@linux.alibaba.com>,
<alexander.h.duyck@linux.intel.com>, <chris@chrisdown.name>,
<richard.weiyang@gmail.com>, <vbabka@suse.cz>,
<mathieu.desnoyers@efficios.com>, <posk@google.com>,
<jannh@google.com>, <iamjoonsoo.kim@lge.com>,
<daniel.vetter@ffwll.ch>, <longman@redhat.com>,
<walken@google.com>, <christian.brauner@ubuntu.com>,
<ebiederm@xmission.com>, <keescook@chromium.org>,
<krisman@collabora.com>, <esyr@redhat.com>, <surenb@google.com>,
<elver@google.com>, <linux-fsdevel@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
<bpf@vger.kernel.org>, <cgroups@vger.kernel.org>,
<linux-mm@kvack.org>, <duanxiongchun@bytedance.com>
Subject: Re: [PATCH 4/5] mm: memcontrol: move remote memcg charging APIs to CONFIG_MEMCG_KMEM
Date: Mon, 1 Mar 2021 17:15:36 -0800 [thread overview]
Message-ID: <YD2RuPzikjPnI82h@carbon.dhcp.thefacebook.com> (raw)
In-Reply-To: <20210301062227.59292-5-songmuchun@bytedance.com>
On Mon, Mar 01, 2021 at 02:22:26PM +0800, Muchun Song wrote:
> The remote memcg charing APIs is a mechanism to charge kernel memory
> to a given memcg. So we can move the infrastructure to the scope of
> the CONFIG_MEMCG_KMEM.
This is not a good idea, because there is nothing kmem-specific
in the idea of remote charging, and we definitely will see cases
when user memory is charged to the process different from the current.
>
> As a bonus, on !CONFIG_MEMCG_KMEM build some functions and variables
> can be compiled out.
>
> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
> ---
> include/linux/sched.h | 2 ++
> include/linux/sched/mm.h | 2 +-
> kernel/fork.c | 2 +-
> mm/memcontrol.c | 4 ++++
> 4 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index ee46f5cab95b..c2d488eddf85 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -1314,7 +1314,9 @@ struct task_struct {
>
> /* Number of pages to reclaim on returning to userland: */
> unsigned int memcg_nr_pages_over_high;
> +#endif
>
> +#ifdef CONFIG_MEMCG_KMEM
> /* Used by memcontrol for targeted memcg charge: */
> struct mem_cgroup *active_memcg;
> #endif
> diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h
> index 1ae08b8462a4..64a72975270e 100644
> --- a/include/linux/sched/mm.h
> +++ b/include/linux/sched/mm.h
> @@ -294,7 +294,7 @@ static inline void memalloc_nocma_restore(unsigned int flags)
> }
> #endif
>
> -#ifdef CONFIG_MEMCG
> +#ifdef CONFIG_MEMCG_KMEM
> DECLARE_PER_CPU(struct mem_cgroup *, int_active_memcg);
> /**
> * set_active_memcg - Starts the remote memcg charging scope.
> diff --git a/kernel/fork.c b/kernel/fork.c
> index d66cd1014211..d66718bc82d5 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -942,7 +942,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig, int node)
> tsk->use_memdelay = 0;
> #endif
>
> -#ifdef CONFIG_MEMCG
> +#ifdef CONFIG_MEMCG_KMEM
> tsk->active_memcg = NULL;
> #endif
> return tsk;
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 39cb8c5bf8b2..092dc4588b43 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -76,8 +76,10 @@ EXPORT_SYMBOL(memory_cgrp_subsys);
>
> struct mem_cgroup *root_mem_cgroup __read_mostly;
>
> +#ifdef CONFIG_MEMCG_KMEM
> /* Active memory cgroup to use from an interrupt context */
> DEFINE_PER_CPU(struct mem_cgroup *, int_active_memcg);
> +#endif
>
> /* Socket memory accounting disabled? */
> static bool cgroup_memory_nosocket;
> @@ -1054,6 +1056,7 @@ struct mem_cgroup *get_mem_cgroup_from_mm(struct mm_struct *mm)
> }
> EXPORT_SYMBOL(get_mem_cgroup_from_mm);
>
> +#ifdef CONFIG_MEMCG_KMEM
> static __always_inline struct mem_cgroup *active_memcg(void)
> {
> if (in_interrupt())
> @@ -1074,6 +1077,7 @@ static __always_inline bool memcg_kmem_bypass(void)
>
> return false;
> }
> +#endif
>
> /**
> * mem_cgroup_iter - iterate over memory cgroup hierarchy
> --
> 2.11.0
>
next prev parent reply other threads:[~2021-03-02 1:16 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-01 6:22 [PATCH 0/5] Use obj_cgroup APIs to change kmem pages Muchun Song
2021-03-01 6:22 ` [PATCH 1/5] mm: memcontrol: introduce obj_cgroup_{un}charge_page Muchun Song
2021-03-01 6:22 ` [PATCH 2/5] mm: memcontrol: make page_memcg{_rcu} only applicable for non-kmem page Muchun Song
2021-03-01 18:11 ` Shakeel Butt
2021-03-01 19:09 ` Johannes Weiner
2021-03-02 3:49 ` [External] " Muchun Song
2021-03-02 3:03 ` Muchun Song
2021-03-02 3:35 ` Shakeel Butt
2021-03-02 3:51 ` Muchun Song
2021-03-01 6:22 ` [PATCH 3/5] mm: memcontrol: reparent the kmem pages on cgroup removal Muchun Song
2021-03-01 6:22 ` [PATCH 4/5] mm: memcontrol: move remote memcg charging APIs to CONFIG_MEMCG_KMEM Muchun Song
2021-03-02 1:15 ` Roman Gushchin [this message]
2021-03-02 3:43 ` Shakeel Butt
2021-03-02 3:58 ` Roman Gushchin
2021-03-02 4:12 ` [External] " Muchun Song
2021-03-01 6:22 ` [PATCH 5/5] mm: memcontrol: use object cgroup for remote memory cgroup charging Muchun Song
2021-03-02 1:29 ` Roman Gushchin
2021-03-02 4:11 ` [External] " Muchun Song
2021-03-02 1:12 ` [PATCH 0/5] Use obj_cgroup APIs to change kmem pages Roman Gushchin
2021-03-02 2:50 ` [External] " Muchun Song
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=YD2RuPzikjPnI82h@carbon.dhcp.thefacebook.com \
--to=guro@fb.com \
--cc=akpm@linux-foundation.org \
--cc=alex.shi@linux.alibaba.com \
--cc=alexander.h.duyck@linux.intel.com \
--cc=amir73il@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=cgroups@vger.kernel.org \
--cc=chris@chrisdown.name \
--cc=christian.brauner@ubuntu.com \
--cc=daniel.vetter@ffwll.ch \
--cc=daniel@iogearbox.net \
--cc=dietmar.eggemann@arm.com \
--cc=duanxiongchun@bytedance.com \
--cc=ebiederm@xmission.com \
--cc=elver@google.com \
--cc=esyr@redhat.com \
--cc=hannes@cmpxchg.org \
--cc=iamjoonsoo.kim@lge.com \
--cc=jack@suse.cz \
--cc=jannh@google.com \
--cc=john.fastabend@gmail.com \
--cc=juri.lelli@redhat.com \
--cc=kafai@fb.com \
--cc=keescook@chromium.org \
--cc=kpsingh@kernel.org \
--cc=krisman@collabora.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=longman@redhat.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mgorman@suse.de \
--cc=mhocko@kernel.org \
--cc=mingo@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=posk@google.com \
--cc=richard.weiyang@gmail.com \
--cc=rostedt@goodmis.org \
--cc=shakeelb@google.com \
--cc=songliubraving@fb.com \
--cc=songmuchun@bytedance.com \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
--cc=vdavydov.dev@gmail.com \
--cc=vincent.guittot@linaro.org \
--cc=viro@zeniv.linux.org.uk \
--cc=walken@google.com \
--cc=yhs@fb.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