* [PATCH] mm: memcontrol: Fix do not put the css reference
@ 2020-06-14 12:26 Muchun Song
2020-06-14 17:22 ` Roman Gushchin
2020-06-15 11:50 ` Michal Hocko
0 siblings, 2 replies; 3+ messages in thread
From: Muchun Song @ 2020-06-14 12:26 UTC (permalink / raw)
To: hannes, mhocko, vdavydov.dev, akpm
Cc: guro, cai, cgroups, linux-mm, linux-kernel, Muchun Song
We should put the css reference when memory allocation failed.
Fixes: f0a3a24b532d ("mm: memcg/slab: rework non-root kmem_cache lifecycle management")
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
---
mm/memcontrol.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 0b38b6ad547d..2323d811ee8e 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2772,8 +2772,10 @@ static void memcg_schedule_kmem_cache_create(struct mem_cgroup *memcg,
return;
cw = kmalloc(sizeof(*cw), GFP_NOWAIT | __GFP_NOWARN);
- if (!cw)
+ if (!cw) {
+ css_put(&memcg->css);
return;
+ }
cw->memcg = memcg;
cw->cachep = cachep;
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mm: memcontrol: Fix do not put the css reference
2020-06-14 12:26 [PATCH] mm: memcontrol: Fix do not put the css reference Muchun Song
@ 2020-06-14 17:22 ` Roman Gushchin
2020-06-15 11:50 ` Michal Hocko
1 sibling, 0 replies; 3+ messages in thread
From: Roman Gushchin @ 2020-06-14 17:22 UTC (permalink / raw)
To: Muchun Song
Cc: hannes, mhocko, vdavydov.dev, akpm, cai, cgroups, linux-mm, linux-kernel
On Sun, Jun 14, 2020 at 08:26:53PM +0800, Muchun Song wrote:
> We should put the css reference when memory allocation failed.
>
> Fixes: f0a3a24b532d ("mm: memcg/slab: rework non-root kmem_cache lifecycle management")
> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
> ---
> mm/memcontrol.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
Good catch, thank you!
Acked-by: Roman Gushchin <guro@fb.com>
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 0b38b6ad547d..2323d811ee8e 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -2772,8 +2772,10 @@ static void memcg_schedule_kmem_cache_create(struct mem_cgroup *memcg,
> return;
>
> cw = kmalloc(sizeof(*cw), GFP_NOWAIT | __GFP_NOWARN);
> - if (!cw)
> + if (!cw) {
> + css_put(&memcg->css);
> return;
> + }
>
> cw->memcg = memcg;
> cw->cachep = cachep;
> --
> 2.11.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mm: memcontrol: Fix do not put the css reference
2020-06-14 12:26 [PATCH] mm: memcontrol: Fix do not put the css reference Muchun Song
2020-06-14 17:22 ` Roman Gushchin
@ 2020-06-15 11:50 ` Michal Hocko
1 sibling, 0 replies; 3+ messages in thread
From: Michal Hocko @ 2020-06-15 11:50 UTC (permalink / raw)
To: Muchun Song
Cc: hannes, vdavydov.dev, akpm, guro, cai, cgroups, linux-mm, linux-kernel
On Sun 14-06-20 20:26:53, Muchun Song wrote:
> We should put the css reference when memory allocation failed.
>
> Fixes: f0a3a24b532d ("mm: memcg/slab: rework non-root kmem_cache lifecycle management")
> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
This looks like a stable tree material to me.
Acked-by: Michal Hocko <mhocko@suse.com>
> ---
> mm/memcontrol.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 0b38b6ad547d..2323d811ee8e 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -2772,8 +2772,10 @@ static void memcg_schedule_kmem_cache_create(struct mem_cgroup *memcg,
> return;
>
> cw = kmalloc(sizeof(*cw), GFP_NOWAIT | __GFP_NOWARN);
> - if (!cw)
> + if (!cw) {
> + css_put(&memcg->css);
> return;
> + }
>
> cw->memcg = memcg;
> cw->cachep = cachep;
> --
> 2.11.0
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-06-15 11:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-14 12:26 [PATCH] mm: memcontrol: Fix do not put the css reference Muchun Song
2020-06-14 17:22 ` Roman Gushchin
2020-06-15 11:50 ` Michal Hocko
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).