From: Michal Hocko <mhocko@kernel.org>
To: Roman Gushchin <guro@fb.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, Johannes Weiner <hannes@cmpxchg.org>,
linux-kernel@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH 2/2] mm: memcontrol: flush percpu slab vmstats on kmem offlining
Date: Wed, 14 Aug 2019 13:32:42 +0200 [thread overview]
Message-ID: <20190814113242.GV17933@dhcp22.suse.cz> (raw)
In-Reply-To: <20190812222911.2364802-3-guro@fb.com>
On Mon 12-08-19 15:29:11, Roman Gushchin wrote:
> I've noticed that the "slab" value in memory.stat is sometimes 0,
> even if some children memory cgroups have a non-zero "slab" value.
> The following investigation showed that this is the result
> of the kmem_cache reparenting in combination with the per-cpu
> batching of slab vmstats.
>
> At the offlining some vmstat value may leave in the percpu cache,
> not being propagated upwards by the cgroup hierarchy. It means
> that stats on ancestor levels are lower than actual. Later when
> slab pages are released, the precise number of pages is substracted
> on the parent level, making the value negative. We don't show negative
> values, 0 is printed instead.
So the difference with other counters is that slab ones are reparented
and that's why we have treat them specially? I guess that is what the
comment in the code suggest but being explicit in the changelog would be
nice.
[...]
> -static void memcg_flush_percpu_vmstats(struct mem_cgroup *memcg)
> +static void memcg_flush_percpu_vmstats(struct mem_cgroup *memcg, bool slab_only)
> {
> unsigned long stat[MEMCG_NR_STAT];
> struct mem_cgroup *mi;
> int node, cpu, i;
> + int min_idx, max_idx;
>
> - for (i = 0; i < MEMCG_NR_STAT; i++)
> + if (slab_only) {
> + min_idx = NR_SLAB_RECLAIMABLE;
> + max_idx = NR_SLAB_UNRECLAIMABLE;
> + } else {
> + min_idx = 0;
> + max_idx = MEMCG_NR_STAT;
> + }
This is just ugly has hell! I really detest how this implicitly makes
counters value very special without any note in the node_stat_item
definition. Is it such a big deal to have a per counter flush and do
the loop over all counters resp. specific counters around it so much
worse? This should be really a slow path to safe few instructions or
cache misses, no?
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2019-08-14 11:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-12 22:29 [PATCH 0/2] flush percpu vmstats Roman Gushchin
2019-08-12 22:29 ` [PATCH 1/2] mm: memcontrol: flush percpu vmstats before releasing memcg Roman Gushchin
2019-08-13 21:27 ` Andrew Morton
2019-08-13 21:46 ` Roman Gushchin
2020-09-01 15:32 ` Yang Shi
2019-08-14 11:26 ` Michal Hocko
2019-08-12 22:29 ` [PATCH 2/2] mm: memcontrol: flush percpu slab vmstats on kmem offlining Roman Gushchin
2019-08-14 11:32 ` Michal Hocko [this message]
2019-08-14 21:54 ` Roman Gushchin
2019-08-15 8:35 ` 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=20190814113242.GV17933@dhcp22.suse.cz \
--to=mhocko@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=guro@fb.com \
--cc=hannes@cmpxchg.org \
--cc=kernel-team@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/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).