All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michal Koutný" <mkoutny@suse.com>
To: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
Cc: Tejun Heo <tj@kernel.org>, Johannes Weiner <hannes@cmpxchg.org>,
	 Waiman Long <longman@redhat.com>,
	Ridong Chen <ridong.chen@linux.dev>,
	 linux-kernel@vger.kernel.org, Peng Fan <peng.fan@nxp.com>,
	cgroups@vger.kernel.org
Subject: Re: [PATCH] cgroup: use assign_bit() where applicable
Date: Mon, 21 Sep 2026 16:13:15 +0200	[thread overview]
Message-ID: <arE7Zx-ur8W9Jsij@localhost.localdomain> (raw)
In-Reply-To: <20260920022738.3145820-1-peng.fan@oss.nxp.com>

On Sun, Sep 20, 2026 at 10:27:37AM +0800, "Peng Fan (OSS)" <peng.fan@oss.nxp.com> wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> Convert open-coded if/else with set_bit/clear_bit and their
> non-atomic __set_bit/__clear_bit variants to the assign_bit/__assign_bit
> API.
> 
> Done with Coccinelle semantic patch:
>     // set_bit -> clear_bit => assign_bit
> 
>     @@
>     expression cond, bit, addr;
>     @@
> 
>     -if (cond)
>     -        set_bit(bit, addr);
>     -else
>     -        clear_bit(bit, addr);
>     +assign_bit(bit, addr, cond);
> 
>     // clear_bit -> set_bit => assign_bit
> 
>     @@
>     expression cond, bit, addr;
>     @@
> 
>     -if (cond)
>     -        clear_bit(bit, addr);
>     -else
>     -        set_bit(bit, addr);
>     +assign_bit(bit, addr, !cond);
> 
>     // __set_bit -> __clear_bit => __assign_bit
> 
>     @@
>     expression cond, bit, addr;
>     @@
> 
>     -if (cond)
>     -        __set_bit(bit, addr);
>     -else
>     -        __clear_bit(bit, addr);
>     +__assign_bit(bit, addr, cond);
> 
>     // __clear_bit -> __set_bit => __assign_bit
> 
>     @@
>     expression cond, bit, addr;
>     @@
> 
>     -if (cond)
>     -        __clear_bit(bit, addr);
>     -else
>     -        __set_bit(bit, addr);
>     +__assign_bit(bit, addr, !cond);
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  kernel/cgroup/cgroup-v1.c | 10 ++--------
>  kernel/cgroup/cpuset.c    | 16 ++++------------
>  kernel/cgroup/freezer.c   |  5 +----
>  3 files changed, 7 insertions(+), 24 deletions(-)

Nice use of Coccinelle,
Acked-by: Michal Koutný <mkoutny@suse.com>

(You may consider sharing an adjusted variant for
scripts/coccinelle/misc/ via cocci@inria.fr ML.)


  reply	other threads:[~2026-09-21 14:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-20  2:27 [PATCH] cgroup: use assign_bit() where applicable Peng Fan (OSS)
2026-09-21 14:13 ` Michal Koutný [this message]
2026-09-21 17:11 ` Tejun Heo

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=arE7Zx-ur8W9Jsij@localhost.localdomain \
    --to=mkoutny@suse.com \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=peng.fan@nxp.com \
    --cc=peng.fan@oss.nxp.com \
    --cc=ridong.chen@linux.dev \
    --cc=tj@kernel.org \
    /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.