Re: [PATCH] mm, memcg: reset low limit during memcg offlining
From: Roman Gushchin
Date: Tue Jul 25 2017 - 08:31:47 EST
On Tue, Jul 25, 2017 at 03:05:37PM +0300, Vladimir Davydov wrote:
> On Tue, Jul 25, 2017 at 12:40:47PM +0100, Roman Gushchin wrote:
> > A removed memory cgroup with a defined low limit and some belonging
> > pagecache has very low chances to be freed.
> >
> > If a cgroup has been removed, there is likely no memory pressure inside
> > the cgroup, and the pagecache is protected from the external pressure
> > by the defined low limit. The cgroup will be freed only after
> > the reclaim of all belonging pages. And it will not happen until
> > there are any reclaimable memory in the system. That means,
> > there is a good chance, that a cold pagecache will reside
> > in the memory for an undefined amount of time, wasting
> > system resources.
> >
> > Fix this issue by zeroing memcg->low during memcg offlining.
> >
> > Signed-off-by: Roman Gushchin <guro@xxxxxx>
> > Cc: Tejun Heo <tj@xxxxxxxxxx>
> > Cc: Johannes Weiner <hannes@xxxxxxxxxxx>
> > Cc: Michal Hocko <mhocko@xxxxxxxxxx>
> > Cc: Vladimir Davydov <vdavydov.dev@xxxxxxxxx>
> > Cc: kernel-team@xxxxxx
> > Cc: cgroups@xxxxxxxxxxxxxxx
> > Cc: linux-mm@xxxxxxxxx
> > Cc: linux-kernel@xxxxxxxxxxxxxxx
> > ---
> > mm/memcontrol.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> > index aed11b2d0251..2aa204b8f9fd 100644
> > --- a/mm/memcontrol.c
> > +++ b/mm/memcontrol.c
> > @@ -4300,6 +4300,8 @@ static void mem_cgroup_css_offline(struct cgroup_subsys_state *css)
> > }
> > spin_unlock(&memcg->event_list_lock);
> >
> > + memcg->low = 0;
> > +
> > memcg_offline_kmem(memcg);
> > wb_memcg_offline(memcg);
> >
>
> We already have that - see mem_cgroup_css_reset().
Hm, I see...
But are you sure, that calling mem_cgroup_css_reset() from offlining path
is always a good idea?
As I understand, css_reset() callback is intended to _completely_ disable all
limits, as if there were no cgroup at all. And it's main purpose to be called
when controllers are detached from the hierarhy.
Offlining is different: some limits make perfect sence after offlining
(e.g. we want to limit the writeback speed), and other might be tweaked
(e.g. we can set soft limit to prioritize reclaiming of abandoned cgroups).
So, I'd prefer to move this code to the offlining callback,
and not to call css_reset.
But, anyway, thanks for pointing at the mem_cgroup_css_reset().
Roman