Skip to content

Commit 4c2374e

Browse files
glemcoKAGA-KOKO
authored andcommitted
timers/migration: Use scoped_guard on available flag set/clear
Cleanup tmigr_clear_cpu_available() and tmigr_set_cpu_available() to prepare for easier checks on the available flag. Signed-off-by: Gabriele Monaco <gmonaco@redhat.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Frederic Weisbecker <frederic@kernel.org> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Link: https://patch.msgid.link/20251120145653.296659-4-gmonaco@redhat.com
1 parent a048ca5 commit 4c2374e

1 file changed

Lines changed: 17 additions & 17 deletions

File tree

kernel/time/timer_migration.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,17 +1440,17 @@ static int tmigr_clear_cpu_available(unsigned int cpu)
14401440
u64 firstexp;
14411441

14421442
cpumask_clear_cpu(cpu, tmigr_available_cpumask);
1443-
raw_spin_lock_irq(&tmc->lock);
1444-
tmc->available = false;
1445-
WRITE_ONCE(tmc->wakeup, KTIME_MAX);
1443+
scoped_guard(raw_spinlock_irq, &tmc->lock) {
1444+
tmc->available = false;
1445+
WRITE_ONCE(tmc->wakeup, KTIME_MAX);
14461446

1447-
/*
1448-
* CPU has to handle the local events on his own, when on the way to
1449-
* offline; Therefore nextevt value is set to KTIME_MAX
1450-
*/
1451-
firstexp = __tmigr_cpu_deactivate(tmc, KTIME_MAX);
1452-
trace_tmigr_cpu_unavailable(tmc);
1453-
raw_spin_unlock_irq(&tmc->lock);
1447+
/*
1448+
* CPU has to handle the local events on his own, when on the way to
1449+
* offline; Therefore nextevt value is set to KTIME_MAX
1450+
*/
1451+
firstexp = __tmigr_cpu_deactivate(tmc, KTIME_MAX);
1452+
trace_tmigr_cpu_unavailable(tmc);
1453+
}
14541454

14551455
if (firstexp != KTIME_MAX) {
14561456
migrator = cpumask_any(tmigr_available_cpumask);
@@ -1469,13 +1469,13 @@ static int tmigr_set_cpu_available(unsigned int cpu)
14691469
return -EINVAL;
14701470

14711471
cpumask_set_cpu(cpu, tmigr_available_cpumask);
1472-
raw_spin_lock_irq(&tmc->lock);
1473-
trace_tmigr_cpu_available(tmc);
1474-
tmc->idle = timer_base_is_idle();
1475-
if (!tmc->idle)
1476-
__tmigr_cpu_activate(tmc);
1477-
tmc->available = true;
1478-
raw_spin_unlock_irq(&tmc->lock);
1472+
scoped_guard(raw_spinlock_irq, &tmc->lock) {
1473+
trace_tmigr_cpu_available(tmc);
1474+
tmc->idle = timer_base_is_idle();
1475+
if (!tmc->idle)
1476+
__tmigr_cpu_activate(tmc);
1477+
tmc->available = true;
1478+
}
14791479
return 0;
14801480
}
14811481

0 commit comments

Comments
 (0)