linux-kernel.vger.kernel.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>,
	<akpm@linux-foundation.org>, <shakeelb@google.com>,
	<vdavydov.dev@gmail.com>, <linux-kernel@vger.kernel.org>,
	<linux-mm@kvack.org>, <duanxiongchun@bytedance.com>,
	<fam.zheng@bytedance.com>
Subject: Re: [PATCH 1/7] mm: memcontrol: fix page charging in page replacement
Date: Tue, 13 Apr 2021 10:45:59 -0700	[thread overview]
Message-ID: <YHXY123MtiWc5wPW@carbon.dhcp.thefacebook.com> (raw)
In-Reply-To: <20210413065153.63431-2-songmuchun@bytedance.com>

On Tue, Apr 13, 2021 at 02:51:47PM +0800, Muchun Song wrote:
> The pages aren't accounted at the root level, so do not charge the page
> to the root memcg in page replacement. Although we do not display the
> value (mem_cgroup_usage) so there shouldn't be any actual problem, but
> there is a WARN_ON_ONCE in the page_counter_cancel(). Who knows if it
> will trigger? So it is better to fix it.
> 
> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
> Acked-by: Johannes Weiner <hannes@cmpxchg.org>
> Reviewed-by: Shakeel Butt <shakeelb@google.com>

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

Thanks!
> ---
>  mm/memcontrol.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 64ada9e650a5..f229de925aa5 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -6806,9 +6806,11 @@ void mem_cgroup_migrate(struct page *oldpage, struct page *newpage)
>  	/* Force-charge the new page. The old one will be freed soon */
>  	nr_pages = thp_nr_pages(newpage);
>  
> -	page_counter_charge(&memcg->memory, nr_pages);
> -	if (do_memsw_account())
> -		page_counter_charge(&memcg->memsw, nr_pages);
> +	if (!mem_cgroup_is_root(memcg)) {
> +		page_counter_charge(&memcg->memory, nr_pages);
> +		if (do_memsw_account())
> +			page_counter_charge(&memcg->memsw, nr_pages);
> +	}
>  
>  	css_get(&memcg->css);
>  	commit_charge(newpage, memcg);
> -- 
> 2.11.0
> 

  reply	other threads:[~2021-04-13 17:46 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-13  6:51 [PATCH 0/7] memcontrol code cleanup and simplification Muchun Song
2021-04-13  6:51 ` [PATCH 1/7] mm: memcontrol: fix page charging in page replacement Muchun Song
2021-04-13 17:45   ` Roman Gushchin [this message]
2021-04-14  9:20   ` Michal Hocko
2021-04-13  6:51 ` [PATCH 2/7] mm: memcontrol: bail out early when !mm in get_mem_cgroup_from_mm Muchun Song
2021-04-13 17:47   ` Roman Gushchin
2021-04-14  9:24   ` Michal Hocko
2021-04-14 10:04     ` [External] " Muchun Song
2021-04-14 10:15       ` Michal Hocko
2021-04-15  3:13         ` Muchun Song
2021-04-15  7:09           ` Michal Hocko
2021-04-13  6:51 ` [PATCH 3/7] mm: memcontrol: remove the pgdata parameter of mem_cgroup_page_lruvec Muchun Song
2021-04-13 13:12   ` Shakeel Butt
2021-04-13 17:48   ` Roman Gushchin
2021-04-14  9:27   ` Michal Hocko
2021-04-13  6:51 ` [PATCH 4/7] mm: memcontrol: simplify lruvec_holds_page_lru_lock Muchun Song
2021-04-13 13:28   ` Shakeel Butt
2021-04-13 17:57   ` Roman Gushchin
2021-04-14  9:44   ` Michal Hocko
2021-04-14 10:00     ` [External] " Muchun Song
2021-04-14 17:49       ` Johannes Weiner
2021-04-15  7:08         ` Michal Hocko
2021-04-15 10:01         ` Muchun Song
2021-04-13  6:51 ` [PATCH 5/7] mm: memcontrol: simplify the logic of objcg pinning memcg Muchun Song
2021-04-13 14:16   ` Shakeel Butt
2021-04-13 17:51   ` Roman Gushchin
2021-04-13  6:51 ` [PATCH 6/7] mm: memcontrol: move obj_cgroup_uncharge_pages() out of css_set_lock Muchun Song
2021-04-13 14:18   ` Shakeel Butt
2021-04-13 17:54   ` Roman Gushchin
2021-04-13 18:03   ` Johannes Weiner
2021-04-13  6:51 ` [PATCH 7/7] mm: vmscan: remove noinline_for_stack Muchun Song
2021-04-14  9:46   ` Michal Hocko

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=YHXY123MtiWc5wPW@carbon.dhcp.thefacebook.com \
    --to=guro@fb.com \
    --cc=akpm@linux-foundation.org \
    --cc=duanxiongchun@bytedance.com \
    --cc=fam.zheng@bytedance.com \
    --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).