Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1695665 > unrolled thread
| Started by | Vladimir Davydov <vdavydov.dev@gmail.com> |
|---|---|
| First post | 2017-07-25 14:10 +0200 |
| Last post | 2017-07-27 16:50 +0200 |
| Articles | 8 — 4 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH] mm, memcg: reset low limit during memcg offlining Vladimir Davydov <vdavydov.dev@gmail.com> - 2017-07-25 14:10 +0200
Re: [PATCH] mm, memcg: reset low limit during memcg offlining Michal Hocko <mhocko@kernel.org> - 2017-07-25 14:50 +0200
Re: [PATCH] mm, memcg: reset low limit during memcg offlining Vladimir Davydov <vdavydov.dev@gmail.com> - 2017-07-26 10:40 +0200
Re: [PATCH] mm, memcg: reset low limit during memcg offlining Tejun Heo <tj@kernel.org> - 2017-07-26 14:10 +0200
Re: [PATCH 2/2] cgroup: revert fa06235b8eb0 ("cgroup: reset css on destruction") Tejun Heo <tj@kernel.org> - 2017-07-27 16:00 +0200
Re: [PATCH 1/2] mm, memcg: reset memory.low during memcg offlining Johannes Weiner <hannes@cmpxchg.org> - 2017-07-27 16:40 +0200
Re: [PATCH 2/2] cgroup: revert fa06235b8eb0 ("cgroup: reset css on destruction") Johannes Weiner <hannes@cmpxchg.org> - 2017-07-27 16:40 +0200
Re: [PATCH 1/2] mm, memcg: reset memory.low during memcg offlining Michal Hocko <mhocko@kernel.org> - 2017-07-27 16:50 +0200
| From | Vladimir Davydov <vdavydov.dev@gmail.com> |
|---|---|
| Date | 2017-07-25 14:10 +0200 |
| Subject | Re: [PATCH] mm, memcg: reset low limit during memcg offlining |
| Message-ID | <u76P0-2BR-19@gated-at.bofh.it> |
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@fb.com> > Cc: Tejun Heo <tj@kernel.org> > Cc: Johannes Weiner <hannes@cmpxchg.org> > Cc: Michal Hocko <mhocko@kernel.org> > Cc: Vladimir Davydov <vdavydov.dev@gmail.com> > Cc: kernel-team@fb.com > Cc: cgroups@vger.kernel.org > Cc: linux-mm@kvack.org > Cc: linux-kernel@vger.kernel.org > --- > 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().
[toc] | [next] | [standalone]
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2017-07-25 14:50 +0200 |
| Message-ID | <u77rH-2RA-7@gated-at.bofh.it> |
| In reply to | #1695665 |
On Tue 25-07-17 13:31:13, Roman Gushchin wrote: > 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@fb.com> > > > Cc: Tejun Heo <tj@kernel.org> > > > Cc: Johannes Weiner <hannes@cmpxchg.org> > > > Cc: Michal Hocko <mhocko@kernel.org> > > > Cc: Vladimir Davydov <vdavydov.dev@gmail.com> > > > Cc: kernel-team@fb.com > > > Cc: cgroups@vger.kernel.org > > > Cc: linux-mm@kvack.org > > > Cc: linux-kernel@vger.kernel.org > > > --- > > > 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? Well, originally I wanted to suggest the same but then I asked the very same question and couldn't answer it myself. memcg_offline_kmem feels much more generic. > 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. yes, that is my understanding as well. > 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). and the writeback path was exactly the one that triggered my suspicious... -- Michal Hocko SUSE Labs
[toc] | [prev] | [next] | [standalone]
| From | Vladimir Davydov <vdavydov.dev@gmail.com> |
|---|---|
| Date | 2017-07-26 10:40 +0200 |
| Message-ID | <u7q1j-6pF-9@gated-at.bofh.it> |
| In reply to | #1695665 |
On Tue, Jul 25, 2017 at 01:31:13PM +0100, Roman Gushchin wrote: > 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@fb.com> > > > Cc: Tejun Heo <tj@kernel.org> > > > Cc: Johannes Weiner <hannes@cmpxchg.org> > > > Cc: Michal Hocko <mhocko@kernel.org> > > > Cc: Vladimir Davydov <vdavydov.dev@gmail.com> > > > Cc: kernel-team@fb.com > > > Cc: cgroups@vger.kernel.org > > > Cc: linux-mm@kvack.org > > > Cc: linux-kernel@vger.kernel.org > > > --- > > > 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. But that's exactly what cgroup offline is: deletion of a cgroup as if it never existed. The fact that we leave the zombie dangling until all pages charged to the cgroup are gone is an implementation detail. IIRC we would "reparent" those charges and delete the mem_cgroup right away if it were not inherently racy. > 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). The user can't tweak limits of an offline cgroup, because the cgroup directory no longer exist. So IMHO resetting all limits is reasonable. If you want to keep the cgroup limits effective, you shouldn't have deleted it in the first place, I suppose. You might also want to check out this: http://www.spinics.net/lists/linux-mm/msg102995.html > > 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().
[toc] | [prev] | [next] | [standalone]
| From | Tejun Heo <tj@kernel.org> |
|---|---|
| Date | 2017-07-26 14:10 +0200 |
| Message-ID | <u7tix-7n-7@gated-at.bofh.it> |
| In reply to | #1696884 |
Hello, Vladimir. On Wed, Jul 26, 2017 at 11:30:17AM +0300, Vladimir Davydov wrote: > > As I understand, css_reset() callback is intended to _completely_ disable all > > limits, as if there were no cgroup at all. > > But that's exactly what cgroup offline is: deletion of a cgroup as if it > never existed. The fact that we leave the zombie dangling until all > pages charged to the cgroup are gone is an implementation detail. IIRC > we would "reparent" those charges and delete the mem_cgroup right away > if it were not inherently racy. That may be true for memcg but not in general. Think about writeback IOs servicing dirty pages of a removed cgroup. Removing a cgroup shouldn't grant it more resources than when it was alive and changing the membership to the parent will break that. For memcg, they seem the same just because no new major consumption can be generated after removal. > The user can't tweak limits of an offline cgroup, because the cgroup > directory no longer exist. So IMHO resetting all limits is reasonable. > If you want to keep the cgroup limits effective, you shouldn't have > deleted it in the first place, I suppose. I don't think that's the direction we wanna go. Granting more resources on removal is surprising. Thanks. -- tejun
[toc] | [prev] | [next] | [standalone]
| From | Tejun Heo <tj@kernel.org> |
|---|---|
| Date | 2017-07-27 16:00 +0200 |
| Subject | Re: [PATCH 2/2] cgroup: revert fa06235b8eb0 ("cgroup: reset css on destruction") |
| Message-ID | <u7Ruy-6NU-11@gated-at.bofh.it> |
| In reply to | #1696884 |
On Thu, Jul 27, 2017 at 02:04:28PM +0100, Roman Gushchin wrote:
> Commit fa06235b8eb0 ("cgroup: reset css on destruction") caused
> css_reset callback to be called from the offlining path. Although
> it solves the problem mentioned in the commit description
> ("For instance, memory cgroup needs to reset memory.low, otherwise
> pages charged to a dead cgroup might never get reclaimed."),
> generally speaking, it's not correct.
>
> An offline cgroup can still be a resource domain, and we shouldn't
> grant it more resources than it had before deletion.
>
> For instance, if an offline memory cgroup has dirty pages, we should
> still imply i/o limits during writeback.
>
> The css_reset callback is designed to return the cgroup state
> into the original state, that means reset all limits and counters.
> It's spomething different from the offlining, and we shouldn't use
> it from the offlining path. Instead, we should adjust necessary
> settings from the per-controller css_offline callbacks (e.g. reset
> memory.low).
>
> Signed-off-by: Roman Gushchin <guro@fb.com>
> Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
> Cc: Tejun Heo <tj@kernel.org>
> Cc: Johannes Weiner <hannes@cmpxchg.org>
> Cc: Michal Hocko <mhocko@kernel.org>
> Cc: kernel-team@fb.com
> Cc: cgroups@vger.kernel.org
> Cc: linux-mm@kvack.org
> Cc: linux-kernel@vger.kernel.org
Acked-by: Tejun Heo <tj@kernel.org>
Please feel free to route with the previous patch through -mm.
Thanks.
--
tejun
[toc] | [prev] | [next] | [standalone]
| From | Johannes Weiner <hannes@cmpxchg.org> |
|---|---|
| Date | 2017-07-27 16:40 +0200 |
| Subject | Re: [PATCH 1/2] mm, memcg: reset memory.low during memcg offlining |
| Message-ID | <u7S7f-7g8-17@gated-at.bofh.it> |
| In reply to | #1696884 |
CC Andrew - can you route these through the -mm tree please?
On Thu, Jul 27, 2017 at 02:04:27PM +0100, Roman Gushchin wrote:
> A removed memory cgroup with a defined memory.low 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.
>
> This problem was fixed earlier by commit fa06235b8eb0
> ("cgroup: reset css on destruction"), but it's not a best way
> to do it, as we can't really reset all limits/counters during
> cgroup offlining.
>
> Signed-off-by: Roman Gushchin <guro@fb.com>
> Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
> Cc: Tejun Heo <tj@kernel.org>
> Cc: Johannes Weiner <hannes@cmpxchg.org>
> Cc: Michal Hocko <mhocko@kernel.org>
> Cc: kernel-team@fb.com
> Cc: cgroups@vger.kernel.org
> Cc: linux-mm@kvack.org
> Cc: linux-kernel@vger.kernel.org
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
[toc] | [prev] | [next] | [standalone]
| From | Johannes Weiner <hannes@cmpxchg.org> |
|---|---|
| Date | 2017-07-27 16:40 +0200 |
| Subject | Re: [PATCH 2/2] cgroup: revert fa06235b8eb0 ("cgroup: reset css on destruction") |
| Message-ID | <u7S7g-7g8-25@gated-at.bofh.it> |
| In reply to | #1696884 |
On Thu, Jul 27, 2017 at 02:04:28PM +0100, Roman Gushchin wrote:
> Commit fa06235b8eb0 ("cgroup: reset css on destruction") caused
> css_reset callback to be called from the offlining path. Although
> it solves the problem mentioned in the commit description
> ("For instance, memory cgroup needs to reset memory.low, otherwise
> pages charged to a dead cgroup might never get reclaimed."),
> generally speaking, it's not correct.
>
> An offline cgroup can still be a resource domain, and we shouldn't
> grant it more resources than it had before deletion.
>
> For instance, if an offline memory cgroup has dirty pages, we should
> still imply i/o limits during writeback.
>
> The css_reset callback is designed to return the cgroup state
> into the original state, that means reset all limits and counters.
> It's spomething different from the offlining, and we shouldn't use
> it from the offlining path. Instead, we should adjust necessary
> settings from the per-controller css_offline callbacks (e.g. reset
> memory.low).
>
> Signed-off-by: Roman Gushchin <guro@fb.com>
> Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
> Cc: Tejun Heo <tj@kernel.org>
> Cc: Johannes Weiner <hannes@cmpxchg.org>
> Cc: Michal Hocko <mhocko@kernel.org>
> Cc: kernel-team@fb.com
> Cc: cgroups@vger.kernel.org
> Cc: linux-mm@kvack.org
> Cc: linux-kernel@vger.kernel.org
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
[toc] | [prev] | [next] | [standalone]
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2017-07-27 16:50 +0200 |
| Subject | Re: [PATCH 1/2] mm, memcg: reset memory.low during memcg offlining |
| Message-ID | <u7SgW-7jy-9@gated-at.bofh.it> |
| In reply to | #1696884 |
On Thu 27-07-17 14:04:27, Roman Gushchin wrote:
> A removed memory cgroup with a defined memory.low 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.
>
> This problem was fixed earlier by commit fa06235b8eb0
> ("cgroup: reset css on destruction"), but it's not a best way
> to do it, as we can't really reset all limits/counters during
> cgroup offlining.
>
> Signed-off-by: Roman Gushchin <guro@fb.com>
> Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
> Cc: Tejun Heo <tj@kernel.org>
> Cc: Johannes Weiner <hannes@cmpxchg.org>
> Cc: Michal Hocko <mhocko@kernel.org>
> Cc: kernel-team@fb.com
> Cc: cgroups@vger.kernel.org
> Cc: linux-mm@kvack.org
> Cc: linux-kernel@vger.kernel.org
my ack for this patch still holds.
Acked-by: Michal Hocko <mhocko@suse.com>
> ---
> mm/memcontrol.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index d61133e6af99..7b24210596ea 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);
>
> --
> 2.13.3
--
Michal Hocko
SUSE Labs
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web