All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] memcg: remove unused mem_cgroup_from_obj()
@ 2023-05-27 10:31 ` Miaohe Lin
  0 siblings, 0 replies; 18+ messages in thread
From: Miaohe Lin @ 2023-05-27 10:31 UTC (permalink / raw)
  To: hannes, mhocko, roman.gushchin, shakeelb, akpm
  Cc: muchun.song, cgroups, linux-mm, linux-kernel, linmiaohe

The function mem_cgroup_from_obj() is not used anymore. Remove it and
clean up relevant comments.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 include/linux/memcontrol.h |  6 ------
 mm/memcontrol.c            | 31 -------------------------------
 2 files changed, 37 deletions(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 00a88cf947e1..ce8c2355ed9f 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -1813,7 +1813,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,
@@ -1876,11 +1875,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 6a3d4ce87b8a..532b29c9a0fe 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2972,37 +2972,6 @@ 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().
- *
  * A passed kernel object must be a slab object or a generic kernel page.
  *
  * The caller must ensure the memcg lifetime, e.g. by taking rcu_read_lock(),
-- 
2.27.0


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

end of thread, other threads:[~2023-05-29 18:53 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-27 10:31 [PATCH] memcg: remove unused mem_cgroup_from_obj() Miaohe Lin
2023-05-27 10:31 ` Miaohe Lin
2023-05-27  3:55 ` Yosry Ahmed
2023-05-27  3:55   ` Yosry Ahmed
2023-05-27  4:00 ` Matthew Wilcox
2023-05-27  4:00   ` Matthew Wilcox
2023-05-27  4:13   ` Yosry Ahmed
2023-05-27  4:13     ` Yosry Ahmed
2023-05-27 15:07     ` Matthew Wilcox
2023-05-27 15:07       ` Matthew Wilcox
2023-05-27 18:54       ` Yosry Ahmed
2023-05-27 18:54         ` Yosry Ahmed
2023-05-28 13:01         ` Muchun Song
2023-05-28 13:01           ` Muchun Song
2023-05-28 19:36           ` Matthew Wilcox
2023-05-29 18:53             ` Shakeel Butt
2023-05-29 18:53               ` Shakeel Butt
2023-05-28 20:19           ` Yosry Ahmed

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.