| 0ad45018 | 16-Jul-2026 |
Tomas Glozar <tglozar@redhat.com> |
rtla/cli: Unify and improve handling of invalid option arguments
The current handling of invalid command line option arguments is inconsistent:
- opt_llong_callback() treats non-numerical input the
rtla/cli: Unify and improve handling of invalid option arguments
The current handling of invalid command line option arguments is inconsistent:
- opt_llong_callback() treats non-numerical input the same as "-1", which might or might not be rejected later. - opt_int_callback() returns -1 on non-numerical input without an error message, which makes parsing fail silently (libsubcmd will automatically print the usage of the option only, no error message). - custom callbacks abort command line parsing using fatal(), which displays an error message and exits, without libsubcmd printing the usage.
Unify this such that all invalid options, regardless of the format, print an error message similar to the out of range case:
Error: --opt: 'value' is not a valid XY
followed by the usage of the option, e.g.:
$ rtla timerlat hist --period=1us Error: --period: '1us' is not a valid number
Usage: rtla timerlat hist [<options>] [-h|--help]
-p, --period <us> timerlat period in us
As this is a libsubcmd help path, all option parsing failures now return the exit code of 129 (help).
The unified handling is implemented using a new error message helper, opt_err(), which is called from two new CLI-specific parsing functions, strtoll_safe() and strtoi_safe(), as well as from custom helpers.
Option callback tests are updated to cover the new behavior.
Assisted-by: Claude:claude-opus-4-6 Reviewed-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260716144901.1187474-1-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 92a33d5b | 10-Jul-2026 |
Tomas Glozar <tglozar@redhat.com> |
rtla/cli: Unify and improve range validation logic
Several RTLA options do range validation inside the CLI parser layer (e.g. -p/--period). When RTLA migrated CLI parsing to libsubcmd, this logic wa
rtla/cli: Unify and improve range validation logic
Several RTLA options do range validation inside the CLI parser layer (e.g. -p/--period). When RTLA migrated CLI parsing to libsubcmd, this logic was moved unchanged inside opt_*() callbacks.
Unify range validation so that all options use two newly added functions, check_llong_range() and check_int_range(), to validate the range.
The new range validation returns -1 from opt_*() callbacks rather than hard-exit with fatal(), allowing the help message for the specific option to be automatically displayed by libsubcmd logic.
Many options no longer need a custom callback, as they use the unified range validation of opt_llong_callback() and opt_int_callback(). Validation for several other options is improved:
- timerlat -p/--period: lower bound raised from 1 to 100 us to match the kernel's timerlat_min_period in trace_osnoise.c. - timerlat -A/--aligned: reject negative values. - timerlat --deepest-idle-state: add range [-1, INT_MAX]; previously, values <= -2 were read as "option not set". - timerlat -p/--period, -A/--aligned, -b/--bucket-size: properly reject negative values instead of passing them to the tracer.
Remove unit tests for removed callbacks and test the new range validation functionality of opt_llong_callback() and opt_int_callback().
Update runtime tests for histogram options to account for the new error messages and exit value.
Assisted-by: Claude:claude-opus-4-6 Link: https://lore.kernel.org/r/20260710131554.338335-1-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| ab43bd72 | 09-Jul-2026 |
Tomas Glozar <tglozar@redhat.com> |
rtla/tests: Test all tracer options in runtime tests
Currently, runtime tests only test the osnoise period option (-p/--period of rtla-osnoise tools, backed by /sys/kernel/tracing/osnoise/period_us)
rtla/tests: Test all tracer options in runtime tests
Currently, runtime tests only test the osnoise period option (-p/--period of rtla-osnoise tools, backed by /sys/kernel/tracing/osnoise/period_us), using the check_with_osnoise_options function together with a hack relying on long period (pre-set) timing out if RTLA fails to reset it to the default value.
Extend tracer option testing to all options used by RTLA; test both RTLA setting the default option by pre-setting the tracer to a different value and user-requested value.
The tests are done using a script that reads the tracer values inside an --on-threshold action, like existing tests for runtime behavior already do. check_with_osnoise_option is modified to support grep filters, so that it can be used together with the script pattern.
Assisted-by: Claude:claude-opus-4-6 Link: https://lore.kernel.org/r/20260709091755.58265-1-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 05f4bcb2 | 29-Jun-2026 |
Tomas Glozar <tglozar@redhat.com> |
rtla: Add unit tests for CLI with unset
Test parsing of command line that sets an option and then unsets it back to the default value in all tools.
Only two CLI tests are added for each tool: short
rtla: Add unit tests for CLI with unset
Test parsing of command line that sets an option and then unsets it back to the default value in all tools.
Only two CLI tests are added for each tool: short period option (-p ... --no-period) and long period option (--period ... --no-period). The logic specific for individual options is tested in opt callback tests already.
Reviewed-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260629083654.1548925-3-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 596a9bed | 28-May-2026 |
Tomas Glozar <tglozar@redhat.com> |
rtla/tests: Add unit tests for CLI option callbacks
In addition to testing all tool_parse_args() functions, test also all callbacks used for parsing custom option formats.
The callbacks represent a
rtla/tests: Add unit tests for CLI option callbacks
In addition to testing all tool_parse_args() functions, test also all callbacks used for parsing custom option formats.
The callbacks represent a middle layer between the parsing functions and utility functions dedicated to checking specific argument formats, for example, scheduling class and duration. Callback tests are run before parsing functions to make sure any issue in the former is reported before it is encountered through the latter.
Tests verify both successful parsing and proper rejection of invalid inputs (via exit tests). To enable testing static callbacks, a pragma once guard is added to timerlat.h for safe inclusion by cli_p.h.
Add dependency of UNIT_TESTS_IN on LIBSUBCMD_INCLUDES, as the new test file tests/unit/cli_opt_callback.c includes cli_p.h which includes subcmd/parse-options.h.
Link: https://lore.kernel.org/r/20260528103254.2990068-7-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 244d0cbf | 28-May-2026 |
Tomas Glozar <tglozar@redhat.com> |
rtla/tests: Add unit tests for _parse_args() functions
Add a test suite for the _parse_args() function of each tool that checks the params structures (struct common_params, struct osnoise_params, st
rtla/tests: Add unit tests for _parse_args() functions
Add a test suite for the _parse_args() function of each tool that checks the params structures (struct common_params, struct osnoise_params, struct timerlat_params) returned by them for correctness.
One test case is added per option, as well as a few special cases for tricky combinations of options. Test cases are ordered the same as the option arrays and help message to allow easy checking of whether all options are covered.
This should help clarify what the proper command line behavior of RTLA is in case there are holes in the documentation and verify that the intended behavior is implemented correctly.
A few necessary changes to the unit tests were done as part of this commit:
- Unit tests now also link to libsubcmd and its dependencies. - A new global variable in_unit_test is added to RTLA's CLI interface, causing it to skip check for root if running in unit tests. This allows the CLI unit tests to run as non-root, like existing unit tests.
There is quite a lot of duplication, some of it is mitigated with macros, but partially it is intentional so that future changes in behavior are tracked across tools.
Link: https://lore.kernel.org/r/20260528103254.2990068-6-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 5d9af63e | 28-May-2026 |
Tomas Glozar <tglozar@redhat.com> |
rtla: Parse cmdline using libsubcmd
Instead of using getopt_long() directly to parse the command line arguments given to an RTLA tool, use libsubcmd's parse_options().
Utilizing libsubcmd for parsi
rtla: Parse cmdline using libsubcmd
Instead of using getopt_long() directly to parse the command line arguments given to an RTLA tool, use libsubcmd's parse_options().
Utilizing libsubcmd for parsing command line arguments has several benefits:
- A help message is automatically generated by libsubcmd from the specification, removing the need of writing it by hand. - Options are sorted into groups based on which part of tracing (CPU, thread, auto-analysis, tuning, histogram) they relate to. - Common parsing patterns for numerical and boolean values now share code, with the target variable being stored in the option array.
To avoid duplication of the option parsing logic, RTLA-specific macros defining struct option values are created:
- RTLA_OPT_* for options common to all tools - OSNOISE_OPT_* and TIMERLAT_OPT_* for options specific to osnoise/timerlat tools - HIST_OPT_* macros for options specific to histogram-based tools.
Individual *_parse_args() functions then construct an array out of these macros that is then passed to libsubcmd's parse_options().
All code specific to command line options parsing is moved out of the individual tool files into a new file, cli.c, which also contains the contents of the rtla.c file. A private header, cli_p.h, is added alongside the public header cli.h, so that unit tests are able to test statically declared option callbacks.
Minor changes:
- The return value of tool-level help option changes to 129, as this is the value set by libsubcmd; this is reflected in affected test cases. The implementation of help for command-level and tracer-level help is set to 129 as well for consistency, and the change is reflected in exit value documentation. - Related to the above, {rtla,osnoise,timerlat}_usage() are marked __noreturn and exit() is removed from after they are called for cleaner code. - The error messages for invalid argument for options --dma-latency and -E/--entries were corrected, fixing off-by-one in the limits.
Note that unsetting options (using --no-<opt> syntax) is currently not implemented for options that use custom callbacks. For --irq and --thread, it will never be implemented, as they conflict with already existing --no-irq and --no-thread with a different meaning.
Assisted-by: Composer:composer-1.5 Link: https://lore.kernel.org/r/20260528103254.2990068-5-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 6a1700b2 | 26-May-2026 |
Tomas Glozar <tglozar@redhat.com> |
rtla/tests: Add runtime tests for restoring continue flag
In case an action preceding the continue action fails, not only the continue flag should not be set, it should be unset if it was set from a
rtla/tests: Add runtime tests for restoring continue flag
In case an action preceding the continue action fails, not only the continue flag should not be set, it should be unset if it was set from a previous run of actions_perform().
Add a runtime test to both osnoise and timerlat tools that checks that this works properly by creating a temporary file.
Link: https://lore.kernel.org/r/20260526102523.2662391-4-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| ad5b50a0 | 26-May-2026 |
Tomas Glozar <tglozar@redhat.com> |
rtla/tests: Run runtime tests in temporary directory
Create a temporary directory before each test case to serve as working directory during the duration of the test.
This prevents littering of the
rtla/tests: Run runtime tests in temporary directory
Create a temporary directory before each test case to serve as working directory during the duration of the test.
This prevents littering of the original working directory as well as allows tests to use it to avoid path conflicts.
In order not to break already existing tests, also add a new "testdir" variable containing the directory where the test file is located. This is then used to locate artifacts used during testing like BPF programs and scripts for checking the tracer threads.
Link: https://lore.kernel.org/r/20260526102523.2662391-3-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| a92bd1a2 | 26-May-2026 |
Tomas Glozar <tglozar@redhat.com> |
rtla/tests: Add unit test for restoring continue flag
In case an action preceding the continue action fails, not only the continue flag should not be set, it should be unset if it was set from a pre
rtla/tests: Add unit test for restoring continue flag
In case an action preceding the continue action fails, not only the continue flag should not be set, it should be unset if it was set from a previous run of actions_perform().
Add a unit test to check if this is implemented correctly.
Link: https://lore.kernel.org/r/20260526102523.2662391-2-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| e5d8f227 | 24-Apr-2026 |
Tomas Glozar <tglozar@redhat.com> |
rtla/tests: Add unit tests for actions module
Add unit tests covering all functions in the actions module, including both valid and invalid inputs and all action types, except for actions_perform(),
rtla/tests: Add unit tests for actions module
Add unit tests covering all functions in the actions module, including both valid and invalid inputs and all action types, except for actions_perform(), where only shell and continue actions are tested.
To support testing multiple modules, the unit test build was modified so that it links the entire rtla-in.o file. For this to work, the main() function in rtla.c was declared weak, so that the unit test main is able to override it.
Other included minor changes to unit tests are:
- Make unit test output verbose to show which tests are being run, now that we have more than 3 tests. - Add unit_tests file to .gitignore. - Split unit test sources to one file per test suite, and keep only main() function in unit_tests.c. - Fix Makefile dependencies so that "make unit-tests" will rebuild the binary with the changes in the commit.
Also with the linking the entire rtla-in.o file, it now has rtla's nr_cpus symbol, so the declaration in utils unit tests is made extern.
Assisted-by: Composer:composer-2-fast Link: https://lore.kernel.org/r/20260424140244.958495-1-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 117a366c | 23-Apr-2026 |
Tomas Glozar <tglozar@redhat.com> |
rtla/tests: Add runtime tests for -C/--cgroup
Add a new script check-cgroup-match.sh that retrieves the cgroup of the main rtla process and compares it to the cgroup of the rtla workload threads.
A
rtla/tests: Add runtime tests for -C/--cgroup
Add a new script check-cgroup-match.sh that retrieves the cgroup of the main rtla process and compares it to the cgroup of the rtla workload threads.
Add a new test based on this script, for both osnoise and timerlat tools, testing the variant of -C without argument (which sets the cgroup of the workload to the cgroup of the rtla main process).
Note that this has to be tested in kernel mode to be significant for timerlat tool, as user workloads inherit the parent rtla process cgroup even without the option.
Reviewed-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260423130558.882022-10-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| a98dad63 | 23-Apr-2026 |
Tomas Glozar <tglozar@redhat.com> |
rtla/tests: Add runtime test for -k and -u options
Add runtime test for rtla-timerlat's -k/--kernel-threads and -u/--user-threads options using get_workload_pids.sh to check whether the appropriate
rtla/tests: Add runtime test for -k and -u options
Add runtime test for rtla-timerlat's -k/--kernel-threads and -u/--user-threads options using get_workload_pids.sh to check whether the appropriate threads are being created.
The tests are implemented for both top and hist. Additionally, all tests related to timerlat threads are moved to a separate section in the test files. The latter is also done for rtla-osnoise tests.
Reviewed-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260423130558.882022-9-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 66c1d48d | 23-Apr-2026 |
Tomas Glozar <tglozar@redhat.com> |
rtla/tests: Add runtime test for -H/--house-keeping
Add a runtime test for -H/--house-keeping option for both osnoise and timerlat tools, with affinity checking similar to what is done for -c/--cpus
rtla/tests: Add runtime test for -H/--house-keeping
Add a runtime test for -H/--house-keeping option for both osnoise and timerlat tools, with affinity checking similar to what is done for -c/--cpus.
Reviewed-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260423130558.882022-8-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 287ff55a | 23-Apr-2026 |
Tomas Glozar <tglozar@redhat.com> |
rtla/tests: Cover all hist options in runtime tests
Cover all options regarding histogram formatting for both rtla-osnoise-hist and rtla-timerlat-hist tools. All options also have output checking us
rtla/tests: Cover all hist options in runtime tests
Cover all options regarding histogram formatting for both rtla-osnoise-hist and rtla-timerlat-hist tools. All options also have output checking using positive or negative match, except for -b/--bucket-size and -E/--entries, which cannot be tested in isolated due to the output depending on the actual data collected.
Old -E/--entries test for rtla-osnoise was replaced with a new one equivalent to the timerlat one.
Reviewed-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260423130558.882022-7-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| f78ba48f | 23-Apr-2026 |
Tomas Glozar <tglozar@redhat.com> |
rtla/tests: Extend timerlat top --aa-only coverage
rtla-timerlat-top's --aa-only option is currently only tested for return value.
Extend the tests to also check that only auto-analysis is being do
rtla/tests: Extend timerlat top --aa-only coverage
rtla-timerlat-top's --aa-only option is currently only tested for return value.
Extend the tests to also check that only auto-analysis is being done via a negative match for the "Timer Latency" text in the top header, and further split the test case into two:
- one test case for --aa-only stopping on threshold - one test case for --aa-only exiting without threshold being hit
For both cases, the expected output ("analyzing it" or "Max latency was" respectively) is checked against in addition to the negative match.
Reviewed-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260423130558.882022-6-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 31664637 | 23-Apr-2026 |
Tomas Glozar <tglozar@redhat.com> |
rtla/tests: Use negative match when testing --aa-only
For testing the -a/--auto option in timerlat tool, the string "analyzing it" is matched against to make sure auto-analysis was triggered.
Use t
rtla/tests: Use negative match when testing --aa-only
For testing the -a/--auto option in timerlat tool, the string "analyzing it" is matched against to make sure auto-analysis was triggered.
Use the same string as a negative match for --aa-only option test.
Reviewed-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260423130558.882022-5-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 7f7ad23b | 23-Apr-2026 |
Tomas Glozar <tglozar@redhat.com> |
rtla/tests: Check -c/--cpus thread affinity
RTLA runtime tests verify the -c/--cpus options, but do not check whether the correct affinity is actually applied.
Add a script named check-cpus.sh that
rtla/tests: Check -c/--cpus thread affinity
RTLA runtime tests verify the -c/--cpus options, but do not check whether the correct affinity is actually applied.
Add a script named check-cpus.sh that retrieves the affinity of all workload threads and use it to check the -c/--cpus option for both osnoise and timerlat tools.
Also add missing -c/--cpus test for osnoise.
Reviewed-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260423130558.882022-4-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| d18fd5a3 | 23-Apr-2026 |
Tomas Glozar <tglozar@redhat.com> |
rtla/tests: Add get_workload_pids() helper
RTLA runtime tests that check workload processes (currently the test case "verify -P/--priority" of timerlat.t and "verify the --priority/-P param" of osno
rtla/tests: Add get_workload_pids() helper
RTLA runtime tests that check workload processes (currently the test case "verify -P/--priority" of timerlat.t and "verify the --priority/-P param" of osnoise.t) use "pgrep timerlatu/" or "pgrep osnoise/" respectively to identify the workload.
Make them more robust by adding a get_workload_pids() helper that finds the main rtla process and returns the PIDs of all siblings other than the test script itself, plus all child processes of kthreadd that have the osnoise/timerlat kthread pattern comm.
This filters out any spurious processes not related to the running test that happen to have "timerlatu/" or "osnoise/" in their command, for example, a user grepping the same names at the time of the running of the test.
Reviewed-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260423130558.882022-3-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 115b06a0 | 06-Mar-2026 |
Costa Shulyupin <costa.shul@redhat.com> |
tools/rtla: Consolidate nr_cpus usage across all tools
sysconf(_SC_NPROCESSORS_CONF) (via get_nprocs_conf) reflects cpu_possible_mask, which is fixed at boot time, so querying it repeatedly is unnec
tools/rtla: Consolidate nr_cpus usage across all tools
sysconf(_SC_NPROCESSORS_CONF) (via get_nprocs_conf) reflects cpu_possible_mask, which is fixed at boot time, so querying it repeatedly is unnecessary.
Replace multiple calls to sysconf(_SC_NPROCESSORS_CONF) with a single global nr_cpus variable initialized once at startup.
`#pragma once` in timerlat_u.h is needed for pre-C23 compilers to avoid redefinition errors.
Signed-off-by: Costa Shulyupin <costa.shul@redhat.com> Link: https://lore.kernel.org/r/20260306194953.2511960-2-costa.shul@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|