linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Roman Gushchin <guro@fb.com>
To: Muchun Song <songmuchun@bytedance.com>
Cc: <hannes@cmpxchg.org>, <mhocko@kernel.org>,
	<vdavydov.dev@gmail.com>, <akpm@linux-foundation.org>,
	<shakeelb@google.com>, <cgroups@vger.kernel.org>,
	<linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mm: memcontrol: fix get_active_memcg return value
Date: Tue, 23 Feb 2021 07:35:49 -0800	[thread overview]
Message-ID: <YDUg1TJm5NBvLbQS@carbon.lan> (raw)
In-Reply-To: <20210223091101.42150-1-songmuchun@bytedance.com>

On Tue, Feb 23, 2021 at 05:11:01PM +0800, Muchun Song wrote:
> We use a global percpu int_active_memcg variable to store the remote
> memcg when we are in the interrupt context. But get_active_memcg always
> return the current->active_memcg or root_mem_cgroup. The remote memcg
> (set in the interrupt context) is ignored. This is not what we want.
> So fix it.
> 
> Fixes: 37d5985c003d ("mm: kmem: prepare remote memcg charging infra for interrupt contexts")
> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
> ---
>  mm/memcontrol.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index be6bc5044150..bbe25655f7eb 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -1061,13 +1061,9 @@ static __always_inline struct mem_cgroup *get_active_memcg(void)
>  
>  	rcu_read_lock();
>  	memcg = active_memcg();
> -	if (memcg) {
> -		/* current->active_memcg must hold a ref. */
> -		if (WARN_ON_ONCE(!css_tryget(&memcg->css)))
> -			memcg = root_mem_cgroup;
> -		else
> -			memcg = current->active_memcg;
> -	}
> +	/* remote memcg must hold a ref. */
> +	if (memcg && WARN_ON_ONCE(!css_tryget(&memcg->css)))
> +		memcg = root_mem_cgroup;

Ouch, this is a good one!

Reviewed-by: Roman Gushchin <guro@fb.com>

Thank you!


      parent reply	other threads:[~2021-02-23 15:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-23  9:11 [PATCH] mm: memcontrol: fix get_active_memcg return value Muchun Song
2021-02-23 15:18 ` Shakeel Butt
2021-02-23 15:35 ` Roman Gushchin [this message]

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=YDUg1TJm5NBvLbQS@carbon.lan \
    --to=guro@fb.com \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=shakeelb@google.com \
    --cc=songmuchun@bytedance.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).