rtla/timerlat: Add -A/--aligned CLI option
Subsystems (3)
Tomas Glozar
maintainerPATCH 1/3 rtla/timerlat: Add -A/--aligned CLI option
Add a new option, -A/--aligned, that enables timerlat thread alignment implemented on the kernel-side in commit 4245bf4dc58f ("tracing/osnoise:
Add option to align tlat threads"). The option takes an argument, representing alignment between timerlat threads in microseconds.
The feature is modeled after the option of the same name in the cyclictest tool.
---
This patchset depends on "rtla: Migrate to libsubcmd for command line option parsing"
- https://lore.kernel.org/linux-trace-kernel/[email protected]/T/
as it uses the new CLI implementation. That in turn depends on the test patches:
- https://lore.kernel.org/linux-trace-kernel/[email protected]/T/
- https://lore.kernel.org/linux-trace-kernel/[email protected]/
as it touches tests, as well as a fix touching the CLI:
- https://lore.kernel.org/linux-trace-kernel/[email protected]/
tools/tracing/rtla/src/cli.c | 2 + tools/tracing/rtla/src/cli_p.h | 17 ++++ tools/tracing/rtla/src/common.h | 8 ++ tools/tracing/rtla/src/osnoise.c | 149 ++++++++++++++++++++++++++++++ tools/tracing/rtla/src/osnoise.h | 6 ++ tools/tracing/rtla/src/timerlat.c | 18 ++++ tools/tracing/rtla/src/timerlat.h | 2 + 7 files changed, 202 insertions(+)
tools/tracing/rtla/src/cli.c +2 -0
@@ -248,6 +248,7 @@ struct common_params *timerlat_top_parse_args(int argc, char **argv)RTLA_OPT_USER_THREADS ,RTLA_OPT_KERNEL_THREADS ,RTLA_OPT_USER_LOAD , +TIMERLAT_OPT_ALIGNED ,OPT_GROUP ("Output:" ), TIMERLAT_OPT_NANO,
@@ -362,6 +363,7 @@ struct common_params *timerlat_hist_parse_args(int argc, char **argv)RTLA_OPT_USER_THREADS ,RTLA_OPT_KERNEL_THREADS ,RTLA_OPT_USER_LOAD , +TIMERLAT_OPT_ALIGNED ,OPT_GROUP ("Histogram Options:" ), HIST_OPT_BUCKET_SIZE,
tools/tracing/rtla/src/cli_p.h +17 -0
@@ -447,6 +447,10 @@ static int opt_osnoise_on_end_cb(const struct option *opt, const char *arg, int "set the stack format (truncate, skip, full)", \ opt_stack_format_cb) +#define TIMERLAT_OPT_ALIGNED OPT_CALLBACK('A', "aligned", params, "us", \ + "align thread wakeups to a specific offset", \ + opt_timerlat_align_cb) +/* * Callback functions for command line options for timerlat tools */
@@ -608,6 +612,19 @@ static int opt_stack_format_cb(const struct option *opt, const char *arg, int unreturn 0 ; } +static int opt_timerlat_align_cb (const struct option *opt,const char *arg,int unset) +{ +struct timerlat_params *params = opt->value; + +if (unset || !arg) +return -1 ; + + params->timerlat_align = true; + params->timerlat_align_us =get_llong_from_str ((char *)arg); + +return 0 ; +} +/* * Macros for command line options specific to histogram-based tools */
tools/tracing/rtla/src/common.h +8 -0
@@ -51,6 +51,14 @@ struct osnoise_context {/* -1 as init value because 0 is off */ int orig_opt_workload;int opt_workload; + +/* -1 as init value because 0 is off */ +int orig_opt_timerlat_align; +int opt_timerlat_align; + +/* 0 as init value */ +unsigned long long orig_timerlat_align_us; +unsigned long long timerlat_align_us; };extern volatile int stop_tracing;
tools/tracing/rtla/src/osnoise.c +149 -0
173 lines not on this page · raw message
tools/tracing/rtla/src/osnoise.h +6 -0
@@ -49,6 +49,12 @@ void osnoise_restore_print_stack(struct osnoise_context *context);int osnoise_set_print_stack (struct osnoise_context *context,long long print_stack); +int osnoise_set_timerlat_align_us (struct osnoise_context *context, +long long timerlat_align_us); +void osnoise_restore_timerlat_align_us (struct osnoise_context *context); + +int osnoise_set_timerlat_align (struct osnoise_context *context,bool onoff); +int osnoise_set_irq_disable (struct osnoise_context *context,bool onoff);void osnoise_report_missed_events (struct osnoise_tool *tool);int osnoise_apply_config (struct osnoise_tool *tool,struct osnoise_params *params);
tools/tracing/rtla/src/timerlat.c +18 -0
@@ -77,6 +77,24 @@ timerlat_apply_config(struct osnoise_tool *tool, struct timerlat_params *params) goto out_err; } + retval =osnoise_set_timerlat_align (tool->context, params->timerlat_align); +if (retval && params->timerlat_align) { +/* +* We might be running on a kernel that does not support timerlat align. +* Unless user requested it explicitly, ignore the error. +*/ +err_msg ("Failed to enable timerlat align\n" ); + goto out_err; + } + +if (params->timerlat_align) { + retval =osnoise_set_timerlat_align_us (tool->context, params->timerlat_align_us); +if (retval) { +err_msg ("Failed to set timerlat align us\n" ); + goto out_err; + } + } +/* * If the user did not specify a type of thread, try user-threads first. * Fall back to kernel threads otherwise.
tools/tracing/rtla/src/timerlat.h +2 -0
@@ -31,6 +31,8 @@ struct timerlat_params {enum timerlat_tracing_mode mode;const char *bpf_action_program;enum stack_format stack_format; +bool timerlat_align; +unsigned long long timerlat_align_us; };#define to_timerlat_params (ptr) container_of(ptr, struct timerlat_params, common)
Signature · 1 line
2.54.0
Tomas Glozar
maintainerPATCH 2/3 rtla/tests: Add unit tests for -A/--aligned option
Add both parse_args() and opt_* tests for the newly added -A/--aligned option.
--- .../rtla/tests/unit/cli_opt_callback.c | 12 +++++++++++ .../rtla/tests/unit/timerlat_hist_cli.c | 20 +++++++++++++++++++ .../rtla/tests/unit/timerlat_top_cli.c | 20 +++++++++++++++++++ 3 files changed, 52 insertions(+)
tools/tracing/rtla/tests/unit/cli_opt_callback.c +12 -0
@@ -545,6 +545,17 @@ START_TEST(test_opt_nano_cb) }END_TEST +START_TEST (test_opt_timerlat_align_cb ) +{ +struct timerlat_params params = {0 }; +const struct option opt =TEST_CALLBACK (¶ms, opt_timerlat_align_cb); + +ck_assert_int_eq (opt_timerlat_align_cb (&opt,"500" ,0 ),0 ); +ck_assert (params.timerlat_align); +ck_assert_int_eq (params.timerlat_align_us,500 ); +} +END_TEST +START_TEST (test_opt_stack_format_cb ) {int stack_format =0 ;
@@ -689,6 +700,7 @@ Suite *cli_opt_callback_suite(void)tcase_add_test (tc, test_opt_nano_cb);tcase_add_test (tc, test_opt_stack_format_cb);tcase_add_exit_test (tc, test_opt_stack_format_cb_invalid,EXIT_FAILURE ); +tcase_add_test (tc, test_opt_timerlat_align_cb);suite_add_tcase (s, tc); tc =tcase_create ("histogram" );
tools/tracing/rtla/tests/unit/timerlat_hist_cli.c +20 -0
@@ -373,6 +373,24 @@ START_TEST(test_user_threads_long) }END_TEST +START_TEST (test_aligned_short ) +{ +PARSE_ARGS ("timerlat" ,"hist" ,"-A" ,"500" ); + +ck_assert (tlat_params->timerlat_align); +ck_assert_int_eq (tlat_params->timerlat_align_us,500 ); +} +END_TEST + +START_TEST (test_aligned_long ) +{ +PARSE_ARGS ("timerlat" ,"hist" ,"--aligned" ,"500" ); + +ck_assert (tlat_params->timerlat_align); +ck_assert_int_eq (tlat_params->timerlat_align_us,500 ); +} +END_TEST +/* Histogram Options */ START_TEST (test_bucket_size_short )
@@ -654,6 +672,8 @@ Suite *timerlat_hist_cli_suite(void)tcase_add_test (tc, test_user_load_long);tcase_add_test (tc, test_user_threads_short);tcase_add_test (tc, test_user_threads_long); +tcase_add_test (tc, test_aligned_short); +tcase_add_test (tc, test_aligned_long);suite_add_tcase (s, tc); tc =tcase_create ("histogram_options" );
tools/tracing/rtla/tests/unit/timerlat_top_cli.c +20 -0
@@ -373,6 +373,24 @@ START_TEST(test_user_threads_long) }END_TEST +START_TEST (test_aligned_short ) +{ +PARSE_ARGS ("timerlat" ,"top" ,"-A" ,"500" ); + +ck_assert (tlat_params->timerlat_align); +ck_assert_int_eq (tlat_params->timerlat_align_us,500 ); +} +END_TEST + +START_TEST (test_aligned_long ) +{ +PARSE_ARGS ("timerlat" ,"top" ,"--aligned" ,"500" ); + +ck_assert (tlat_params->timerlat_align); +ck_assert_int_eq (tlat_params->timerlat_align_us,500 ); +} +END_TEST +/* Output */ START_TEST (test_nano_short )
@@ -596,6 +614,8 @@ Suite *timerlat_top_cli_suite(void)tcase_add_test (tc, test_user_load_long);tcase_add_test (tc, test_user_threads_short);tcase_add_test (tc, test_user_threads_long); +tcase_add_test (tc, test_aligned_short); +tcase_add_test (tc, test_aligned_long);suite_add_tcase (s, tc); tc =tcase_create ("output" );
Signature · 1 line
2.54.0
Tomas Glozar
maintainerPATCH 3/3 Documentation/rtla: Add -A/--aligned option
In reply to Tomas GlozarCover the newly added -A/--aligned option that aligns timerlat threads using the corresponding feature of the timerlat tracer.
A note is added to clarify what alignment means, similar to the note in the tracer implementation in commit 4245bf4dc58f ("tracing/osnoise: Add option to align tlat threads").
--- Documentation/tools/rtla/common_timerlat_options.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+)
Documentation/tools/rtla/common_timerlat_options.txt +12 -0
@@ -95,3 +95,15 @@ * **full** Print the entire stack trace, including unknown addresses. For unknown addresses, the raw pointer is printed. + +**-A**, **--aligned** *us* + + Align wake-up of timerlat threads to a set offset in microseconds. + + The alignment will be applied when the threads wake up at the start of tracing while + the timer for the first cycle is armed. Each thread sets its timer to the wake-up time + of the previous thread plus the alignment. + + This option may be used with any non-negative argument, including zero, which will + align threads so that they wake up all at the same time. +
Signature · 1 line
2.54.0