@@ -6400,20 +6400,24 @@ static void queue_core_balance(struct rq *rq)
6400
6400
queue_balance_callback (rq , & per_cpu (core_balance_head , rq -> cpu ), sched_core_balance );
6401
6401
}
6402
6402
6403
+ DEFINE_LOCK_GUARD_1 (core_lock , int ,
6404
+ sched_core_lock (* _T -> lock , & _T -> flags ),
6405
+ sched_core_unlock (* _T -> lock , & _T -> flags ),
6406
+ unsigned long flags )
6407
+
6403
6408
static void sched_core_cpu_starting (unsigned int cpu )
6404
6409
{
6405
6410
const struct cpumask * smt_mask = cpu_smt_mask (cpu );
6406
6411
struct rq * rq = cpu_rq (cpu ), * core_rq = NULL ;
6407
- unsigned long flags ;
6408
6412
int t ;
6409
6413
6410
- sched_core_lock ( cpu , & flags );
6414
+ guard ( core_lock )( & cpu );
6411
6415
6412
6416
WARN_ON_ONCE (rq -> core != rq );
6413
6417
6414
6418
/* if we're the first, we'll be our own leader */
6415
6419
if (cpumask_weight (smt_mask ) == 1 )
6416
- goto unlock ;
6420
+ return ;
6417
6421
6418
6422
/* find the leader */
6419
6423
for_each_cpu (t , smt_mask ) {
@@ -6427,7 +6431,7 @@ static void sched_core_cpu_starting(unsigned int cpu)
6427
6431
}
6428
6432
6429
6433
if (WARN_ON_ONCE (!core_rq )) /* whoopsie */
6430
- goto unlock ;
6434
+ return ;
6431
6435
6432
6436
/* install and validate core_rq */
6433
6437
for_each_cpu (t , smt_mask ) {
@@ -6438,29 +6442,25 @@ static void sched_core_cpu_starting(unsigned int cpu)
6438
6442
6439
6443
WARN_ON_ONCE (rq -> core != core_rq );
6440
6444
}
6441
-
6442
- unlock :
6443
- sched_core_unlock (cpu , & flags );
6444
6445
}
6445
6446
6446
6447
static void sched_core_cpu_deactivate (unsigned int cpu )
6447
6448
{
6448
6449
const struct cpumask * smt_mask = cpu_smt_mask (cpu );
6449
6450
struct rq * rq = cpu_rq (cpu ), * core_rq = NULL ;
6450
- unsigned long flags ;
6451
6451
int t ;
6452
6452
6453
- sched_core_lock ( cpu , & flags );
6453
+ guard ( core_lock )( & cpu );
6454
6454
6455
6455
/* if we're the last man standing, nothing to do */
6456
6456
if (cpumask_weight (smt_mask ) == 1 ) {
6457
6457
WARN_ON_ONCE (rq -> core != rq );
6458
- goto unlock ;
6458
+ return ;
6459
6459
}
6460
6460
6461
6461
/* if we're not the leader, nothing to do */
6462
6462
if (rq -> core != rq )
6463
- goto unlock ;
6463
+ return ;
6464
6464
6465
6465
/* find a new leader */
6466
6466
for_each_cpu (t , smt_mask ) {
@@ -6471,7 +6471,7 @@ static void sched_core_cpu_deactivate(unsigned int cpu)
6471
6471
}
6472
6472
6473
6473
if (WARN_ON_ONCE (!core_rq )) /* impossible */
6474
- goto unlock ;
6474
+ return ;
6475
6475
6476
6476
/* copy the shared state to the new leader */
6477
6477
core_rq -> core_task_seq = rq -> core_task_seq ;
@@ -6493,9 +6493,6 @@ static void sched_core_cpu_deactivate(unsigned int cpu)
6493
6493
rq = cpu_rq (t );
6494
6494
rq -> core = core_rq ;
6495
6495
}
6496
-
6497
- unlock :
6498
- sched_core_unlock (cpu , & flags );
6499
6496
}
6500
6497
6501
6498
static inline void sched_core_cpu_dying (unsigned int cpu )
0 commit comments