Skip to content

Commit 9d95b7e

Browse files
Daniel Bristot de Oliveiragregkh
authored andcommitted
tracing/osnoise: Make osnoise_main to sleep for microseconds
[ Upstream commit dd99035 ] 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 Cc: Ingo Molnar <mingo@redhat.com> Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 4d28896 commit 9d95b7e

1 file changed

Lines changed: 32 additions & 21 deletions

File tree

‎kernel/trace/trace_osnoise.c‎

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,37 @@ static int run_osnoise(void)
12491249
static struct cpumask osnoise_cpumask;
12501250
static struct cpumask save_cpumask;
12511251

1252+
/*
1253+
* osnoise_sleep - sleep until the next period
1254+
*/
1255+
static void osnoise_sleep(void)
1256+
{
1257+
u64 interval;
1258+
ktime_t wake_time;
1259+
1260+
mutex_lock(&interface_lock);
1261+
interval = osnoise_data.sample_period - osnoise_data.sample_runtime;
1262+
mutex_unlock(&interface_lock);
1263+
1264+
/*
1265+
* differently from hwlat_detector, the osnoise tracer can run
1266+
* without a pause because preemption is on.
1267+
*/
1268+
if (!interval) {
1269+
/* Let synchronize_rcu_tasks() make progress */
1270+
cond_resched_tasks_rcu_qs();
1271+
return;
1272+
}
1273+
1274+
wake_time = ktime_add_us(ktime_get(), interval);
1275+
__set_current_state(TASK_INTERRUPTIBLE);
1276+
1277+
while (schedule_hrtimeout_range(&wake_time, 0, HRTIMER_MODE_ABS)) {
1278+
if (kthread_should_stop())
1279+
break;
1280+
}
1281+
}
1282+
12521283
/*
12531284
* osnoise_main - The osnoise detection kernel thread
12541285
*
@@ -1257,30 +1288,10 @@ static struct cpumask save_cpumask;
12571288
*/
12581289
static int osnoise_main(void *data)
12591290
{
1260-
u64 interval;
12611291

12621292
while (!kthread_should_stop()) {
1263-
12641293
run_osnoise();
1265-
1266-
mutex_lock(&interface_lock);
1267-
interval = osnoise_data.sample_period - osnoise_data.sample_runtime;
1268-
mutex_unlock(&interface_lock);
1269-
1270-
do_div(interval, USEC_PER_MSEC);
1271-
1272-
/*
1273-
* differently from hwlat_detector, the osnoise tracer can run
1274-
* without a pause because preemption is on.
1275-
*/
1276-
if (interval < 1) {
1277-
/* Let synchronize_rcu_tasks() make progress */
1278-
cond_resched_tasks_rcu_qs();
1279-
continue;
1280-
}
1281-
1282-
if (msleep_interruptible(interval))
1283-
break;
1294+
osnoise_sleep();
12841295
}
12851296

12861297
return 0;

0 commit comments

Comments
 (0)