History

tracing/osnoise: Make osnoise_main to sleep for microseconds

osnoise's runtime and period are in the microseconds scale, but it is currently sleeping in the millisecond's scale. This behavior roots in the usage of hwlat as the skeleton for osnoise. Make osnoise to sleep in the microseconds scale. Also, move the sleep to a specialized function. Link: https://lkml.kernel.org/r/302aa6c7bdf2d131719b22901905e9da122a11b2.1645197336.git.bristot@kernel.org

Daniel Bristot de Oliveira committed 4 years ago

Commit dd990351 parent ab2f9931 file · +32 −21Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/trace/trace_osnoise.c+32−21
@@ -1436,6 +1436,37 @@ out: · 1435 unmodified lines
14361436 static struct cpumask osnoise_cpumask;
14371437 static struct cpumask save_cpumask;
14381438
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+
14391470 /*
14401471 * osnoise_main - The osnoise detection kernel thread
14411472 *
@@ -1444,30 +1475,10 @@ static struct cpumask save_cpumask; · 2 unmodified lines
14441475 */
14451476 static int osnoise_main(void *data)
14461477 {
1447− u64 interval;
14481478
14491479 while (!kthread_should_stop()) {
1450−
14511480 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();
14711482 }
14721483
14731484 return 0;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t