[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190124002359.GB21563@castle.DHCP.thefacebook.com>
Date: Thu, 24 Jan 2019 00:24:05 +0000
From: Roman Gushchin <guro@...com>
To: Chris Down <chris@...isdown.name>
CC: Andrew Morton <akpm@...ux-foundation.org>,
Johannes Weiner <hannes@...xchg.org>,
Michal Hocko <mhocko@...nel.org>, Tejun Heo <tj@...nel.org>,
Dennis Zhou <dennis@...nel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"cgroups@...r.kernel.org" <cgroups@...r.kernel.org>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
Kernel Team <Kernel-team@...com>
Subject: Re: [PATCH 2/2] mm: Consider subtrees in memory.events
On Wed, Jan 23, 2019 at 05:31:44PM -0500, Chris Down wrote:
> memory.stat and other files already consider subtrees in their output,
> and we should too in order to not present an inconsistent interface.
>
> The current situation is fairly confusing, because people interacting
> with cgroups expect hierarchical behaviour in the vein of memory.stat,
> cgroup.events, and other files. For example, this causes confusion when
> debugging reclaim events under low, as currently these always read "0"
> at non-leaf memcg nodes, which frequently causes people to misdiagnose
> breach behaviour. The same confusion applies to other counters in this
> file when debugging issues.
>
> Aggregation is done at write time instead of at read-time since these
> counters aren't hot (unlike memory.stat which is per-page, so it does it
> at read time), and it makes sense to bundle this with the file
> notifications.
I agree with the consistency argument (matching cgroup.events, ...),
and it's definitely looks better for oom* events, but at the same time it feels
like a API break.
Just for example, let's say you have a delegated sub-tree with memory.max
set. Earlier, getting memory.high/max event meant that the whole sub-tree
is tight on memory, and, for example, led to shutdown of some parts of the tree.
After your change, it might mean that some sub-cgroup has reached its limit,
and probably doesn't matter on the top level.
Maybe it's still ok, but we definitely need to document it better. It feels
bad that different versions of the kernel will handle it differently, so
the userspace has to workaround it to actually use these events.
Also, please, make sure that it doesn't break memcg kselftests.
>
> After this patch, events are propagated up the hierarchy:
>
> [root@...t ~]# cat /sys/fs/cgroup/system.slice/memory.events
> low 0
> high 0
> max 0
> oom 0
> oom_kill 0
> [root@...t ~]# systemd-run -p MemoryMax=1 true
> Running as unit: run-r251162a189fb4562b9dabfdc9b0422f5.service
> [root@...t ~]# cat /sys/fs/cgroup/system.slice/memory.events
> low 0
> high 0
> max 7
> oom 1
> oom_kill 1
>
> Signed-off-by: Chris Down <chris@...isdown.name>
> Acked-by: Johannes Weiner <hannes@...xchg.org>
> To: Andrew Morton <akpm@...ux-foundation.org>
s/To/CC
> Cc: Michal Hocko <mhocko@...nel.org>
> Cc: Tejun Heo <tj@...nel.org>
> Cc: Roman Gushchin <guro@...com>
> Cc: Dennis Zhou <dennis@...nel.org>
> Cc: linux-kernel@...r.kernel.org
> Cc: cgroups@...r.kernel.org
> Cc: linux-mm@...ck.org
> Cc: kernel-team@...com
> ---
> include/linux/memcontrol.h | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
> index 380a212a8c52..5428b372def4 100644
> --- a/include/linux/memcontrol.h
> +++ b/include/linux/memcontrol.h
> @@ -769,8 +769,10 @@ static inline void count_memcg_event_mm(struct mm_struct *mm,
> static inline void memcg_memory_event(struct mem_cgroup *memcg,
> enum memcg_memory_event event)
> {
> - atomic_long_inc(&memcg->memory_events[event]);
> - cgroup_file_notify(&memcg->events_file);
> + do {
> + atomic_long_inc(&memcg->memory_events[event]);
> + cgroup_file_notify(&memcg->events_file);
> + } while ((memcg = parent_mem_cgroup(memcg)));
We don't have memory.events file for the root cgroup, so we can stop earlier.
Thanks!
Powered by blists - more mailing lists