* [PATCH] mm: memcontrol: Don't css_get() on root_mem_cgroup in get_mem_cgroup_from_mm()
@ 2023-10-12 16:15 Waiman Long
2023-10-13 14:17 ` Michal Hocko
0 siblings, 1 reply; 2+ messages in thread
From: Waiman Long @ 2023-10-12 16:15 UTC (permalink / raw)
To: Johannes Weiner, Michal Hocko, Roman Gushchin, Shakeel Butt,
Muchun Song, Andrew Morton
Cc: linux-kernel, cgroups, linux-mm, Waiman Long
As reference counting in the root memcg is disabled, there is no need
to get a reference if root memcg is to be returned.
Signed-off-by: Waiman Long <longman@redhat.com>
---
mm/memcontrol.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 5b009b233ab8..2b3864194042 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1060,8 +1060,10 @@ struct mem_cgroup *get_mem_cgroup_from_mm(struct mm_struct *mm)
rcu_read_lock();
do {
memcg = mem_cgroup_from_task(rcu_dereference(mm->owner));
- if (unlikely(!memcg))
+ if (unlikely(!memcg)) {
memcg = root_mem_cgroup;
+ break;
+ }
} while (!css_tryget(&memcg->css));
rcu_read_unlock();
return memcg;
--
2.39.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] mm: memcontrol: Don't css_get() on root_mem_cgroup in get_mem_cgroup_from_mm()
2023-10-12 16:15 [PATCH] mm: memcontrol: Don't css_get() on root_mem_cgroup in get_mem_cgroup_from_mm() Waiman Long
@ 2023-10-13 14:17 ` Michal Hocko
0 siblings, 0 replies; 2+ messages in thread
From: Michal Hocko @ 2023-10-13 14:17 UTC (permalink / raw)
To: Waiman Long
Cc: Johannes Weiner, Roman Gushchin, Shakeel Butt, Muchun Song,
Andrew Morton, linux-kernel, cgroups, linux-mm
On Thu 12-10-23 12:15:04, Waiman Long wrote:
> As reference counting in the root memcg is disabled, there is no need
> to get a reference if root memcg is to be returned.
Does this give any measurable wins?
> Signed-off-by: Waiman Long <longman@redhat.com>
> ---
> mm/memcontrol.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 5b009b233ab8..2b3864194042 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -1060,8 +1060,10 @@ struct mem_cgroup *get_mem_cgroup_from_mm(struct mm_struct *mm)
> rcu_read_lock();
> do {
> memcg = mem_cgroup_from_task(rcu_dereference(mm->owner));
> - if (unlikely(!memcg))
> + if (unlikely(!memcg)) {
> memcg = root_mem_cgroup;
> + break;
> + }
> } while (!css_tryget(&memcg->css));
> rcu_read_unlock();
> return memcg;
> --
> 2.39.3
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-10-13 14:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-12 16:15 [PATCH] mm: memcontrol: Don't css_get() on root_mem_cgroup in get_mem_cgroup_from_mm() Waiman Long
2023-10-13 14:17 ` Michal Hocko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox