cgroups.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jemmy Wong <jemmywong512@gmail.com>
To: "Michal Koutný" <mkoutny@suse.com>
Cc: Jemmy <jemmywong512@gmail.com>, Tejun Heo <tj@kernel.org>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>, Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Stanislav Fomichev <sdf@fomichev.me>, Hao Luo <haoluo@google.com>,
	Jiri Olsa <jolsa@kernel.org>,
	cgroups@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v0] cgroup: Add lock guard support
Date: Fri, 6 Jun 2025 21:51:34 +0800	[thread overview]
Message-ID: <64D97068-D44C-4B29-9847-82F87A006D14@gmail.com> (raw)
In-Reply-To: <fo5le4uonsrv24z5gikojq7hxwaqaidgco25pypnppk5h2czap@egdwx6yte4lf>

Hi Michal,

> On Jun 6, 2025, at 5:34 PM, Michal Koutný <mkoutny@suse.com> wrote:
> 
> Hello.
> 
> On Fri, Jun 06, 2025 at 05:10:53AM +0800, Jemmy Wong <jemmywong512@gmail.com> wrote:
>> This change replaces manual lock acquisition and release with lock guards
>> to improve code robustness and reduce the risk of lock mismanagement.
>> No functional changes to the cgroup logic are introduced.
> 
> I like this.
> Could you possible split it to individual commits to ease the review
> for: cgroup_mutex, css_set_lock, RCU and the rest?
> 

Thanks for your support. I’ll split the patch into several parts.

> ...
>> --- a/include/linux/cgroup.h
>> +++ b/include/linux/cgroup.h
>> @@ -382,6 +382,10 @@ static inline void cgroup_put(struct cgroup *cgrp)
>> 
>> extern struct mutex cgroup_mutex;
>> 
>> +DEFINE_LOCK_GUARD_0(cgroup_mutex,
>> + mutex_lock(&cgroup_mutex),
>> + mutex_unlock(&cgroup_mutex))
>> +
>> static inline void cgroup_lock(void)
>> {
>> mutex_lock(&cgroup_mutex);
>> @@ -656,6 +660,9 @@ struct cgroup *cgroup_get_from_id(u64 id);
>> struct cgroup_subsys_state;
>> struct cgroup;
>> 
>> +extern struct mutex cgroup_mutex;
> 
> I assume this was because of the BPF code, which wouldn't be needed in
> the end.
> 

Yeah, other modules also need cgroup_mutex, cgroup_lock/unlock must be retained.

> ...
> 
> Thanks,
> Michal

Best, 
Jemmy


      reply	other threads:[~2025-06-06 13:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-05 21:10 [PATCH v0] cgroup: Add lock guard support Jemmy Wong
2025-06-06  0:54 ` Alexei Starovoitov
2025-06-06  5:58   ` Jemmy Wong
2025-06-06 10:42   ` Johannes Weiner
2025-06-06 13:39     ` Jemmy Wong
2025-06-06  9:34 ` Michal Koutný
2025-06-06 13:51   ` Jemmy Wong [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=64D97068-D44C-4B29-9847-82F87A006D14@gmail.com \
    --to=jemmywong512@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=cgroups@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=hannes@cmpxchg.org \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mkoutny@suse.com \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --cc=tj@kernel.org \
    --cc=yonghong.song@linux.dev \
    /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;
as well as URLs for NNTP newsgroup(s).