@@ -1436,6 +1436,37 @@ static int run_osnoise(void)
1436
1436
static struct cpumask osnoise_cpumask ;
1437
1437
static struct cpumask save_cpumask ;
1438
1438
1439
+ /*
1440
+ * osnoise_sleep - sleep until the next period
1441
+ */
1442
+ static void osnoise_sleep (void )
1443
+ {
1444
+ u64 interval ;
1445
+ ktime_t wake_time ;
1446
+
1447
+ mutex_lock (& interface_lock );
1448
+ interval = osnoise_data .sample_period - osnoise_data .sample_runtime ;
1449
+ mutex_unlock (& interface_lock );
1450
+
1451
+ /*
1452
+ * differently from hwlat_detector, the osnoise tracer can run
1453
+ * without a pause because preemption is on.
1454
+ */
1455
+ if (!interval ) {
1456
+ /* Let synchronize_rcu_tasks() make progress */
1457
+ cond_resched_tasks_rcu_qs ();
1458
+ return ;
1459
+ }
1460
+
1461
+ wake_time = ktime_add_us (ktime_get (), interval );
1462
+ __set_current_state (TASK_INTERRUPTIBLE );
1463
+
1464
+ while (schedule_hrtimeout_range (& wake_time , 0 , HRTIMER_MODE_ABS )) {
1465
+ if (kthread_should_stop ())
1466
+ break ;
1467
+ }
1468
+ }
1469
+
1439
1470
/*
1440
1471
* osnoise_main - The osnoise detection kernel thread
1441
1472
*
@@ -1444,30 +1475,10 @@ static struct cpumask save_cpumask;
1444
1475
*/
1445
1476
static int osnoise_main (void * data )
1446
1477
{
1447
- u64 interval ;
1448
1478
1449
1479
while (!kthread_should_stop ()) {
1450
-
1451
1480
run_osnoise ();
1452
-
1453
- mutex_lock (& interface_lock );
1454
- interval = osnoise_data .sample_period - osnoise_data .sample_runtime ;
1455
- mutex_unlock (& interface_lock );
1456
-
1457
- do_div (interval , USEC_PER_MSEC );
1458
-
1459
- /*
1460
- * differently from hwlat_detector, the osnoise tracer can run
1461
- * without a pause because preemption is on.
1462
- */
1463
- if (interval < 1 ) {
1464
- /* Let synchronize_rcu_tasks() make progress */
1465
- cond_resched_tasks_rcu_qs ();
1466
- continue ;
1467
- }
1468
-
1469
- if (msleep_interruptible (interval ))
1470
- break ;
1481
+ osnoise_sleep ();
1471
1482
}
1472
1483
1473
1484
return 0 ;
0 commit comments