Re: [PATCH 07/24] locking: Switch to _irq_{disable,enable}() variants in cleanup guards
Boqun Feng <[email protected]> Mon, 3 Aug 2026 07:09:51 -0700
| Newsgroups | org.kernel.vger.rust-for-linux,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
On Mon, Aug 03, 2026 at 03:55:47PM +0200, Peter Zijlstra wrote:
> On Mon, Aug 03, 2026 at 06:46:19AM -0700, Boqun Feng wrote:
>
> > > What about the _irqsave() guards?
> > >
> > > Is the goal to replace _irqsave guard usage with _irq and then remove
> > > the _irqsave guards?
> > >
> >
> > Yes, that's the goal. I had that in previous version. However in
> > 1abbecd1d2d2 ("sched/fair: Convert cfs bandwidth throttling to use
> > guards"), we have a user that explicitly plays with the .flags in guard.
> > Lyude also spotted that too. We could adjust that user to the new API
> > (Lyude already has the diff for that) but I decided to simply drop that
> > part for now given the current size of the changes. But if you think
> > it's a must for merge this, I will add it.
>
> Well, but this new stuff should be able to clean that up, no?
>
Yeah... I admit that the decision was made based on how much time I
could spend on this cycle, rather than "what the best we can do here".
Thank you. I fold the following.
Regards,
Boqun
> ---
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -7248,7 +7248,7 @@ static bool distribute_cfs_runtime(struc
> * period the timer is deactivated until scheduling resumes; cfs_b->idle is
> * used to track this state.
> */
> -static int do_sched_cfs_period_timer(struct cfs_bandwidth *cfs_b, int overrun, unsigned long flags)
> +static int do_sched_cfs_period_timer(struct cfs_bandwidth *cfs_b, int overrun)
> __must_hold(&cfs_b->lock)
> {
> int throttled;
> @@ -7283,10 +7283,10 @@ static int do_sched_cfs_period_timer(str
> * This check is repeated as we release cfs_b->lock while we unthrottle.
> */
> while (throttled && cfs_b->runtime > 0) {
> - raw_spin_unlock_irqrestore(&cfs_b->lock, flags);
> + raw_spin_unlock_irq_enable(&cfs_b->lock);
> /* we can't nest cfs_b->lock while distributing bandwidth */
> throttled = distribute_cfs_runtime(cfs_b);
> - raw_spin_lock_irqsave(&cfs_b->lock, flags);
> + raw_spin_lock_irq_disable(&cfs_b->lock);
> }
>
> /*
> @@ -7394,7 +7394,7 @@ static __always_inline void return_cfs_r
> static void do_sched_cfs_slack_timer(struct cfs_bandwidth *cfs_b)
> {
> /* confirm we're still not at a refresh boundary */
> - scoped_guard(raw_spinlock_irqsave, &cfs_b->lock) {
> + scoped_guard(raw_spinlock_irq, &cfs_b->lock) {
> u64 runtime = 0, slice = sched_cfs_bandwidth_slice();
>
> cfs_b->slack_started = false;
> @@ -7479,14 +7479,14 @@ static enum hrtimer_restart sched_cfs_pe
> int idle = 0;
> int count = 0;
>
> - CLASS(raw_spinlock_irqsave, cfsb_guard)(&cfs_b->lock);
> + guard(raw_spinlock_irq)(&cfs_b->lock);
>
> for (;;) {
> overrun = hrtimer_forward_now(timer, cfs_b->period);
> if (!overrun)
> break;
>
> - idle = do_sched_cfs_period_timer(cfs_b, overrun, cfsb_guard.flags);
> + idle = do_sched_cfs_period_timer(cfs_b, overrun);
>
> if (++count > 3) {
> u64 new, old = ktime_to_ns(cfs_b->period);