linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: memcontrol: rename mem_cgroup_from_slab_obj()
@ 2025-12-10 15:43 Johannes Weiner
  2025-12-11  6:41 ` Roman Gushchin
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Johannes Weiner @ 2025-12-10 15:43 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Matthew Wilcox, Vlastimil Babka, Michal Hocko, Roman Gushchin,
	Shakeel Butt, Muchun Song, linux-mm, cgroups, linux-kernel

In addition to slab objects, this function is used for resolving
non-slab kernel pointers. This has caused confusion in recent
refactoring work. Rename it to mem_cgroup_from_virt(), sticking with
terminology established by the virt_to_<foo>() converters.

Link: https://lore.kernel.org/linux-mm/20251113161424.GB3465062@cmpxchg.org/
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 include/linux/memcontrol.h | 4 ++--
 mm/list_lru.c              | 4 ++--
 mm/memcontrol.c            | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 0651865a4564..17ad5cf43129 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -1727,7 +1727,7 @@ static inline int memcg_kmem_id(struct mem_cgroup *memcg)
 	return memcg ? memcg->kmemcg_id : -1;
 }
 
-struct mem_cgroup *mem_cgroup_from_slab_obj(void *p);
+struct mem_cgroup *mem_cgroup_from_virt(void *p);
 
 static inline void count_objcg_events(struct obj_cgroup *objcg,
 				      enum vm_event_item idx,
@@ -1799,7 +1799,7 @@ static inline int memcg_kmem_id(struct mem_cgroup *memcg)
 	return -1;
 }
 
-static inline struct mem_cgroup *mem_cgroup_from_slab_obj(void *p)
+static inline struct mem_cgroup *mem_cgroup_from_virt(void *p)
 {
 	return NULL;
 }
diff --git a/mm/list_lru.c b/mm/list_lru.c
index ec48b5dadf51..37b642f6cbda 100644
--- a/mm/list_lru.c
+++ b/mm/list_lru.c
@@ -187,7 +187,7 @@ bool list_lru_add_obj(struct list_lru *lru, struct list_head *item)
 
 	if (list_lru_memcg_aware(lru)) {
 		rcu_read_lock();
-		ret = list_lru_add(lru, item, nid, mem_cgroup_from_slab_obj(item));
+		ret = list_lru_add(lru, item, nid, mem_cgroup_from_virt(item));
 		rcu_read_unlock();
 	} else {
 		ret = list_lru_add(lru, item, nid, NULL);
@@ -224,7 +224,7 @@ bool list_lru_del_obj(struct list_lru *lru, struct list_head *item)
 
 	if (list_lru_memcg_aware(lru)) {
 		rcu_read_lock();
-		ret = list_lru_del(lru, item, nid, mem_cgroup_from_slab_obj(item));
+		ret = list_lru_del(lru, item, nid, mem_cgroup_from_virt(item));
 		rcu_read_unlock();
 	} else {
 		ret = list_lru_del(lru, item, nid, NULL);
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index be810c1fbfc3..e552072e346c 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -806,7 +806,7 @@ void mod_lruvec_kmem_state(void *p, enum node_stat_item idx, int val)
 	struct lruvec *lruvec;
 
 	rcu_read_lock();
-	memcg = mem_cgroup_from_slab_obj(p);
+	memcg = mem_cgroup_from_virt(p);
 
 	/*
 	 * Untracked pages have no memcg, no lruvec. Update only the
@@ -2619,7 +2619,7 @@ struct mem_cgroup *mem_cgroup_from_obj_slab(struct slab *slab, void *p)
  * The caller must ensure the memcg lifetime, e.g. by taking rcu_read_lock(),
  * cgroup_mutex, etc.
  */
-struct mem_cgroup *mem_cgroup_from_slab_obj(void *p)
+struct mem_cgroup *mem_cgroup_from_virt(void *p)
 {
 	struct slab *slab;
 
-- 
2.52.0



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

* Re: [PATCH] mm: memcontrol: rename mem_cgroup_from_slab_obj()
  2025-12-10 15:43 [PATCH] mm: memcontrol: rename mem_cgroup_from_slab_obj() Johannes Weiner
@ 2025-12-11  6:41 ` Roman Gushchin
  2025-12-11  9:35 ` Anshuman Khandual
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Roman Gushchin @ 2025-12-11  6:41 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Andrew Morton, Matthew Wilcox, Vlastimil Babka, Michal Hocko,
	Shakeel Butt, Muchun Song, linux-mm, cgroups, linux-kernel

On Wed, Dec 10, 2025 at 10:43:01AM -0500, Johannes Weiner wrote:
> In addition to slab objects, this function is used for resolving
> non-slab kernel pointers. This has caused confusion in recent
> refactoring work. Rename it to mem_cgroup_from_virt(), sticking with
> terminology established by the virt_to_<foo>() converters.
> 
> Link: https://lore.kernel.org/linux-mm/20251113161424.GB3465062@cmpxchg.org/
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>

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

Thanks!


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

* Re: [PATCH] mm: memcontrol: rename mem_cgroup_from_slab_obj()
  2025-12-10 15:43 [PATCH] mm: memcontrol: rename mem_cgroup_from_slab_obj() Johannes Weiner
  2025-12-11  6:41 ` Roman Gushchin
@ 2025-12-11  9:35 ` Anshuman Khandual
  2025-12-11  9:36 ` Vlastimil Babka
  2025-12-12  0:38 ` Shakeel Butt
  3 siblings, 0 replies; 5+ messages in thread
From: Anshuman Khandual @ 2025-12-11  9:35 UTC (permalink / raw)
  To: Johannes Weiner, Andrew Morton
  Cc: Matthew Wilcox, Vlastimil Babka, Michal Hocko, Roman Gushchin,
	Shakeel Butt, Muchun Song, linux-mm, cgroups, linux-kernel

On 10/12/25 9:13 PM, Johannes Weiner wrote:
> In addition to slab objects, this function is used for resolving
> non-slab kernel pointers. This has caused confusion in recent
> refactoring work. Rename it to mem_cgroup_from_virt(), sticking with
> terminology established by the virt_to_<foo>() converters.
> 
> Link: https://lore.kernel.org/linux-mm/20251113161424.GB3465062@cmpxchg.org/
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
> ---
>  include/linux/memcontrol.h | 4 ++--
>  mm/list_lru.c              | 4 ++--
>  mm/memcontrol.c            | 4 ++--
>  3 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
> index 0651865a4564..17ad5cf43129 100644
> --- a/include/linux/memcontrol.h
> +++ b/include/linux/memcontrol.h
> @@ -1727,7 +1727,7 @@ static inline int memcg_kmem_id(struct mem_cgroup *memcg)
>  	return memcg ? memcg->kmemcg_id : -1;
>  }
>  
> -struct mem_cgroup *mem_cgroup_from_slab_obj(void *p);
> +struct mem_cgroup *mem_cgroup_from_virt(void *p);
>  
>  static inline void count_objcg_events(struct obj_cgroup *objcg,
>  				      enum vm_event_item idx,
> @@ -1799,7 +1799,7 @@ static inline int memcg_kmem_id(struct mem_cgroup *memcg)
>  	return -1;
>  }
>  
> -static inline struct mem_cgroup *mem_cgroup_from_slab_obj(void *p)
> +static inline struct mem_cgroup *mem_cgroup_from_virt(void *p)
>  {
>  	return NULL;
>  }
> diff --git a/mm/list_lru.c b/mm/list_lru.c
> index ec48b5dadf51..37b642f6cbda 100644
> --- a/mm/list_lru.c
> +++ b/mm/list_lru.c
> @@ -187,7 +187,7 @@ bool list_lru_add_obj(struct list_lru *lru, struct list_head *item)
>  
>  	if (list_lru_memcg_aware(lru)) {
>  		rcu_read_lock();
> -		ret = list_lru_add(lru, item, nid, mem_cgroup_from_slab_obj(item));
> +		ret = list_lru_add(lru, item, nid, mem_cgroup_from_virt(item));
>  		rcu_read_unlock();
>  	} else {
>  		ret = list_lru_add(lru, item, nid, NULL);
> @@ -224,7 +224,7 @@ bool list_lru_del_obj(struct list_lru *lru, struct list_head *item)
>  
>  	if (list_lru_memcg_aware(lru)) {
>  		rcu_read_lock();
> -		ret = list_lru_del(lru, item, nid, mem_cgroup_from_slab_obj(item));
> +		ret = list_lru_del(lru, item, nid, mem_cgroup_from_virt(item));
>  		rcu_read_unlock();
>  	} else {
>  		ret = list_lru_del(lru, item, nid, NULL);
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index be810c1fbfc3..e552072e346c 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -806,7 +806,7 @@ void mod_lruvec_kmem_state(void *p, enum node_stat_item idx, int val)
>  	struct lruvec *lruvec;
>  
>  	rcu_read_lock();
> -	memcg = mem_cgroup_from_slab_obj(p);
> +	memcg = mem_cgroup_from_virt(p);
>  
>  	/*
>  	 * Untracked pages have no memcg, no lruvec. Update only the
> @@ -2619,7 +2619,7 @@ struct mem_cgroup *mem_cgroup_from_obj_slab(struct slab *slab, void *p)
>   * The caller must ensure the memcg lifetime, e.g. by taking rcu_read_lock(),
>   * cgroup_mutex, etc.
>   */
> -struct mem_cgroup *mem_cgroup_from_slab_obj(void *p)
> +struct mem_cgroup *mem_cgroup_from_virt(void *p)
>  {
>  	struct slab *slab;
> 

Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>



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

* Re: [PATCH] mm: memcontrol: rename mem_cgroup_from_slab_obj()
  2025-12-10 15:43 [PATCH] mm: memcontrol: rename mem_cgroup_from_slab_obj() Johannes Weiner
  2025-12-11  6:41 ` Roman Gushchin
  2025-12-11  9:35 ` Anshuman Khandual
@ 2025-12-11  9:36 ` Vlastimil Babka
  2025-12-12  0:38 ` Shakeel Butt
  3 siblings, 0 replies; 5+ messages in thread
From: Vlastimil Babka @ 2025-12-11  9:36 UTC (permalink / raw)
  To: Johannes Weiner, Andrew Morton
  Cc: Matthew Wilcox, Michal Hocko, Roman Gushchin, Shakeel Butt,
	Muchun Song, linux-mm, cgroups, linux-kernel

On 12/10/25 16:43, Johannes Weiner wrote:
> In addition to slab objects, this function is used for resolving
> non-slab kernel pointers. This has caused confusion in recent
> refactoring work. Rename it to mem_cgroup_from_virt(), sticking with
> terminology established by the virt_to_<foo>() converters.
> 
> Link: https://lore.kernel.org/linux-mm/20251113161424.GB3465062@cmpxchg.org/
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>

Acked-by: Vlastimil Babka <vbabka@suse.cz>



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

* Re: [PATCH] mm: memcontrol: rename mem_cgroup_from_slab_obj()
  2025-12-10 15:43 [PATCH] mm: memcontrol: rename mem_cgroup_from_slab_obj() Johannes Weiner
                   ` (2 preceding siblings ...)
  2025-12-11  9:36 ` Vlastimil Babka
@ 2025-12-12  0:38 ` Shakeel Butt
  3 siblings, 0 replies; 5+ messages in thread
From: Shakeel Butt @ 2025-12-12  0:38 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Andrew Morton, Matthew Wilcox, Vlastimil Babka, Michal Hocko,
	Roman Gushchin, Muchun Song, linux-mm, cgroups, linux-kernel

On Wed, Dec 10, 2025 at 10:43:01AM -0500, Johannes Weiner wrote:
> In addition to slab objects, this function is used for resolving
> non-slab kernel pointers. This has caused confusion in recent
> refactoring work. Rename it to mem_cgroup_from_virt(), sticking with
> terminology established by the virt_to_<foo>() converters.
> 
> Link: https://lore.kernel.org/linux-mm/20251113161424.GB3465062@cmpxchg.org/
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>

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


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

end of thread, other threads:[~2025-12-12  0:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-10 15:43 [PATCH] mm: memcontrol: rename mem_cgroup_from_slab_obj() Johannes Weiner
2025-12-11  6:41 ` Roman Gushchin
2025-12-11  9:35 ` Anshuman Khandual
2025-12-11  9:36 ` Vlastimil Babka
2025-12-12  0:38 ` Shakeel Butt

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