All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Weiner <hannes@cmpxchg.org>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: "Jemmy Wong" <jemmywong512@gmail.com>,
	"Tejun Heo" <tj@kernel.org>, "Michal Koutný" <mkoutny@suse.com>,
	"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>,
	"open list:CONTROL GROUP (CGROUP)" <cgroups@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v0] cgroup: Add lock guard support
Date: Fri, 6 Jun 2025 12:42:48 +0200	[thread overview]
Message-ID: <20250606104248.GA1118@cmpxchg.org> (raw)
In-Reply-To: <CAADnVQJyATTb9GFyBhOy5V_keAO5NZ6+zucLRyN27Cmg2FGPVA@mail.gmail.com>

On Thu, Jun 05, 2025 at 05:54:15PM -0700, Alexei Starovoitov wrote:
> On Thu, Jun 5, 2025 at 2:11 PM 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.
> >
> > Signed-off-by: Jemmy Wong <jemmywong512@gmail.com>
> >
> > ---
> >  include/linux/cgroup.h     |   7 +
> >  kernel/bpf/cgroup.c        |  96 +++---
> >  kernel/bpf/local_storage.c |  12 +-
> 
> Nack for bpf bits.
> It only uglifies the code.

I agree with this.

The extra indentation from scoped guard is unfortunate.

The guard with implicit unlock gives me the heebeejeebees - it's
asymmetric and critical sections don't stand out visually at all.

Adjusting critical section boundaries with guard means either:
* indentation churn to convert to scoped guard,
* forcing abstraction splits along critical sections (non-API
  _locked functions), which makes the code flow harder to follow,
* or straight-up violating abstraction layering and adding
  non-critical stuff to callers where it doesn't make sense.

I don't remember the last production bug from forgetting to drop a
lock. Meanwhile, the things that people actually seem to struggle with
when it comes to locks appear to become harder with those primitives.

  parent reply	other threads:[~2025-06-06 10:42 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 [this message]
2025-06-06 13:39     ` Jemmy Wong
2025-06-06  9:34 ` Michal Koutný
2025-06-06 13:51   ` Jemmy Wong

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=20250606104248.GA1118@cmpxchg.org \
    --to=hannes@cmpxchg.org \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=cgroups@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=jemmywong512@gmail.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 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.