mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-25 20:05:39 +00:00
rtla/timerlat: Make user-space threads the default
After ther -u addition, most of the known users are setting it. And it makes sense, as it adds more information, and inherits the default setup for the threads - e.g., cgroups configs. Thus, if the user-space interface is available, enable -u. Otherwise, use the in-kernel thread. Add the -k option to allow the user to request kernel-threads. Link: https://lkml.kernel.org/r/9241d3089de4091b124f780ed832a0e6646cadaa.1713968967.git.bristot@kernel.org Cc: Jonathan Corbet <corbet@lwn.net> Cc: Juri Lelli <juri.lelli@redhat.com> Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
This commit is contained in:
parent
cdbf71962b
commit
fb9e90a67e
3 changed files with 61 additions and 7 deletions
|
@ -27,12 +27,16 @@
|
||||||
*cyclictest* sets this value to *0* by default, use **--dma-latency** *0* to have
|
*cyclictest* sets this value to *0* by default, use **--dma-latency** *0* to have
|
||||||
similar results.
|
similar results.
|
||||||
|
|
||||||
|
**-k**, **--kernel-threads**
|
||||||
|
|
||||||
|
Use timerlat kernel-space threads, in contrast of **-u**.
|
||||||
|
|
||||||
**-u**, **--user-threads**
|
**-u**, **--user-threads**
|
||||||
|
|
||||||
Set timerlat to run without a workload, and then dispatches user-space workloads
|
Set timerlat to run without a workload, and then dispatches user-space workloads
|
||||||
to wait on the timerlat_fd. Once the workload is awakes, it goes to sleep again
|
to wait on the timerlat_fd. Once the workload is awakes, it goes to sleep again
|
||||||
adding so the measurement for the kernel-to-user and user-to-kernel to the tracer
|
adding so the measurement for the kernel-to-user and user-to-kernel to the tracer
|
||||||
output.
|
output. **--user-threads** will be used unless the user specify **-k**.
|
||||||
|
|
||||||
**-U**, **--user-load**
|
**-U**, **--user-load**
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ struct timerlat_hist_params {
|
||||||
int no_aa;
|
int no_aa;
|
||||||
int dump_tasks;
|
int dump_tasks;
|
||||||
int user_workload;
|
int user_workload;
|
||||||
|
int kernel_workload;
|
||||||
int user_hist;
|
int user_hist;
|
||||||
cpu_set_t hk_cpu_set;
|
cpu_set_t hk_cpu_set;
|
||||||
struct sched_attr sched_param;
|
struct sched_attr sched_param;
|
||||||
|
@ -628,7 +629,7 @@ static void timerlat_hist_usage(char *usage)
|
||||||
" usage: [rtla] timerlat hist [-h] [-q] [-d s] [-D] [-n] [-a us] [-p us] [-i us] [-T us] [-s us] \\",
|
" usage: [rtla] timerlat hist [-h] [-q] [-d s] [-D] [-n] [-a us] [-p us] [-i us] [-T us] [-s us] \\",
|
||||||
" [-t[=file]] [-e sys[:event]] [--filter <filter>] [--trigger <trigger>] [-c cpu-list] [-H cpu-list]\\",
|
" [-t[=file]] [-e sys[:event]] [--filter <filter>] [--trigger <trigger>] [-c cpu-list] [-H cpu-list]\\",
|
||||||
" [-P priority] [-E N] [-b N] [--no-irq] [--no-thread] [--no-header] [--no-summary] \\",
|
" [-P priority] [-E N] [-b N] [--no-irq] [--no-thread] [--no-header] [--no-summary] \\",
|
||||||
" [--no-index] [--with-zeros] [--dma-latency us] [-C[=cgroup_name]] [--no-aa] [--dump-task] [-u]",
|
" [--no-index] [--with-zeros] [--dma-latency us] [-C[=cgroup_name]] [--no-aa] [--dump-task] [-u|-k]",
|
||||||
" [--warm-up s]",
|
" [--warm-up s]",
|
||||||
"",
|
"",
|
||||||
" -h/--help: print this menu",
|
" -h/--help: print this menu",
|
||||||
|
@ -664,7 +665,8 @@ static void timerlat_hist_usage(char *usage)
|
||||||
" f:prio - use SCHED_FIFO with prio",
|
" f:prio - use SCHED_FIFO with prio",
|
||||||
" d:runtime[us|ms|s]:period[us|ms|s] - use SCHED_DEADLINE with runtime and period",
|
" d:runtime[us|ms|s]:period[us|ms|s] - use SCHED_DEADLINE with runtime and period",
|
||||||
" in nanoseconds",
|
" in nanoseconds",
|
||||||
" -u/--user-threads: use rtla user-space threads instead of in-kernel timerlat threads",
|
" -u/--user-threads: use rtla user-space threads instead of kernel-space timerlat threads",
|
||||||
|
" -k/--kernel-threads: use timerlat kernel-space threads instead of rtla user-space threads",
|
||||||
" -U/--user-load: enable timerlat for user-defined user-space workload",
|
" -U/--user-load: enable timerlat for user-defined user-space workload",
|
||||||
" --warm-up s: let the workload run for s seconds before collecting data",
|
" --warm-up s: let the workload run for s seconds before collecting data",
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -728,6 +730,7 @@ static struct timerlat_hist_params
|
||||||
{"thread", required_argument, 0, 'T'},
|
{"thread", required_argument, 0, 'T'},
|
||||||
{"trace", optional_argument, 0, 't'},
|
{"trace", optional_argument, 0, 't'},
|
||||||
{"user-threads", no_argument, 0, 'u'},
|
{"user-threads", no_argument, 0, 'u'},
|
||||||
|
{"kernel-threads", no_argument, 0, 'k'},
|
||||||
{"user-load", no_argument, 0, 'U'},
|
{"user-load", no_argument, 0, 'U'},
|
||||||
{"event", required_argument, 0, 'e'},
|
{"event", required_argument, 0, 'e'},
|
||||||
{"no-irq", no_argument, 0, '0'},
|
{"no-irq", no_argument, 0, '0'},
|
||||||
|
@ -748,7 +751,7 @@ static struct timerlat_hist_params
|
||||||
/* getopt_long stores the option index here. */
|
/* getopt_long stores the option index here. */
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
|
|
||||||
c = getopt_long(argc, argv, "a:c:C::b:d:e:E:DhH:i:np:P:s:t::T:uU0123456:7:8:9\1\2:",
|
c = getopt_long(argc, argv, "a:c:C::b:d:e:E:DhH:i:knp:P:s:t::T:uU0123456:7:8:9\1\2:",
|
||||||
long_options, &option_index);
|
long_options, &option_index);
|
||||||
|
|
||||||
/* detect the end of the options. */
|
/* detect the end of the options. */
|
||||||
|
@ -831,6 +834,9 @@ static struct timerlat_hist_params
|
||||||
case 'i':
|
case 'i':
|
||||||
params->stop_us = get_llong_from_str(optarg);
|
params->stop_us = get_llong_from_str(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'k':
|
||||||
|
params->kernel_workload = 1;
|
||||||
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
params->output_divisor = 1;
|
params->output_divisor = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -942,6 +948,9 @@ static struct timerlat_hist_params
|
||||||
if (!params->stop_us && !params->stop_total_us)
|
if (!params->stop_us && !params->stop_total_us)
|
||||||
params->no_aa = 1;
|
params->no_aa = 1;
|
||||||
|
|
||||||
|
if (params->kernel_workload && params->user_workload)
|
||||||
|
timerlat_hist_usage("--kernel-threads and --user-threads are mutually exclusive!");
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1017,6 +1026,22 @@ timerlat_hist_apply_config(struct osnoise_tool *tool, struct timerlat_hist_param
|
||||||
auto_house_keeping(¶ms->monitored_cpus);
|
auto_house_keeping(¶ms->monitored_cpus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the user did not specify a type of thread, try user-threads first.
|
||||||
|
* Fall back to kernel threads otherwise.
|
||||||
|
*/
|
||||||
|
if (!params->kernel_workload && !params->user_workload) {
|
||||||
|
retval = tracefs_file_exists(NULL, "osnoise/per_cpu/cpu0/timerlat_fd");
|
||||||
|
if (retval) {
|
||||||
|
debug_msg("User-space interface detected, setting user-threads\n");
|
||||||
|
params->user_workload = 1;
|
||||||
|
params->user_hist = 1;
|
||||||
|
} else {
|
||||||
|
debug_msg("User-space interface not detected, setting kernel-threads\n");
|
||||||
|
params->kernel_workload = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (params->user_hist) {
|
if (params->user_hist) {
|
||||||
retval = osnoise_set_workload(tool->context, 0);
|
retval = osnoise_set_workload(tool->context, 0);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
|
|
|
@ -44,6 +44,7 @@ struct timerlat_top_params {
|
||||||
int hk_cpus;
|
int hk_cpus;
|
||||||
int user_top;
|
int user_top;
|
||||||
int user_workload;
|
int user_workload;
|
||||||
|
int kernel_workload;
|
||||||
int pretty_output;
|
int pretty_output;
|
||||||
int warmup;
|
int warmup;
|
||||||
cpu_set_t hk_cpu_set;
|
cpu_set_t hk_cpu_set;
|
||||||
|
@ -445,7 +446,7 @@ static void timerlat_top_usage(char *usage)
|
||||||
"",
|
"",
|
||||||
" usage: rtla timerlat [top] [-h] [-q] [-a us] [-d s] [-D] [-n] [-p us] [-i us] [-T us] [-s us] \\",
|
" usage: rtla timerlat [top] [-h] [-q] [-a us] [-d s] [-D] [-n] [-p us] [-i us] [-T us] [-s us] \\",
|
||||||
" [[-t[=file]] [-e sys[:event]] [--filter <filter>] [--trigger <trigger>] [-c cpu-list] [-H cpu-list]\\",
|
" [[-t[=file]] [-e sys[:event]] [--filter <filter>] [--trigger <trigger>] [-c cpu-list] [-H cpu-list]\\",
|
||||||
" [-P priority] [--dma-latency us] [--aa-only us] [-C[=cgroup_name]] [-u] [--warm-up s]",
|
" [-P priority] [--dma-latency us] [--aa-only us] [-C[=cgroup_name]] [-u|-k] [--warm-up s]",
|
||||||
"",
|
"",
|
||||||
" -h/--help: print this menu",
|
" -h/--help: print this menu",
|
||||||
" -a/--auto: set automatic trace mode, stopping the session if argument in us latency is hit",
|
" -a/--auto: set automatic trace mode, stopping the session if argument in us latency is hit",
|
||||||
|
@ -474,7 +475,8 @@ static void timerlat_top_usage(char *usage)
|
||||||
" f:prio - use SCHED_FIFO with prio",
|
" f:prio - use SCHED_FIFO with prio",
|
||||||
" d:runtime[us|ms|s]:period[us|ms|s] - use SCHED_DEADLINE with runtime and period",
|
" d:runtime[us|ms|s]:period[us|ms|s] - use SCHED_DEADLINE with runtime and period",
|
||||||
" in nanoseconds",
|
" in nanoseconds",
|
||||||
" -u/--user-threads: use rtla user-space threads instead of in-kernel timerlat threads",
|
" -u/--user-threads: use rtla user-space threads instead of kernel-space timerlat threads",
|
||||||
|
" -k/--kernel-threads: use timerlat kernel-space threads instead of rtla user-space threads",
|
||||||
" -U/--user-load: enable timerlat for user-defined user-space workload",
|
" -U/--user-load: enable timerlat for user-defined user-space workload",
|
||||||
" --warm-up s: let the workload run for s seconds before collecting data",
|
" --warm-up s: let the workload run for s seconds before collecting data",
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -536,6 +538,7 @@ static struct timerlat_top_params
|
||||||
{"thread", required_argument, 0, 'T'},
|
{"thread", required_argument, 0, 'T'},
|
||||||
{"trace", optional_argument, 0, 't'},
|
{"trace", optional_argument, 0, 't'},
|
||||||
{"user-threads", no_argument, 0, 'u'},
|
{"user-threads", no_argument, 0, 'u'},
|
||||||
|
{"kernel-threads", no_argument, 0, 'k'},
|
||||||
{"user-load", no_argument, 0, 'U'},
|
{"user-load", no_argument, 0, 'U'},
|
||||||
{"trigger", required_argument, 0, '0'},
|
{"trigger", required_argument, 0, '0'},
|
||||||
{"filter", required_argument, 0, '1'},
|
{"filter", required_argument, 0, '1'},
|
||||||
|
@ -550,7 +553,7 @@ static struct timerlat_top_params
|
||||||
/* getopt_long stores the option index here. */
|
/* getopt_long stores the option index here. */
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
|
|
||||||
c = getopt_long(argc, argv, "a:c:C::d:De:hH:i:np:P:qs:t::T:uU0:1:2:345:6:",
|
c = getopt_long(argc, argv, "a:c:C::d:De:hH:i:knp:P:qs:t::T:uU0:1:2:345:6:",
|
||||||
long_options, &option_index);
|
long_options, &option_index);
|
||||||
|
|
||||||
/* detect the end of the options. */
|
/* detect the end of the options. */
|
||||||
|
@ -635,6 +638,9 @@ static struct timerlat_top_params
|
||||||
case 'i':
|
case 'i':
|
||||||
params->stop_us = get_llong_from_str(optarg);
|
params->stop_us = get_llong_from_str(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'k':
|
||||||
|
params->kernel_workload = true;
|
||||||
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
params->output_divisor = 1;
|
params->output_divisor = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -729,6 +735,9 @@ static struct timerlat_top_params
|
||||||
if (params->no_aa && params->aa_only)
|
if (params->no_aa && params->aa_only)
|
||||||
timerlat_top_usage("--no-aa and --aa-only are mutually exclusive!");
|
timerlat_top_usage("--no-aa and --aa-only are mutually exclusive!");
|
||||||
|
|
||||||
|
if (params->kernel_workload && params->user_workload)
|
||||||
|
timerlat_top_usage("--kernel-threads and --user-threads are mutually exclusive!");
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -807,6 +816,22 @@ timerlat_top_apply_config(struct osnoise_tool *top, struct timerlat_top_params *
|
||||||
auto_house_keeping(¶ms->monitored_cpus);
|
auto_house_keeping(¶ms->monitored_cpus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the user did not specify a type of thread, try user-threads first.
|
||||||
|
* Fall back to kernel threads otherwise.
|
||||||
|
*/
|
||||||
|
if (!params->kernel_workload && !params->user_workload) {
|
||||||
|
retval = tracefs_file_exists(NULL, "osnoise/per_cpu/cpu0/timerlat_fd");
|
||||||
|
if (retval) {
|
||||||
|
debug_msg("User-space interface detected, setting user-threads\n");
|
||||||
|
params->user_workload = 1;
|
||||||
|
params->user_top = 1;
|
||||||
|
} else {
|
||||||
|
debug_msg("User-space interface not detected, setting kernel-threads\n");
|
||||||
|
params->kernel_workload = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (params->user_top) {
|
if (params->user_top) {
|
||||||
retval = osnoise_set_workload(top->context, 0);
|
retval = osnoise_set_workload(top->context, 0);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
|
|
Loading…
Reference in a new issue