linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mm/memcg: Remove obsolete memcg_free_kmem()
@ 2021-10-05 20:24 Waiman Long
  2021-10-06  1:15 ` Roman Gushchin
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Waiman Long @ 2021-10-05 20:24 UTC (permalink / raw)
  To: Johannes Weiner, Michal Hocko, Vladimir Davydov, Andrew Morton,
	Vlastimil Babka, Roman Gushchin
  Cc: linux-kernel, cgroups, linux-mm, Shakeel Butt, Muchun Song, Waiman Long

Since commit d648bcc7fe65 ("mm: kmem: make memcg_kmem_enabled()
irreversible"), the only thing memcg_free_kmem() does is to call
memcg_offline_kmem() when the memcg is still online which can happen when
online_css() fails due to -ENOMEM. However, the name memcg_free_kmem()
is confusing and it is more clear and straight forward to call
memcg_offline_kmem() directly from mem_cgroup_css_free().

Suggested-by: Roman Gushchin <guro@fb.com>
Signed-off-by: Waiman Long <longman@redhat.com>
---
 mm/memcontrol.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 6da5020a8656..96a93c608d80 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3656,13 +3656,6 @@ static void memcg_offline_kmem(struct mem_cgroup *memcg)
 
 	memcg_free_cache_id(kmemcg_id);
 }
-
-static void memcg_free_kmem(struct mem_cgroup *memcg)
-{
-	/* css_alloc() failed, offlining didn't happen */
-	if (unlikely(memcg->kmem_state == KMEM_ONLINE))
-		memcg_offline_kmem(memcg);
-}
 #else
 static int memcg_online_kmem(struct mem_cgroup *memcg)
 {
@@ -3671,9 +3664,6 @@ static int memcg_online_kmem(struct mem_cgroup *memcg)
 static void memcg_offline_kmem(struct mem_cgroup *memcg)
 {
 }
-static void memcg_free_kmem(struct mem_cgroup *memcg)
-{
-}
 #endif /* CONFIG_MEMCG_KMEM */
 
 static int memcg_update_kmem_max(struct mem_cgroup *memcg,
@@ -5308,7 +5298,9 @@ static void mem_cgroup_css_free(struct cgroup_subsys_state *css)
 	cancel_work_sync(&memcg->high_work);
 	mem_cgroup_remove_from_trees(memcg);
 	free_shrinker_info(memcg);
-	memcg_free_kmem(memcg);
+
+	/* Need to offline kmem if online_css() fails */
+	memcg_offline_kmem(memcg);
 	mem_cgroup_free(memcg);
 }
 
-- 
2.18.1



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] mm/memcg: Remove obsolete memcg_free_kmem()
  2021-10-05 20:24 [PATCH v2] mm/memcg: Remove obsolete memcg_free_kmem() Waiman Long
@ 2021-10-06  1:15 ` Roman Gushchin
  2021-10-06  5:20 ` Shakeel Butt
  2021-10-06 19:08 ` Aaron Tomlin
  2 siblings, 0 replies; 4+ messages in thread
From: Roman Gushchin @ 2021-10-06  1:15 UTC (permalink / raw)
  To: Waiman Long
  Cc: Johannes Weiner, Michal Hocko, Vladimir Davydov, Andrew Morton,
	Vlastimil Babka, linux-kernel, cgroups, linux-mm, Shakeel Butt,
	Muchun Song

On Tue, Oct 05, 2021 at 04:24:50PM -0400, Waiman Long wrote:
> Since commit d648bcc7fe65 ("mm: kmem: make memcg_kmem_enabled()
> irreversible"), the only thing memcg_free_kmem() does is to call
> memcg_offline_kmem() when the memcg is still online which can happen when
> online_css() fails due to -ENOMEM. However, the name memcg_free_kmem()
> is confusing and it is more clear and straight forward to call
> memcg_offline_kmem() directly from mem_cgroup_css_free().
> 
> Suggested-by: Roman Gushchin <guro@fb.com>
> Signed-off-by: Waiman Long <longman@redhat.com>

Reviewed-by: Roman Gushchin <guro@fb.com>

Thanks, Waiman!


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] mm/memcg: Remove obsolete memcg_free_kmem()
  2021-10-05 20:24 [PATCH v2] mm/memcg: Remove obsolete memcg_free_kmem() Waiman Long
  2021-10-06  1:15 ` Roman Gushchin
@ 2021-10-06  5:20 ` Shakeel Butt
  2021-10-06 19:08 ` Aaron Tomlin
  2 siblings, 0 replies; 4+ messages in thread
From: Shakeel Butt @ 2021-10-06  5:20 UTC (permalink / raw)
  To: Waiman Long
  Cc: Johannes Weiner, Michal Hocko, Vladimir Davydov, Andrew Morton,
	Vlastimil Babka, Roman Gushchin, LKML, Cgroups, Linux MM,
	Muchun Song

On Tue, Oct 5, 2021 at 1:25 PM Waiman Long <longman@redhat.com> wrote:
>
> Since commit d648bcc7fe65 ("mm: kmem: make memcg_kmem_enabled()
> irreversible"), the only thing memcg_free_kmem() does is to call
> memcg_offline_kmem() when the memcg is still online which can happen when
> online_css() fails due to -ENOMEM. However, the name memcg_free_kmem()
> is confusing and it is more clear and straight forward to call
> memcg_offline_kmem() directly from mem_cgroup_css_free().
>
> Suggested-by: Roman Gushchin <guro@fb.com>
> Signed-off-by: Waiman Long <longman@redhat.com>

Reviewed-by: Shakeel Butt <shakeelb@google.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] mm/memcg: Remove obsolete memcg_free_kmem()
  2021-10-05 20:24 [PATCH v2] mm/memcg: Remove obsolete memcg_free_kmem() Waiman Long
  2021-10-06  1:15 ` Roman Gushchin
  2021-10-06  5:20 ` Shakeel Butt
@ 2021-10-06 19:08 ` Aaron Tomlin
  2 siblings, 0 replies; 4+ messages in thread
From: Aaron Tomlin @ 2021-10-06 19:08 UTC (permalink / raw)
  To: Waiman Long
  Cc: Johannes Weiner, Michal Hocko, Vladimir Davydov, Andrew Morton,
	Vlastimil Babka, Roman Gushchin, linux-kernel, cgroups, linux-mm,
	Shakeel Butt, Muchun Song

On Tue 2021-10-05 16:24 -0400, Waiman Long wrote:
> Since commit d648bcc7fe65 ("mm: kmem: make memcg_kmem_enabled()
> irreversible"), the only thing memcg_free_kmem() does is to call
> memcg_offline_kmem() when the memcg is still online which can happen when
> online_css() fails due to -ENOMEM. However, the name memcg_free_kmem()
> is confusing and it is more clear and straight forward to call
> memcg_offline_kmem() directly from mem_cgroup_css_free().
> 
> Suggested-by: Roman Gushchin <guro@fb.com>
> Signed-off-by: Waiman Long <longman@redhat.com>

Reviewed-by: Aaron Tomlin <atomlin@redhat.com>

-- 
Aaron Tomlin



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-10-06 19:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-05 20:24 [PATCH v2] mm/memcg: Remove obsolete memcg_free_kmem() Waiman Long
2021-10-06  1:15 ` Roman Gushchin
2021-10-06  5:20 ` Shakeel Butt
2021-10-06 19:08 ` Aaron Tomlin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox