linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: kmem: remove mem_cgroup_from_obj()
@ 2024-07-18  9:18 Muchun Song
  2024-07-18 19:46 ` Shakeel Butt
  2024-07-18 20:47 ` Roman Gushchin
  0 siblings, 2 replies; 3+ messages in thread
From: Muchun Song @ 2024-07-18  9:18 UTC (permalink / raw)
  To: hannes, mhocko, roman.gushchin, shakeel.butt, muchun.song, akpm
  Cc: cgroups, linux-mm, linux-kernel, Muchun Song

There is no user of mem_cgroup_from_obj(), remove it.

Signed-off-by: Muchun Song <songmuchun@bytedance.com>
---
 include/linux/memcontrol.h |  6 ------
 mm/memcontrol.c            | 32 +-------------------------------
 2 files changed, 1 insertion(+), 37 deletions(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 394fd0a887ae7..461313307ec23 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -1862,7 +1862,6 @@ static inline int memcg_kmem_id(struct mem_cgroup *memcg)
 	return memcg ? memcg->kmemcg_id : -1;
 }
 
-struct mem_cgroup *mem_cgroup_from_obj(void *p);
 struct mem_cgroup *mem_cgroup_from_slab_obj(void *p);
 
 static inline void count_objcg_event(struct obj_cgroup *objcg,
@@ -1925,11 +1924,6 @@ static inline int memcg_kmem_id(struct mem_cgroup *memcg)
 	return -1;
 }
 
-static inline struct mem_cgroup *mem_cgroup_from_obj(void *p)
-{
-	return NULL;
-}
-
 static inline struct mem_cgroup *mem_cgroup_from_slab_obj(void *p)
 {
 	return NULL;
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index fabce2b50c695..d04fb1ae870e9 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3076,37 +3076,7 @@ struct mem_cgroup *mem_cgroup_from_obj_folio(struct folio *folio, void *p)
 
 /*
  * Returns a pointer to the memory cgroup to which the kernel object is charged.
- *
- * A passed kernel object can be a slab object, vmalloc object or a generic
- * kernel page, so different mechanisms for getting the memory cgroup pointer
- * should be used.
- *
- * In certain cases (e.g. kernel stacks or large kmallocs with SLUB) the caller
- * can not know for sure how the kernel object is implemented.
- * mem_cgroup_from_obj() can be safely used in such cases.
- *
- * The caller must ensure the memcg lifetime, e.g. by taking rcu_read_lock(),
- * cgroup_mutex, etc.
- */
-struct mem_cgroup *mem_cgroup_from_obj(void *p)
-{
-	struct folio *folio;
-
-	if (mem_cgroup_disabled())
-		return NULL;
-
-	if (unlikely(is_vmalloc_addr(p)))
-		folio = page_folio(vmalloc_to_page(p));
-	else
-		folio = virt_to_folio(p);
-
-	return mem_cgroup_from_obj_folio(folio, p);
-}
-
-/*
- * Returns a pointer to the memory cgroup to which the kernel object is charged.
- * Similar to mem_cgroup_from_obj(), but faster and not suitable for objects,
- * allocated using vmalloc().
+ * It is not suitable for objects allocated using vmalloc().
  *
  * A passed kernel object must be a slab object or a generic kernel page.
  *
-- 
2.20.1



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

* Re: [PATCH] mm: kmem: remove mem_cgroup_from_obj()
  2024-07-18  9:18 [PATCH] mm: kmem: remove mem_cgroup_from_obj() Muchun Song
@ 2024-07-18 19:46 ` Shakeel Butt
  2024-07-18 20:47 ` Roman Gushchin
  1 sibling, 0 replies; 3+ messages in thread
From: Shakeel Butt @ 2024-07-18 19:46 UTC (permalink / raw)
  To: Muchun Song
  Cc: hannes, mhocko, roman.gushchin, muchun.song, akpm, cgroups,
	linux-mm, linux-kernel

On Thu, Jul 18, 2024 at 05:18:21PM GMT, Muchun Song wrote:
> There is no user of mem_cgroup_from_obj(), remove it.
> 
> Signed-off-by: Muchun Song <songmuchun@bytedance.com>

Acked-by: Shakeel Butt <shakeel.butt@linux.dev>


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

* Re: [PATCH] mm: kmem: remove mem_cgroup_from_obj()
  2024-07-18  9:18 [PATCH] mm: kmem: remove mem_cgroup_from_obj() Muchun Song
  2024-07-18 19:46 ` Shakeel Butt
@ 2024-07-18 20:47 ` Roman Gushchin
  1 sibling, 0 replies; 3+ messages in thread
From: Roman Gushchin @ 2024-07-18 20:47 UTC (permalink / raw)
  To: Muchun Song
  Cc: hannes, mhocko, shakeel.butt, muchun.song, akpm, cgroups,
	linux-mm, linux-kernel

On Thu, Jul 18, 2024 at 05:18:21PM +0800, Muchun Song wrote:
> There is no user of mem_cgroup_from_obj(), remove it.
> 
> Signed-off-by: Muchun Song <songmuchun@bytedance.com>

Acked-by: Roman Gushchin <roman.gushchin@linux.dev>

Thanks!


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

end of thread, other threads:[~2024-07-18 20:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-18  9:18 [PATCH] mm: kmem: remove mem_cgroup_from_obj() Muchun Song
2024-07-18 19:46 ` Shakeel Butt
2024-07-18 20:47 ` Roman Gushchin

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