From: Thomas Gleixner <tglx@linutronix.de>
To: John Stultz <jstultz@google.com>, Su Hui <suhui@nfschina.com>
Cc: sboyd@kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 3/3] alarmtimer: switch spin_{lock,unlock}_irqsave() to guard()
Date: Wed, 30 Apr 2025 08:58:27 +0200 [thread overview]
Message-ID: <87y0vip23w.ffs@tglx> (raw)
In-Reply-To: <CANDhNCq0yOXRF+6_JaMYo98o5uKP_af+UXJcJmzuFvX63RdTaA@mail.gmail.com>
On Thu, Apr 24 2025 at 16:59, John Stultz wrote:
> On Thu, Apr 24, 2025 at 7:48 AM Su Hui <suhui@nfschina.com> wrote:
>> - spin_unlock_irqrestore(&freezer_delta_lock, flags);
>> + scoped_guard(spinlock_irqsave, &freezer_delta_lock) {
>> + min = freezer_delta;
>> + expires = freezer_expires;
>> + type = freezer_alarmtype;
>> + freezer_delta = 0;
>> + }
>
> I'm not necessarily opposed, but I'm not sure we're gaining much here.
>> @@ -352,13 +347,13 @@ EXPORT_SYMBOL_GPL(alarm_init);
>> void alarm_start(struct alarm *alarm, ktime_t start)
>> {
>> struct alarm_base *base = &alarm_bases[alarm->type];
>> - unsigned long flags;
>>
>> - spin_lock_irqsave(&base->lock, flags);
>> - alarm->node.expires = start;
>> - alarmtimer_enqueue(base, alarm);
>> - hrtimer_start(&alarm->timer, alarm->node.expires, HRTIMER_MODE_ABS);
>> - spin_unlock_irqrestore(&base->lock, flags);
>> + scoped_guard(spinlock_irqsave, &base->lock) {
>> + alarm->node.expires = start;
>> + alarmtimer_enqueue(base, alarm);
>> + hrtimer_start(&alarm->timer, alarm->node.expires,
>> + HRTIMER_MODE_ABS);
>> + }
>
> Similarly, this just seems more like churn, than making the code
> particularly more clear.
I disagree. scoped_guard() is actually superior as it makes it
visually entirely clear what the actual scope of the spin lock protected
code is. That's the whole point.
Especially in alarm_suspend() this would end up with a mix of scoped
guards and open coded spinlock regions. That's obstructing the reading
flow.
I'll bring them back for consistency when applying the series.
Thanks,
tglx
next prev parent reply other threads:[~2025-04-30 6:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-24 14:48 [PATCH 0/3] time: some cleanup for jiffies and alarmtimer Su Hui
2025-04-24 14:48 ` [PATCH 1/3] time/jiffies: change register_refined_jiffies() to void __init Su Hui
2025-04-24 14:48 ` [PATCH 2/3] alarmtimer: remove dead return value in clock2alarm() Su Hui
2025-04-24 14:48 ` [PATCH 3/3] alarmtimer: switch spin_{lock,unlock}_irqsave() to guard() Su Hui
2025-04-24 23:59 ` John Stultz
2025-04-25 2:59 ` Su Hui
2025-04-30 6:58 ` Thomas Gleixner [this message]
2025-04-25 13:04 ` Dan Carpenter
2025-04-27 2:15 ` Su Hui
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=87y0vip23w.ffs@tglx \
--to=tglx@linutronix.de \
--cc=jstultz@google.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sboyd@kernel.org \
--cc=suhui@nfschina.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