Pull locking fix from Ingo Molnar: - Revert a commit to spinlock cleanup guards that got caught up in the subtle limitations & fragility of guards (again...) and caused a regression (Peter Zijlstra) * tag 'locking-urgent-2026-08-30' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: locking: Revert switching guards to _irq_{disable,enable}()
Unified · Split
| @@ -572,12 +572,12 @@ DECLARE_LOCK_GUARD_1_ATTRS(raw_spinlock_nested, __acquires(_T), __releases(*(raw · 571 unmodified lines | |||
| 572 | #define class_raw_spinlock_nested_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(raw_spinlock_nested, _T) | 572 | #define class_raw_spinlock_nested_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(raw_spinlock_nested, _T) |
| 573 | 573 | ||
| 574 | DEFINE_LOCK_GUARD_1(raw_spinlock_irq, raw_spinlock_t, | 574 | DEFINE_LOCK_GUARD_1(raw_spinlock_irq, raw_spinlock_t, |
| 575 | raw_spin_lock_irq_disable(_T->lock), | 575 | raw_spin_lock_irq(_T->lock), |
| 576 | raw_spin_unlock_irq_enable(_T->lock)) | 576 | raw_spin_unlock_irq(_T->lock)) |
| 577 | DECLARE_LOCK_GUARD_1_ATTRS(raw_spinlock_irq, __acquires(_T), __releases(*(raw_spinlock_t **)_T)) | 577 | DECLARE_LOCK_GUARD_1_ATTRS(raw_spinlock_irq, __acquires(_T), __releases(*(raw_spinlock_t **)_T)) |
| 578 | #define class_raw_spinlock_irq_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(raw_spinlock_irq, _T) | 578 | #define class_raw_spinlock_irq_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(raw_spinlock_irq, _T) |
| 579 | 579 | ||
| 580 | DEFINE_LOCK_GUARD_1_COND(raw_spinlock_irq, _try, raw_spin_trylock_irq_disable(_T->lock)) | 580 | DEFINE_LOCK_GUARD_1_COND(raw_spinlock_irq, _try, raw_spin_trylock_irq(_T->lock)) |
| 581 | DECLARE_LOCK_GUARD_1_ATTRS(raw_spinlock_irq_try, __acquires(_T), __releases(*(raw_spinlock_t **)_T)) | 581 | DECLARE_LOCK_GUARD_1_ATTRS(raw_spinlock_irq_try, __acquires(_T), __releases(*(raw_spinlock_t **)_T)) |
| 582 | #define class_raw_spinlock_irq_try_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(raw_spinlock_irq_try, _T) | 582 | #define class_raw_spinlock_irq_try_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(raw_spinlock_irq_try, _T) |
| 583 | 583 | ||
| @@ -592,13 +592,14 @@ DECLARE_LOCK_GUARD_1_ATTRS(raw_spinlock_bh_try, __acquires(_T), __releases(*(raw · 8 unmodified lines | |||
| 592 | #define class_raw_spinlock_bh_try_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(raw_spinlock_bh_try, _T) | 592 | #define class_raw_spinlock_bh_try_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(raw_spinlock_bh_try, _T) |
| 593 | 593 | ||
| 594 | DEFINE_LOCK_GUARD_1(raw_spinlock_irqsave, raw_spinlock_t, | 594 | DEFINE_LOCK_GUARD_1(raw_spinlock_irqsave, raw_spinlock_t, |
| 595 | raw_spin_lock_irq_disable(_T->lock), | 595 | raw_spin_lock_irqsave(_T->lock, _T->flags), |
| 596 | raw_spin_unlock_irq_enable(_T->lock)) | 596 | raw_spin_unlock_irqrestore(_T->lock, _T->flags), |
| 597 | unsigned long flags) | ||
| 597 | DECLARE_LOCK_GUARD_1_ATTRS(raw_spinlock_irqsave, __acquires(_T), __releases(*(raw_spinlock_t **)_T)) | 598 | DECLARE_LOCK_GUARD_1_ATTRS(raw_spinlock_irqsave, __acquires(_T), __releases(*(raw_spinlock_t **)_T)) |
| 598 | #define class_raw_spinlock_irqsave_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(raw_spinlock_irqsave, _T) | 599 | #define class_raw_spinlock_irqsave_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(raw_spinlock_irqsave, _T) |
| 599 | 600 | ||
| 600 | DEFINE_LOCK_GUARD_1_COND(raw_spinlock_irqsave, _try, | 601 | DEFINE_LOCK_GUARD_1_COND(raw_spinlock_irqsave, _try, |
| 601 | raw_spin_trylock_irq_disable(_T->lock)) | 602 | raw_spin_trylock_irqsave(_T->lock, _T->flags)) |
| 602 | DECLARE_LOCK_GUARD_1_ATTRS(raw_spinlock_irqsave_try, __acquires(_T), __releases(*(raw_spinlock_t **)_T)) | 603 | DECLARE_LOCK_GUARD_1_ATTRS(raw_spinlock_irqsave_try, __acquires(_T), __releases(*(raw_spinlock_t **)_T)) |
| 603 | #define class_raw_spinlock_irqsave_try_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(raw_spinlock_irqsave_try, _T) | 604 | #define class_raw_spinlock_irqsave_try_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(raw_spinlock_irqsave_try, _T) |
| 604 | 605 | ||
| @@ -617,13 +618,13 @@ DECLARE_LOCK_GUARD_1_ATTRS(spinlock_try, __acquires(_T), __releases(*(spinlock_t · 12 unmodified lines | |||
| 617 | #define class_spinlock_try_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(spinlock_try, _T) | 618 | #define class_spinlock_try_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(spinlock_try, _T) |
| 618 | 619 | ||
| 619 | DEFINE_LOCK_GUARD_1(spinlock_irq, spinlock_t, | 620 | DEFINE_LOCK_GUARD_1(spinlock_irq, spinlock_t, |
| 620 | spin_lock_irq_disable(_T->lock), | 621 | spin_lock_irq(_T->lock), |
| 621 | spin_unlock_irq_enable(_T->lock)) | 622 | spin_unlock_irq(_T->lock)) |
| 622 | DECLARE_LOCK_GUARD_1_ATTRS(spinlock_irq, __acquires(_T), __releases(*(spinlock_t **)_T)) | 623 | DECLARE_LOCK_GUARD_1_ATTRS(spinlock_irq, __acquires(_T), __releases(*(spinlock_t **)_T)) |
| 623 | #define class_spinlock_irq_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(spinlock_irq, _T) | 624 | #define class_spinlock_irq_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(spinlock_irq, _T) |
| 624 | 625 | ||
| 625 | DEFINE_LOCK_GUARD_1_COND(spinlock_irq, _try, | 626 | DEFINE_LOCK_GUARD_1_COND(spinlock_irq, _try, |
| 626 | spin_trylock_irq_disable(_T->lock)) | 627 | spin_trylock_irq(_T->lock)) |
| 627 | DECLARE_LOCK_GUARD_1_ATTRS(spinlock_irq_try, __acquires(_T), __releases(*(spinlock_t **)_T)) | 628 | DECLARE_LOCK_GUARD_1_ATTRS(spinlock_irq_try, __acquires(_T), __releases(*(spinlock_t **)_T)) |
| 628 | #define class_spinlock_irq_try_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(spinlock_irq_try, _T) | 629 | #define class_spinlock_irq_try_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(spinlock_irq_try, _T) |
| 629 | 630 | ||
| @@ -639,13 +640,14 @@ DECLARE_LOCK_GUARD_1_ATTRS(spinlock_bh_try, __acquires(_T), __releases(*(spinloc · 9 unmodified lines | |||
| 639 | #define class_spinlock_bh_try_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(spinlock_bh_try, _T) | 640 | #define class_spinlock_bh_try_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(spinlock_bh_try, _T) |
| 640 | 641 | ||
| 641 | DEFINE_LOCK_GUARD_1(spinlock_irqsave, spinlock_t, | 642 | DEFINE_LOCK_GUARD_1(spinlock_irqsave, spinlock_t, |
| 642 | spin_lock_irq_disable(_T->lock), | 643 | spin_lock_irqsave(_T->lock, _T->flags), |
| 643 | spin_unlock_irq_enable(_T->lock)) | 644 | spin_unlock_irqrestore(_T->lock, _T->flags), |
| 645 | unsigned long flags) | ||
| 644 | DECLARE_LOCK_GUARD_1_ATTRS(spinlock_irqsave, __acquires(_T), __releases(*(spinlock_t **)_T)) | 646 | DECLARE_LOCK_GUARD_1_ATTRS(spinlock_irqsave, __acquires(_T), __releases(*(spinlock_t **)_T)) |
| 645 | #define class_spinlock_irqsave_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(spinlock_irqsave, _T) | 647 | #define class_spinlock_irqsave_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(spinlock_irqsave, _T) |
| 646 | 648 | ||
| 647 | DEFINE_LOCK_GUARD_1_COND(spinlock_irqsave, _try, | 649 | DEFINE_LOCK_GUARD_1_COND(spinlock_irqsave, _try, |
| 648 | spin_trylock_irq_disable(_T->lock)) | 650 | spin_trylock_irqsave(_T->lock, _T->flags)) |
| 649 | DECLARE_LOCK_GUARD_1_ATTRS(spinlock_irqsave_try, __acquires(_T), __releases(*(spinlock_t **)_T)) | 651 | DECLARE_LOCK_GUARD_1_ATTRS(spinlock_irqsave_try, __acquires(_T), __releases(*(spinlock_t **)_T)) |
| 650 | #define class_spinlock_irqsave_try_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(spinlock_irqsave_try, _T) | 652 | #define class_spinlock_irqsave_try_constructor(_T) WITH_LOCK_GUARD_1_ATTRS(spinlock_irqsave_try, _T) |
| 651 | 653 | ||
| @@ -7253,7 +7253,7 @@ static bool distribute_cfs_runtime(struct cfs_bandwidth *cfs_b) · 7252 unmodified lines | |||
| 7253 | * period the timer is deactivated until scheduling resumes; cfs_b->idle is | 7253 | * period the timer is deactivated until scheduling resumes; cfs_b->idle is |
| 7254 | * used to track this state. | 7254 | * used to track this state. |
| 7255 | */ | 7255 | */ |
| 7256 | static int do_sched_cfs_period_timer(struct cfs_bandwidth *cfs_b, int overrun) | 7256 | static int do_sched_cfs_period_timer(struct cfs_bandwidth *cfs_b, int overrun, unsigned long flags) |
| 7257 | __must_hold(&cfs_b->lock) | 7257 | __must_hold(&cfs_b->lock) |
| 7258 | { | 7258 | { |
| 7259 | int throttled; | 7259 | int throttled; |
| @@ -7288,10 +7288,10 @@ static int do_sched_cfs_period_timer(struct cfs_bandwidth *cfs_b, int overrun) · 28 unmodified lines | |||
| 7288 | * This check is repeated as we release cfs_b->lock while we unthrottle. | 7288 | * This check is repeated as we release cfs_b->lock while we unthrottle. |
| 7289 | */ | 7289 | */ |
| 7290 | while (throttled && cfs_b->runtime > 0) { | 7290 | while (throttled && cfs_b->runtime > 0) { |
| 7291 | raw_spin_unlock_irq_enable(&cfs_b->lock); | 7291 | raw_spin_unlock_irqrestore(&cfs_b->lock, flags); |
| 7292 | /* we can't nest cfs_b->lock while distributing bandwidth */ | 7292 | /* we can't nest cfs_b->lock while distributing bandwidth */ |
| 7293 | throttled = distribute_cfs_runtime(cfs_b); | 7293 | throttled = distribute_cfs_runtime(cfs_b); |
| 7294 | raw_spin_lock_irq_disable(&cfs_b->lock); | 7294 | raw_spin_lock_irqsave(&cfs_b->lock, flags); |
| 7295 | } | 7295 | } |
| 7296 | 7296 | ||
| 7297 | /* | 7297 | /* |
| @@ -7399,7 +7399,7 @@ static __always_inline void return_cfs_rq_runtime(struct cfs_rq *cfs_rq) · 101 unmodified lines | |||
| 7399 | static void do_sched_cfs_slack_timer(struct cfs_bandwidth *cfs_b) | 7399 | static void do_sched_cfs_slack_timer(struct cfs_bandwidth *cfs_b) |
| 7400 | { | 7400 | { |
| 7401 | /* confirm we're still not at a refresh boundary */ | 7401 | /* confirm we're still not at a refresh boundary */ |
| 7402 | scoped_guard(raw_spinlock_irq, &cfs_b->lock) { | 7402 | scoped_guard(raw_spinlock_irqsave, &cfs_b->lock) { |
| 7403 | u64 runtime = 0, slice = sched_cfs_bandwidth_slice(); | 7403 | u64 runtime = 0, slice = sched_cfs_bandwidth_slice(); |
| 7404 | 7404 | ||
| 7405 | cfs_b->slack_started = false; | 7405 | cfs_b->slack_started = false; |
| @@ -7484,14 +7484,14 @@ static enum hrtimer_restart sched_cfs_period_timer(struct hrtimer *timer) · 78 unmodified lines | |||
| 7484 | int idle = 0; | 7484 | int idle = 0; |
| 7485 | int count = 0; | 7485 | int count = 0; |
| 7486 | 7486 | ||
| 7487 | guard(raw_spinlock_irq)(&cfs_b->lock); | 7487 | CLASS(raw_spinlock_irqsave, cfsb_guard)(&cfs_b->lock); |
| 7488 | 7488 | ||
| 7489 | for (;;) { | 7489 | for (;;) { |
| 7490 | overrun = hrtimer_forward_now(timer, cfs_b->period); | 7490 | overrun = hrtimer_forward_now(timer, cfs_b->period); |
| 7491 | if (!overrun) | 7491 | if (!overrun) |
| 7492 | break; | 7492 | break; |
| 7493 | 7493 | ||
| 7494 | idle = do_sched_cfs_period_timer(cfs_b, overrun); | 7494 | idle = do_sched_cfs_period_timer(cfs_b, overrun, cfsb_guard.flags); |
| 7495 | 7495 | ||
| 7496 | if (++count > 3) { | 7496 | if (++count > 3) { |
| 7497 | u64 new, old = ktime_to_ns(cfs_b->period); | 7497 | u64 new, old = ktime_to_ns(cfs_b->period); |