| 6ea8a206 | 12-Jan-2026 |
Costa Shulyupin <costa.shul@redhat.com> |
rtla: Fix parse_cpu_set() bug introduced by strtoi()
The patch 'Replace atoi() with a robust strtoi()' introduced a bug in parse_cpu_set(), which relies on partial parsing of the input string.
The
rtla: Fix parse_cpu_set() bug introduced by strtoi()
The patch 'Replace atoi() with a robust strtoi()' introduced a bug in parse_cpu_set(), which relies on partial parsing of the input string.
The function parses CPU specifications like '0-3,5' by incrementing a pointer through the string. strtoi() rejects strings with trailing characters, causing parse_cpu_set() to fail on any CPU list with multiple entries.
Restore the original use of atoi() in parse_cpu_set().
Fixes: 7e9dfccf8f11 ("rtla: Replace atoi() with a robust strtoi()") Signed-off-by: Costa Shulyupin <costa.shul@redhat.com> Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Link: https://lore.kernel.org/r/20260112192642.212848-2-costa.shul@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| fb8b8183 | 06-Jan-2026 |
Wander Lairson Costa <wander@redhat.com> |
rtla: Fix parse_cpu_set() return value documentation
Correct the return value documentation for parse_cpu_set() function in utils.c. The comment incorrectly stated that the function returns 1 on suc
rtla: Fix parse_cpu_set() return value documentation
Correct the return value documentation for parse_cpu_set() function in utils.c. The comment incorrectly stated that the function returns 1 on success and 0 on failure, but the actual implementation returns 0 on success and 1 on failure, following the common error-on-nonzero convention used throughout the codebase.
This documentation fix ensures that developers reading the code understand the correct return value semantics and prevents potential misuse of the function's return value in conditional checks.
Signed-off-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260106133655.249887-18-wander@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 33e3c807 | 06-Jan-2026 |
Wander Lairson Costa <wander@redhat.com> |
rtla: Ensure null termination after read operations in utils.c
Add explicit null termination and buffer initialization for read() operations in procfs_is_workload_pid() and get_self_cgroup() functio
rtla: Ensure null termination after read operations in utils.c
Add explicit null termination and buffer initialization for read() operations in procfs_is_workload_pid() and get_self_cgroup() functions. The read() system call does not null-terminate the data it reads, and when the buffer is filled to capacity, subsequent string operations will read past the buffer boundary searching for a null terminator.
In procfs_is_workload_pid(), explicitly set buffer[MAX_PATH-1] to '\0' to ensure the buffer is always null-terminated before passing it to strncmp(). In get_self_cgroup(), use memset() to zero the path buffer before reading, which ensures null termination when retval is less than MAX_PATH. Additionally, set path[MAX_PATH-1] to '\0' after the read to handle the case where the buffer is filled completely.
These defensive buffer handling practices prevent potential buffer overruns and align with the ongoing buffer safety improvements across the rtla codebase.
Signed-off-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260106133655.249887-17-wander@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| af2962d6 | 06-Jan-2026 |
Wander Lairson Costa <wander@redhat.com> |
rtla: Make stop_tracing variable volatile
The stop_tracing global variable is accessed from both the signal handler context and the main program flow without synchronization. This creates a potentia
rtla: Make stop_tracing variable volatile
The stop_tracing global variable is accessed from both the signal handler context and the main program flow without synchronization. This creates a potential race condition where compiler optimizations could cache the variable value in registers, preventing the signal handler's updates from being visible to other parts of the program.
Add the volatile qualifier to stop_tracing in both common.c and common.h to ensure all accesses to this variable bypass compiler optimizations and read directly from memory. This guarantees that when the signal handler sets stop_tracing, the change is immediately visible to the main program loop, preventing potential hangs or delayed shutdown when termination signals are received.
Signed-off-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260106133655.249887-16-wander@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| a0890f9d | 06-Jan-2026 |
Wander Lairson Costa <wander@redhat.com> |
rtla: Fix NULL pointer dereference in actions_parse
The actions_parse() function uses strtok() to tokenize the trigger string, but does not check if the returned token is NULL before passing it to s
rtla: Fix NULL pointer dereference in actions_parse
The actions_parse() function uses strtok() to tokenize the trigger string, but does not check if the returned token is NULL before passing it to strcmp(). If the trigger parameter is an empty string or contains only delimiter characters, strtok() returns NULL, causing strcmp() to dereference a NULL pointer and crash the program.
This issue can be triggered by malformed user input or edge cases in trigger string parsing. Add a NULL check immediately after the strtok() call to validate that a token was successfully extracted before using it. If no token is found, the function now returns -1 to indicate a parsing error.
Signed-off-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260106133655.249887-13-wander@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| f3cc3e4b | 06-Jan-2026 |
Wander Lairson Costa <wander@redhat.com> |
rtla: Remove unused headers
Remove unused includes for <errno.h> and <signal.h> to clean up the code and reduce unnecessary dependencies.
Signed-off-by: Wander Lairson Costa <wander@redhat.com> Lin
rtla: Remove unused headers
Remove unused includes for <errno.h> and <signal.h> to clean up the code and reduce unnecessary dependencies.
Signed-off-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260106133655.249887-12-wander@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| d849f3af | 06-Jan-2026 |
Wander Lairson Costa <wander@redhat.com> |
rtla: Remove redundant memset after calloc
The actions struct is allocated using calloc, which already returns zeroed memory. The subsequent memset call to zero the 'present' member is therefore red
rtla: Remove redundant memset after calloc
The actions struct is allocated using calloc, which already returns zeroed memory. The subsequent memset call to zero the 'present' member is therefore redundant.
Signed-off-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260106133655.249887-10-wander@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 9bf942f3 | 06-Jan-2026 |
Wander Lairson Costa <wander@redhat.com> |
rtla: Use standard exit codes for result enum
The result enum defines custom values for PASSED, ERROR, and FAILED. These values correspond to standard exit codes EXIT_SUCCESS and EXIT_FAILURE.
Upda
rtla: Use standard exit codes for result enum
The result enum defines custom values for PASSED, ERROR, and FAILED. These values correspond to standard exit codes EXIT_SUCCESS and EXIT_FAILURE.
Update the enum to use the standard macros EXIT_SUCCESS and EXIT_FAILURE to improve readability and adherence to standard C practices.
The FAILED value is implicitly assigned EXIT_FAILURE + 1, so there is no need to assign an explicit value.
Signed-off-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260106133655.249887-9-wander@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 7e9dfccf | 06-Jan-2026 |
Wander Lairson Costa <wander@redhat.com> |
rtla: Replace atoi() with a robust strtoi()
The atoi() function does not perform error checking, which can lead to undefined behavior when parsing invalid or out-of-range strings. This can cause iss
rtla: Replace atoi() with a robust strtoi()
The atoi() function does not perform error checking, which can lead to undefined behavior when parsing invalid or out-of-range strings. This can cause issues when parsing user-provided numerical inputs, such as signal numbers, PIDs, or CPU lists.
To address this, introduce a new strtoi() helper function that safely converts a string to an integer. This function validates the input and checks for overflows, returning a negative value on failure.
Replace all calls to atoi() with the new strtoi() function and add proper error handling to make the parsing more robust and prevent potential issues.
Signed-off-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260106133655.249887-5-wander@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 648634d1 | 06-Jan-2026 |
Wander Lairson Costa <wander@redhat.com> |
rtla: Introduce for_each_action() helper
The for loop to iterate over the list of actions is used in more than one place. To avoid code duplication and improve readability, introduce a for_each_acti
rtla: Introduce for_each_action() helper
The for loop to iterate over the list of actions is used in more than one place. To avoid code duplication and improve readability, introduce a for_each_action() helper macro.
Replace the open-coded for loops with the new helper.
Signed-off-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260106133655.249887-4-wander@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 2a3a2533 | 24-Dec-2025 |
Costa Shulyupin <costa.shul@redhat.com> |
tools/rtla: Deduplicate cgroup path opening code
Both set_pid_cgroup() and set_comm_cgroup() functions contain identical code for opening the cgroup.procs file.
Extract this common code into a new
tools/rtla: Deduplicate cgroup path opening code
Both set_pid_cgroup() and set_comm_cgroup() functions contain identical code for opening the cgroup.procs file.
Extract this common code into a new helper function open_cgroup_procs() to reduce code duplication and improve maintainability.
Signed-off-by: Costa Shulyupin <costa.shul@redhat.com> Link: https://lore.kernel.org/r/20251224125058.1771519-1-costa.shul@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 0576be46 | 09-Dec-2025 |
Costa Shulyupin <costa.shul@redhat.com> |
tools/rtla: Consolidate -H/--house-keeping option parsing
Each rtla tool duplicates parsing of -H/--house-keeping.
Migrate the option parsing from individual tools to the common_parse_options().
S
tools/rtla: Consolidate -H/--house-keeping option parsing
Each rtla tool duplicates parsing of -H/--house-keeping.
Migrate the option parsing from individual tools to the common_parse_options().
Signed-off-by: Costa Shulyupin <costa.shul@redhat.com> Link: https://lore.kernel.org/r/20251209100047.2692515-8-costa.shul@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 5cc90b14 | 09-Dec-2025 |
Costa Shulyupin <costa.shul@redhat.com> |
tools/rtla: Consolidate -P/--priority option parsing
Each rtla tool duplicates parsing of -P/--priority.
Migrate the option parsing from individual tools to the common_parse_options().
Signed-off-
tools/rtla: Consolidate -P/--priority option parsing
Each rtla tool duplicates parsing of -P/--priority.
Migrate the option parsing from individual tools to the common_parse_options().
Signed-off-by: Costa Shulyupin <costa.shul@redhat.com> Link: https://lore.kernel.org/r/20251209100047.2692515-7-costa.shul@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| c93c25fc | 09-Dec-2025 |
Costa Shulyupin <costa.shul@redhat.com> |
tools/rtla: Consolidate -e/--event option parsing
Each rtla tool duplicates parsing of -e/--event.
Migrate the option parsing from individual tools to the common_parse_options().
Signed-off-by: Co
tools/rtla: Consolidate -e/--event option parsing
Each rtla tool duplicates parsing of -e/--event.
Migrate the option parsing from individual tools to the common_parse_options().
Signed-off-by: Costa Shulyupin <costa.shul@redhat.com> Link: https://lore.kernel.org/r/20251209100047.2692515-6-costa.shul@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 76975581 | 09-Dec-2025 |
Costa Shulyupin <costa.shul@redhat.com> |
tools/rtla: Consolidate -d/--duration option parsing
Each rtla tool duplicates parsing of -d/--duration.
Migrate the option parsing from individual tools to the common_parse_options().
Signed-off-
tools/rtla: Consolidate -d/--duration option parsing
Each rtla tool duplicates parsing of -d/--duration.
Migrate the option parsing from individual tools to the common_parse_options().
Signed-off-by: Costa Shulyupin <costa.shul@redhat.com> Link: https://lore.kernel.org/r/20251209100047.2692515-5-costa.shul@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| fd788c49 | 09-Dec-2025 |
Costa Shulyupin <costa.shul@redhat.com> |
tools/rtla: Consolidate -D/--debug option parsing
Each rtla tool duplicates parsing of -D/--debug.
Migrate the option parsing from individual tools to the common_parse_options().
Signed-off-by: Co
tools/rtla: Consolidate -D/--debug option parsing
Each rtla tool duplicates parsing of -D/--debug.
Migrate the option parsing from individual tools to the common_parse_options().
Signed-off-by: Costa Shulyupin <costa.shul@redhat.com> Link: https://lore.kernel.org/r/20251209100047.2692515-4-costa.shul@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| edb23c83 | 09-Dec-2025 |
Costa Shulyupin <costa.shul@redhat.com> |
tools/rtla: Consolidate -C/--cgroup option parsing
Each rtla tool duplicates parsing of -C/--cgroup.
Migrate the option parsing from individual tools to the common_parse_options().
Signed-off-by:
tools/rtla: Consolidate -C/--cgroup option parsing
Each rtla tool duplicates parsing of -C/--cgroup.
Migrate the option parsing from individual tools to the common_parse_options().
Signed-off-by: Costa Shulyupin <costa.shul@redhat.com> Link: https://lore.kernel.org/r/20251209100047.2692515-3-costa.shul@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 28dc4459 | 09-Dec-2025 |
Costa Shulyupin <costa.shul@redhat.com> |
tools/rtla: Consolidate -c/--cpus option parsing
Each rtla tool duplicates parsing of -c/--cpus.
Migrate the option parsing from individual tools to the common_parse_options().
Signed-off-by: Cost
tools/rtla: Consolidate -c/--cpus option parsing
Each rtla tool duplicates parsing of -c/--cpus.
Migrate the option parsing from individual tools to the common_parse_options().
Signed-off-by: Costa Shulyupin <costa.shul@redhat.com> Link: https://lore.kernel.org/r/20251209100047.2692515-2-costa.shul@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| f967d1ec | 26-Nov-2025 |
Tomas Glozar <tglozar@redhat.com> |
rtla/timerlat: Add --bpf-action option
Add option --bpf-action that allows the user to attach an external BPF program that will be executed via BPF tail call on latency threshold overflow.
Executin
rtla/timerlat: Add --bpf-action option
Add option --bpf-action that allows the user to attach an external BPF program that will be executed via BPF tail call on latency threshold overflow.
Executing additional BPF code on latency threshold overflow allows doing low-latency and in-kernel troubleshooting of the cause of the overflow.
The option takes an argument, which is a path to a BPF ELF file expected to contain a function named "action_handler" in a section named "tp/timerlat_action" (the section is necessary for libbpf to assign the correct BPF program type to it).
Link: https://lore.kernel.org/r/20251126144205.331954-3-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 8cd0f08a | 26-Nov-2025 |
Tomas Glozar <tglozar@redhat.com> |
rtla/timerlat: Support tail call from BPF program
Add a map to the rtla-timerlat BPF program that holds a file descriptor of another BPF program, to be executed on threshold overflow.
timerlat_bpf_
rtla/timerlat: Support tail call from BPF program
Add a map to the rtla-timerlat BPF program that holds a file descriptor of another BPF program, to be executed on threshold overflow.
timerlat_bpf_set_action() is added as an interface to set the program.
Link: https://lore.kernel.org/r/20251126144205.331954-2-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| a08e012e | 24-Nov-2025 |
Costa Shulyupin <costa.shul@redhat.com> |
tools/rtla: Add common_usage()
The rtla tools have significant code quadruplication in their usage functions. Each tool implements its own version of the same help text formatting and option descrip
tools/rtla: Add common_usage()
The rtla tools have significant code quadruplication in their usage functions. Each tool implements its own version of the same help text formatting and option descriptions, leading to maintenance overhead and inconsistencies. Documentation/tools/rtla/common_options.rst lists 14 common options.
Add common_usage() infrastructure to consolidate help formatting. Subsequent patches will extend this to handle other common options.
The refactored output is almost identical to the original, with the following changes: - add square brackets to specify optionality: `usage: [rtla] ...` - remove `-q` from timerlat hist because hist tools don't support it - minor spacing
Signed-off-by: Costa Shulyupin <costa.shul@redhat.com> Link: https://lore.kernel.org/r/20251124063204.845425-1-costa.shul@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| c219d4ee | 12-Nov-2025 |
Crystal Wood <crwood@redhat.com> |
rtla: Set stop threshold after all instances are enabled
This avoids startup races where one of the instances hit a threshold before all instances were enabled, and thus tracing stops without the re
rtla: Set stop threshold after all instances are enabled
This avoids startup races where one of the instances hit a threshold before all instances were enabled, and thus tracing stops without the relevant event. In particular, this is not uncommon with the tests that set a very tight threshold and then complain if there's no analysis.
This also ensures that we don't stop tracing during a warmup.
The downside is a small chance of having an event over the threshold early in the output, without stopping on it, which could cause user confusion. This should be less likely if the warmup feature is used, but that doesn't eliminate the race window, just the odds of an unusual spike right at that moment.
Signed-off-by: Crystal Wood <crwood@redhat.com> Link: https://lore.kernel.org/r/20251112152529.956778-6-crwood@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 3138df6f | 12-Nov-2025 |
Crystal Wood <crwood@redhat.com> |
rtla/timerlat: Exit top main loop on any non-zero wait_retval
Comparing to exactly 1 will fail if more than one ring buffer event was seen since the last call to timerlat_bpf_wait(), which can happe
rtla/timerlat: Exit top main loop on any non-zero wait_retval
Comparing to exactly 1 will fail if more than one ring buffer event was seen since the last call to timerlat_bpf_wait(), which can happen in some race scenarios.
Signed-off-by: Crystal Wood <crwood@redhat.com> Link: https://lore.kernel.org/r/20251112152529.956778-5-crwood@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|