linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@suse.com>
To: Waiman Long <longman@redhat.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Shakeel Butt <shakeelb@google.com>,
	Muchun Song <muchun.song@linux.dev>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, cgroups@vger.kernel.org,
	linux-mm@kvack.org
Subject: Re: [PATCH] mm: memcontrol: Don't css_get() on root_mem_cgroup in get_mem_cgroup_from_mm()
Date: Fri, 13 Oct 2023 16:17:21 +0200	[thread overview]
Message-ID: <ZSlRcQ3JoPLFRBec@dhcp22.suse.cz> (raw)
In-Reply-To: <20231012161504.3445042-1-longman@redhat.com>

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


      reply	other threads:[~2023-10-13 14:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-12 16:15 Waiman Long
2023-10-13 14:17 ` Michal Hocko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZSlRcQ3JoPLFRBec@dhcp22.suse.cz \
    --to=mhocko@suse.com \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=longman@redhat.com \
    --cc=muchun.song@linux.dev \
    --cc=roman.gushchin@linux.dev \
    --cc=shakeelb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox