* [PATCH 1/2] mm: memcontrol: cleanup css_reset callback
@ 2016-03-01 11:13 Vladimir Davydov
2016-03-01 11:13 ` [PATCH 2/2] cgroup: reset css on destruction Vladimir Davydov
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Vladimir Davydov @ 2016-03-01 11:13 UTC (permalink / raw)
To: Andrew Morton
Cc: Tejun Heo, Johannes Weiner, Michal Hocko, cgroups, linux-mm,
linux-kernel
- Do not take memcg_limit_mutex for resetting limits - the cgroup
cannot be altered from userspace anymore, so no need to protect them.
- Use plain page_counter_limit() for resetting ->memory and ->memsw
limits instead of mem_cgrouop_resize_* helpers - we enlarge the
limits, so no need in special handling.
- Reset ->swap and ->tcpmem limits as well.
Signed-off-by: Vladimir Davydov <vdavydov@virtuozzo.com>
---
mm/memcontrol.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index ae8b81c55685..8615b066b642 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4257,9 +4257,11 @@ static void mem_cgroup_css_reset(struct cgroup_subsys_state *css)
{
struct mem_cgroup *memcg = mem_cgroup_from_css(css);
- mem_cgroup_resize_limit(memcg, PAGE_COUNTER_MAX);
- mem_cgroup_resize_memsw_limit(memcg, PAGE_COUNTER_MAX);
- memcg_update_kmem_limit(memcg, PAGE_COUNTER_MAX);
+ page_counter_limit(&memcg->memory, PAGE_COUNTER_MAX);
+ page_counter_limit(&memcg->swap, PAGE_COUNTER_MAX);
+ page_counter_limit(&memcg->memsw, PAGE_COUNTER_MAX);
+ page_counter_limit(&memcg->kmem, PAGE_COUNTER_MAX);
+ page_counter_limit(&memcg->tcpmem, PAGE_COUNTER_MAX);
memcg->low = 0;
memcg->high = PAGE_COUNTER_MAX;
memcg->soft_limit = PAGE_COUNTER_MAX;
--
2.1.4
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] cgroup: reset css on destruction
2016-03-01 11:13 [PATCH 1/2] mm: memcontrol: cleanup css_reset callback Vladimir Davydov
@ 2016-03-01 11:13 ` Vladimir Davydov
2016-03-01 16:30 ` Tejun Heo
2016-03-01 16:04 ` [PATCH 1/2] mm: memcontrol: cleanup css_reset callback Michal Hocko
2016-03-01 19:53 ` Johannes Weiner
2 siblings, 1 reply; 8+ messages in thread
From: Vladimir Davydov @ 2016-03-01 11:13 UTC (permalink / raw)
To: Andrew Morton
Cc: Tejun Heo, Johannes Weiner, Michal Hocko, cgroups, linux-mm,
linux-kernel
An associated css can be around for quite a while after a cgroup
directory has been removed. In general, it makes sense to reset it to
defaults so as not to worry about any remnants. For instance, memory
cgroup needs to reset memory.low, otherwise pages charged to a dead
cgroup might never get reclaimed. There's ->css_reset callback, which
would fit perfectly for the purpose. Currently, it's only called when a
subsystem is disabled in the unified hierarchy and there are other
subsystems dependant on it. Let's call it on css destruction as well.
Suggested-by: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Vladimir Davydov <vdavydov@virtuozzo.com>
---
kernel/cgroup.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index cc40463e7b69..2ef78912c996 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -5138,6 +5138,8 @@ static void kill_css(struct cgroup_subsys_state *css)
* See seq_css() for details.
*/
css_clear_dir(css, NULL);
+ if (css->ss->css_reset)
+ css->ss->css_reset(css);
/*
* Killing would put the base ref, but we need to keep it alive
--
2.1.4
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] mm: memcontrol: cleanup css_reset callback
2016-03-01 11:13 [PATCH 1/2] mm: memcontrol: cleanup css_reset callback Vladimir Davydov
2016-03-01 11:13 ` [PATCH 2/2] cgroup: reset css on destruction Vladimir Davydov
@ 2016-03-01 16:04 ` Michal Hocko
2016-03-01 19:53 ` Johannes Weiner
2 siblings, 0 replies; 8+ messages in thread
From: Michal Hocko @ 2016-03-01 16:04 UTC (permalink / raw)
To: Vladimir Davydov
Cc: Andrew Morton, Tejun Heo, Johannes Weiner, cgroups, linux-mm,
linux-kernel
On Tue 01-03-16 14:13:12, Vladimir Davydov wrote:
> - Do not take memcg_limit_mutex for resetting limits - the cgroup
> cannot be altered from userspace anymore, so no need to protect them.
>
> - Use plain page_counter_limit() for resetting ->memory and ->memsw
> limits instead of mem_cgrouop_resize_* helpers - we enlarge the
> limits, so no need in special handling.
>
> - Reset ->swap and ->tcpmem limits as well.
>
> Signed-off-by: Vladimir Davydov <vdavydov@virtuozzo.com>
Acked-by: Michal Hocko <mhocko@suse.com>
> ---
> mm/memcontrol.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index ae8b81c55685..8615b066b642 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -4257,9 +4257,11 @@ static void mem_cgroup_css_reset(struct cgroup_subsys_state *css)
> {
> struct mem_cgroup *memcg = mem_cgroup_from_css(css);
>
> - mem_cgroup_resize_limit(memcg, PAGE_COUNTER_MAX);
> - mem_cgroup_resize_memsw_limit(memcg, PAGE_COUNTER_MAX);
> - memcg_update_kmem_limit(memcg, PAGE_COUNTER_MAX);
> + page_counter_limit(&memcg->memory, PAGE_COUNTER_MAX);
> + page_counter_limit(&memcg->swap, PAGE_COUNTER_MAX);
> + page_counter_limit(&memcg->memsw, PAGE_COUNTER_MAX);
> + page_counter_limit(&memcg->kmem, PAGE_COUNTER_MAX);
> + page_counter_limit(&memcg->tcpmem, PAGE_COUNTER_MAX);
> memcg->low = 0;
> memcg->high = PAGE_COUNTER_MAX;
> memcg->soft_limit = PAGE_COUNTER_MAX;
> --
> 2.1.4
--
Michal Hocko
SUSE Labs
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] cgroup: reset css on destruction
2016-03-01 11:13 ` [PATCH 2/2] cgroup: reset css on destruction Vladimir Davydov
@ 2016-03-01 16:30 ` Tejun Heo
2016-03-01 16:56 ` Vladimir Davydov
0 siblings, 1 reply; 8+ messages in thread
From: Tejun Heo @ 2016-03-01 16:30 UTC (permalink / raw)
To: Vladimir Davydov
Cc: Andrew Morton, Johannes Weiner, Michal Hocko, cgroups, linux-mm,
linux-kernel
On Tue, Mar 01, 2016 at 02:13:13PM +0300, Vladimir Davydov wrote:
> @@ -5138,6 +5138,8 @@ static void kill_css(struct cgroup_subsys_state *css)
> * See seq_css() for details.
> */
> css_clear_dir(css, NULL);
> + if (css->ss->css_reset)
> + css->ss->css_reset(css);
I think the better spot for this is in offline_css() right before
->css_offline() is called.
Thanks.
--
tejun
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] cgroup: reset css on destruction
2016-03-01 16:30 ` Tejun Heo
@ 2016-03-01 16:56 ` Vladimir Davydov
2016-03-01 17:06 ` Tejun Heo
2016-03-01 19:54 ` Johannes Weiner
0 siblings, 2 replies; 8+ messages in thread
From: Vladimir Davydov @ 2016-03-01 16:56 UTC (permalink / raw)
To: Tejun Heo
Cc: Andrew Morton, Johannes Weiner, Michal Hocko, cgroups, linux-mm,
linux-kernel
On Tue, Mar 01, 2016 at 11:30:18AM -0500, Tejun Heo wrote:
> On Tue, Mar 01, 2016 at 02:13:13PM +0300, Vladimir Davydov wrote:
> > @@ -5138,6 +5138,8 @@ static void kill_css(struct cgroup_subsys_state *css)
> > * See seq_css() for details.
> > */
> > css_clear_dir(css, NULL);
> > + if (css->ss->css_reset)
> > + css->ss->css_reset(css);
>
> I think the better spot for this is in offline_css() right before
> ->css_offline() is called.
Okay, here it goes.
---
From: Vladimir Davydov <vdavydov@virtuozzo.com>
Subject: [PATCH] cgroup: reset css on destruction
An associated css can be around for quite a while after a cgroup
directory has been removed. In general, it makes sense to reset it to
defaults so as not to worry about any remnants. For instance, memory
cgroup needs to reset memory.low, otherwise pages charged to a dead
cgroup might never get reclaimed. There's ->css_reset callback, which
would fit perfectly for the purpose. Currently, it's only called when a
subsystem is disabled in the unified hierarchy and there are other
subsystems dependant on it. Let's call it on css destruction as well.
Suggested-by: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Vladimir Davydov <vdavydov@virtuozzo.com>
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index cc40463e7b69..bb1900b70b01 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -4876,6 +4876,9 @@ static void offline_css(struct cgroup_subsys_state *css)
if (!(css->flags & CSS_ONLINE))
return;
+ if (ss->css_reset)
+ ss->css_reset(css);
+
if (ss->css_offline)
ss->css_offline(css);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] cgroup: reset css on destruction
2016-03-01 16:56 ` Vladimir Davydov
@ 2016-03-01 17:06 ` Tejun Heo
2016-03-01 19:54 ` Johannes Weiner
1 sibling, 0 replies; 8+ messages in thread
From: Tejun Heo @ 2016-03-01 17:06 UTC (permalink / raw)
To: Vladimir Davydov
Cc: Andrew Morton, Johannes Weiner, Michal Hocko, cgroups, linux-mm,
linux-kernel
On Tue, Mar 01, 2016 at 07:56:30PM +0300, Vladimir Davydov wrote:
> From: Vladimir Davydov <vdavydov@virtuozzo.com>
> Subject: [PATCH] cgroup: reset css on destruction
>
> An associated css can be around for quite a while after a cgroup
> directory has been removed. In general, it makes sense to reset it to
> defaults so as not to worry about any remnants. For instance, memory
> cgroup needs to reset memory.low, otherwise pages charged to a dead
> cgroup might never get reclaimed. There's ->css_reset callback, which
> would fit perfectly for the purpose. Currently, it's only called when a
> subsystem is disabled in the unified hierarchy and there are other
> subsystems dependant on it. Let's call it on css destruction as well.
>
> Suggested-by: Johannes Weiner <hannes@cmpxchg.org>
> Signed-off-by: Vladimir Davydov <vdavydov@virtuozzo.com>
Applied to cgroup/for-4.6. Thanks.
--
tejun
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] mm: memcontrol: cleanup css_reset callback
2016-03-01 11:13 [PATCH 1/2] mm: memcontrol: cleanup css_reset callback Vladimir Davydov
2016-03-01 11:13 ` [PATCH 2/2] cgroup: reset css on destruction Vladimir Davydov
2016-03-01 16:04 ` [PATCH 1/2] mm: memcontrol: cleanup css_reset callback Michal Hocko
@ 2016-03-01 19:53 ` Johannes Weiner
2 siblings, 0 replies; 8+ messages in thread
From: Johannes Weiner @ 2016-03-01 19:53 UTC (permalink / raw)
To: Vladimir Davydov
Cc: Andrew Morton, Tejun Heo, Michal Hocko, cgroups, linux-mm,
linux-kernel
On Tue, Mar 01, 2016 at 02:13:12PM +0300, Vladimir Davydov wrote:
> - Do not take memcg_limit_mutex for resetting limits - the cgroup
> cannot be altered from userspace anymore, so no need to protect them.
>
> - Use plain page_counter_limit() for resetting ->memory and ->memsw
> limits instead of mem_cgrouop_resize_* helpers - we enlarge the
> limits, so no need in special handling.
>
> - Reset ->swap and ->tcpmem limits as well.
>
> Signed-off-by: Vladimir Davydov <vdavydov@virtuozzo.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] cgroup: reset css on destruction
2016-03-01 16:56 ` Vladimir Davydov
2016-03-01 17:06 ` Tejun Heo
@ 2016-03-01 19:54 ` Johannes Weiner
1 sibling, 0 replies; 8+ messages in thread
From: Johannes Weiner @ 2016-03-01 19:54 UTC (permalink / raw)
To: Vladimir Davydov
Cc: Tejun Heo, Andrew Morton, Michal Hocko, cgroups, linux-mm,
linux-kernel
On Tue, Mar 01, 2016 at 07:56:30PM +0300, Vladimir Davydov wrote:
> From: Vladimir Davydov <vdavydov@virtuozzo.com>
> Subject: [PATCH] cgroup: reset css on destruction
>
> An associated css can be around for quite a while after a cgroup
> directory has been removed. In general, it makes sense to reset it to
> defaults so as not to worry about any remnants. For instance, memory
> cgroup needs to reset memory.low, otherwise pages charged to a dead
> cgroup might never get reclaimed. There's ->css_reset callback, which
> would fit perfectly for the purpose. Currently, it's only called when a
> subsystem is disabled in the unified hierarchy and there are other
> subsystems dependant on it. Let's call it on css destruction as well.
>
> Suggested-by: Johannes Weiner <hannes@cmpxchg.org>
> Signed-off-by: Vladimir Davydov <vdavydov@virtuozzo.com>
It's already in a git tree, but FWIW
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-03-01 19:55 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-01 11:13 [PATCH 1/2] mm: memcontrol: cleanup css_reset callback Vladimir Davydov
2016-03-01 11:13 ` [PATCH 2/2] cgroup: reset css on destruction Vladimir Davydov
2016-03-01 16:30 ` Tejun Heo
2016-03-01 16:56 ` Vladimir Davydov
2016-03-01 17:06 ` Tejun Heo
2016-03-01 19:54 ` Johannes Weiner
2016-03-01 16:04 ` [PATCH 1/2] mm: memcontrol: cleanup css_reset callback Michal Hocko
2016-03-01 19:53 ` Johannes Weiner
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).