Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-11-20 Thread Michal Koutný
Hi. On Tue, Nov 10, 2020 at 07:11:28AM -0800, Shakeel Butt wrote: > > The problem is that cgroup_subsys_on_dfl(memory_cgrp_subsys)'s return value > > can change at any particular moment. The switch can happen only when singular (i.e. root-only) hierarchy exists. (Or it could if rebind_subsystems

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-11-10 Thread Roman Gushchin
On Tue, Nov 10, 2020 at 07:11:28AM -0800, Shakeel Butt wrote: > On Mon, Nov 9, 2020 at 5:28 PM Roman Gushchin wrote: > > > > On Fri, Oct 23, 2020 at 12:30:53PM -0400, Johannes Weiner wrote: > > > On Wed, Oct 21, 2020 at 12:33:22PM -0700, Roman Gushchin wrote: > > > > On Tue, Oct 20, 2020 at 02:18:

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-11-10 Thread Shakeel Butt
On Mon, Nov 9, 2020 at 5:28 PM Roman Gushchin wrote: > > On Fri, Oct 23, 2020 at 12:30:53PM -0400, Johannes Weiner wrote: > > On Wed, Oct 21, 2020 at 12:33:22PM -0700, Roman Gushchin wrote: > > > On Tue, Oct 20, 2020 at 02:18:22PM -0400, Johannes Weiner wrote: > > > > On Tue, Oct 20, 2020 at 10:07

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-11-09 Thread Roman Gushchin
On Fri, Oct 23, 2020 at 12:30:53PM -0400, Johannes Weiner wrote: > On Wed, Oct 21, 2020 at 12:33:22PM -0700, Roman Gushchin wrote: > > On Tue, Oct 20, 2020 at 02:18:22PM -0400, Johannes Weiner wrote: > > > On Tue, Oct 20, 2020 at 10:07:17AM -0700, Roman Gushchin wrote: > > > > If we want these coun

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-11-03 Thread Roman Gushchin
On Tue, Nov 03, 2020 at 02:22:21PM +0100, Michal Hocko wrote: > Hi, > I am sorry but I was quite busy at the time this has been discussed. > Now that I got to this thread finally I am wondering whether this > resp. other root cgroup exceptions have any follow up. I'll address a feedback I've got f

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-11-03 Thread Michal Hocko
Hi, I am sorry but I was quite busy at the time this has been discussed. Now that I got to this thread finally I am wondering whether this resp. other root cgroup exceptions have any follow up. I have seen the issue is fixed in Linus tree by 8de15e920dc8 ("mm: memcg: link page counters to root if

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-23 Thread Johannes Weiner
On Wed, Oct 21, 2020 at 12:33:22PM -0700, Roman Gushchin wrote: > On Tue, Oct 20, 2020 at 02:18:22PM -0400, Johannes Weiner wrote: > > On Tue, Oct 20, 2020 at 10:07:17AM -0700, Roman Gushchin wrote: > > > If we want these counter to function properly, then we should go into the > > > opposite > >

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-21 Thread Roman Gushchin
On Tue, Oct 20, 2020 at 02:18:22PM -0400, Johannes Weiner wrote: > On Tue, Oct 20, 2020 at 10:07:17AM -0700, Roman Gushchin wrote: > > If we want these counter to function properly, then we should go into the > > opposite > > direction and remove the special handling of the root memory cgroup in m

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-20 Thread Johannes Weiner
On Tue, Oct 20, 2020 at 10:07:17AM -0700, Roman Gushchin wrote: > If we want these counter to function properly, then we should go into the > opposite > direction and remove the special handling of the root memory cgroup in many > places. I suspect this is also by far the most robust solution fr

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-20 Thread Roman Gushchin
On Tue, Oct 20, 2020 at 09:55:38AM -0700, Shakeel Butt wrote: > On Mon, Oct 19, 2020 at 3:28 PM Roman Gushchin wrote: > > > > On Fri, Oct 16, 2020 at 07:15:02PM +0200, Michal Koutny wrote: > > > On Fri, Oct 16, 2020 at 10:53:08AM -0400, Johannes Weiner > > > wrote: > > > > The central try_charge

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-20 Thread Roman Gushchin
On Tue, Oct 20, 2020 at 06:27:14PM +0200, Michal Koutny wrote: > Hi. > > On Mon, Oct 19, 2020 at 03:28:45PM -0700, Roman Gushchin wrote: > > Currently the root memory cgroup is never charged directly, but > > if an ancestor cgroup is charged, the charge is propagated up to the > s/ancestor/descen

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-20 Thread Shakeel Butt
On Mon, Oct 19, 2020 at 3:28 PM Roman Gushchin wrote: > > On Fri, Oct 16, 2020 at 07:15:02PM +0200, Michal Koutny wrote: > > On Fri, Oct 16, 2020 at 10:53:08AM -0400, Johannes Weiner > > wrote: > > > The central try_charge() function charges recursively all the way up > > > to and including the

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-20 Thread Michal Koutný
Hi. On Mon, Oct 19, 2020 at 03:28:45PM -0700, Roman Gushchin wrote: > Currently the root memory cgroup is never charged directly, but > if an ancestor cgroup is charged, the charge is propagated up to the s/ancestor/descendant/ > The root memory cgroup doesn't show the charge to a user, neither

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-20 Thread Richard Palethorpe
Hello Roman, Roman Gushchin writes: > On Fri, Oct 16, 2020 at 07:15:02PM +0200, Michal Koutny wrote: > > From f50ea74d8f118b9121da3754acdde630ddc060a7 Mon Sep 17 00:00:00 2001 > From: Roman Gushchin > Date: Mon, 19 Oct 2020 14:37:35 -0700 > Subject: [PATCH RFC] mm: memcontrol: do not charge the

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-20 Thread Richard Palethorpe
Hello, Richard Palethorpe writes: > Hello Roman, > > Roman Gushchin writes: > >> -page_counter_init(&memcg->memory, NULL); >> -page_counter_init(&memcg->swap, NULL); >> -page_counter_init(&memcg->kmem, NULL); >> -page_counter_init(&memcg->tcpmem,

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-19 Thread Richard Palethorpe
Hello Roman, Roman Gushchin writes: > On Fri, Oct 16, 2020 at 07:15:02PM +0200, Michal Koutny wrote: >> On Fri, Oct 16, 2020 at 10:53:08AM -0400, Johannes Weiner >> wrote: >> > The central try_charge() function charges recursively all the way up >> > to and including the root. >> Except for us

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-19 Thread Roman Gushchin
On Fri, Oct 16, 2020 at 07:15:02PM +0200, Michal Koutny wrote: > On Fri, Oct 16, 2020 at 10:53:08AM -0400, Johannes Weiner > wrote: > > The central try_charge() function charges recursively all the way up > > to and including the root. > Except for use_hiearchy=0 (which is the case here as Richar

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-19 Thread Richard Palethorpe
Hello, Michal Koutný writes: > On Fri, Oct 16, 2020 at 10:53:08AM -0400, Johannes Weiner > wrote: >> The central try_charge() function charges recursively all the way up >> to and including the root. > Except for use_hiearchy=0 (which is the case here as Richard > wrote). The reparenting is he

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-16 Thread Michal Koutný
On Fri, Oct 16, 2020 at 04:05:21PM +0100, Richard Palethorpe wrote: > I'm don't know if that could happen without reparenting. I suppose if > use_hierarchy=1 then actually this patch will result in root being > overcharged, so perhaps it should also check for use_hierarchy? Right, you'd need to d

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-16 Thread Michal Koutný
On Fri, Oct 16, 2020 at 10:53:08AM -0400, Johannes Weiner wrote: > The central try_charge() function charges recursively all the way up > to and including the root. Except for use_hiearchy=0 (which is the case here as Richard wrote). The reparenting is hence somewhat incompatible with new_parent.

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-16 Thread Roman Gushchin
On Fri, Oct 16, 2020 at 10:53:08AM -0400, Johannes Weiner wrote: > On Fri, Oct 16, 2020 at 11:47:02AM +0200, Michal Koutný wrote: > > Hello. > > > > On Wed, Oct 14, 2020 at 08:07:49PM +0100, Richard Palethorpe > > wrote: > > > SLAB objects which outlive their memcg are moved to their parent > >

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-16 Thread Richard Palethorpe
Hello, Richard Palethorpe writes: > Hello Michal, > > Michal Koutný writes: > >> Hello. >> >> On Wed, Oct 14, 2020 at 08:07:49PM +0100, Richard Palethorpe >> wrote: >>> SLAB objects which outlive their memcg are moved to their parent >>> memcg where they may be uncharged. However if they are

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-16 Thread Johannes Weiner
On Fri, Oct 16, 2020 at 11:47:02AM +0200, Michal Koutný wrote: > Hello. > > On Wed, Oct 14, 2020 at 08:07:49PM +0100, Richard Palethorpe > wrote: > > SLAB objects which outlive their memcg are moved to their parent > > memcg where they may be uncharged. However if they are moved to the > > root

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-16 Thread Richard Palethorpe
Hello Michal, Michal Koutný writes: > Hello. > > On Wed, Oct 14, 2020 at 08:07:49PM +0100, Richard Palethorpe > wrote: >> SLAB objects which outlive their memcg are moved to their parent >> memcg where they may be uncharged. However if they are moved to the >> root memcg, uncharging will resul

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-16 Thread Michal Koutný
Hello. On Wed, Oct 14, 2020 at 08:07:49PM +0100, Richard Palethorpe wrote: > SLAB objects which outlive their memcg are moved to their parent > memcg where they may be uncharged. However if they are moved to the > root memcg, uncharging will result in negative page counter values as > root has n

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-15 Thread Richard Palethorpe
Hello Roman, Roman Gushchin writes: > Hi Richard! > >> SLAB objects which outlive their memcg are moved to their parent >> memcg where they may be uncharged. However if they are moved to the >> root memcg, uncharging will result in negative page counter values as >> root has no page counters. >>

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-14 Thread Roman Gushchin
Hi Richard! > SLAB objects which outlive their memcg are moved to their parent > memcg where they may be uncharged. However if they are moved to the > root memcg, uncharging will result in negative page counter values as > root has no page counters. > > To prevent this, we check whether we are ab

[RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-14 Thread Richard Palethorpe
SLAB objects which outlive their memcg are moved to their parent memcg where they may be uncharged. However if they are moved to the root memcg, uncharging will result in negative page counter values as root has no page counters. To prevent this, we check whether we are about to uncharge the root