@@ -509,6 +509,7 @@ void tick_resume(void)
509
509
510
510
#ifdef CONFIG_SUSPEND
511
511
static DEFINE_RAW_SPINLOCK (tick_freeze_lock );
512
+ static DEFINE_WAIT_OVERRIDE_MAP (tick_freeze_map , LD_WAIT_SLEEP ) ;
512
513
static unsigned int tick_freeze_depth ;
513
514
514
515
/**
@@ -528,9 +529,22 @@ void tick_freeze(void)
528
529
if (tick_freeze_depth == num_online_cpus ()) {
529
530
trace_suspend_resume (TPS ("timekeeping_freeze" ),
530
531
smp_processor_id (), true);
532
+ /*
533
+ * All other CPUs have their interrupts disabled and are
534
+ * suspended to idle. Other tasks have been frozen so there
535
+ * is no scheduling happening. This means that there is no
536
+ * concurrency in the system at this point. Therefore it is
537
+ * okay to acquire a sleeping lock on PREEMPT_RT, such as a
538
+ * spinlock, because the lock cannot be held by other CPUs
539
+ * or threads and acquiring it cannot block.
540
+ *
541
+ * Inform lockdep about the situation.
542
+ */
543
+ lock_map_acquire_try (& tick_freeze_map );
531
544
system_state = SYSTEM_SUSPEND ;
532
545
sched_clock_suspend ();
533
546
timekeeping_suspend ();
547
+ lock_map_release (& tick_freeze_map );
534
548
} else {
535
549
tick_suspend_local ();
536
550
}
@@ -552,8 +566,16 @@ void tick_unfreeze(void)
552
566
raw_spin_lock (& tick_freeze_lock );
553
567
554
568
if (tick_freeze_depth == num_online_cpus ()) {
569
+ /*
570
+ * Similar to tick_freeze(). On resumption the first CPU may
571
+ * acquire uncontended sleeping locks while other CPUs block on
572
+ * tick_freeze_lock.
573
+ */
574
+ lock_map_acquire_try (& tick_freeze_map );
555
575
timekeeping_resume ();
556
576
sched_clock_resume ();
577
+ lock_map_release (& tick_freeze_map );
578
+
557
579
system_state = SYSTEM_RUNNING ;
558
580
trace_suspend_resume (TPS ("timekeeping_freeze" ),
559
581
smp_processor_id (), false);
0 commit comments