summaryrefslogtreecommitdiff
path: root/tools/tracing/rtla/src/osnoise_hist.c
diff options
context:
space:
mode:
authorIvan Pravdin <ipravdin.official@gmail.com>2025-11-03 11:19:06 -0500
committerTomas Glozar <tglozar@redhat.com>2025-11-21 10:30:27 +0100
commit7b71f3a6986c93defbb72bb6c143e04122720cb1 (patch)
treef687349796a0056764b03c36f03010eb5f6a5b2d /tools/tracing/rtla/src/osnoise_hist.c
parent49c15794198ff03a4fa844f894f7e5d4bdbffcfc (diff)
rtla: Fix -C/--cgroup interface
Currently, user can only specify cgroup to the tracer's thread the following ways: `-C[cgroup]` `-C[=cgroup]` `--cgroup[=cgroup]` If user tries to specify cgroup as `-C [cgroup]` or `--cgroup [cgroup]`, the parser silently fails and rtla's cgroup is used for the tracer threads. To make interface more user-friendly, allow user to specify cgroup in the aforementioned way, i.e. `-C [cgroup]` and `--cgroup [cgroup]`. Refactor identical logic between -t/--trace and -C/--cgroup into a common function. Change documentation to reflect this user interface change. Fixes: a957cbc02531 ("rtla: Add -C cgroup support") Signed-off-by: Ivan Pravdin <ipravdin.official@gmail.com> Reviewed-by: Tomas Glozar <tglozar@redhat.com> Link: https://lore.kernel.org/r/16132f1565cf5142b5fbd179975be370b529ced7.1762186418.git.ipravdin.official@gmail.com [ use capital letter in subject, as required by tracing subsystem ] Signed-off-by: Tomas Glozar <tglozar@redhat.com>
Diffstat (limited to 'tools/tracing/rtla/src/osnoise_hist.c')
-rw-r--r--tools/tracing/rtla/src/osnoise_hist.c26
1 files changed, 7 insertions, 19 deletions
diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src/osnoise_hist.c
index 1d841a3056bc..1d06ea47b663 100644
--- a/tools/tracing/rtla/src/osnoise_hist.c
+++ b/tools/tracing/rtla/src/osnoise_hist.c
@@ -414,9 +414,9 @@ static void osnoise_hist_usage(void)
static const char * const msg[] = {
"",
" usage: rtla osnoise hist [-h] [-D] [-d s] [-a us] [-p us] [-r us] [-s us] [-S us] \\",
- " [-T us] [-t[file]] [-e sys[:event]] [--filter <filter>] [--trigger <trigger>] \\",
+ " [-T us] [-t [file]] [-e sys[:event]] [--filter <filter>] [--trigger <trigger>] \\",
" [-c cpu-list] [-H cpu-list] [-P priority] [-b N] [-E N] [--no-header] [--no-summary] \\",
- " [--no-index] [--with-zeros] [-C[=cgroup_name]] [--warm-up]",
+ " [--no-index] [--with-zeros] [-C [cgroup_name]] [--warm-up]",
"",
" -h/--help: print this menu",
" -a/--auto: set automatic trace mode, stopping the session if argument in us sample is hit",
@@ -427,10 +427,10 @@ static void osnoise_hist_usage(void)
" -T/--threshold us: the minimum delta to be considered a noise",
" -c/--cpus cpu-list: list of cpus to run osnoise threads",
" -H/--house-keeping cpus: run rtla control threads only on the given cpus",
- " -C/--cgroup[=cgroup_name]: set cgroup, if no cgroup_name is passed, the rtla's cgroup will be inherited",
+ " -C/--cgroup [cgroup_name]: set cgroup, if no cgroup_name is passed, the rtla's cgroup will be inherited",
" -d/--duration time[s|m|h|d]: duration of the session",
" -D/--debug: print debug info",
- " -t/--trace[file]: save the stopped trace to [file|osnoise_trace.txt]",
+ " -t/--trace [file]: save the stopped trace to [file|osnoise_trace.txt]",
" -e/--event <sys:event>: enable the <sys:event> in the trace instance, multiple -e are allowed",
" --filter <filter>: enable a trace event filter to the previous -e event",
" --trigger <trigger>: enable a trace event trigger to the previous -e event",
@@ -551,13 +551,7 @@ static struct common_params
break;
case 'C':
params->common.cgroup = 1;
- if (!optarg) {
- /* will inherit this cgroup */
- params->common.cgroup_name = NULL;
- } else if (*optarg == '=') {
- /* skip the = */
- params->common.cgroup_name = ++optarg;
- }
+ params->common.cgroup_name = parse_optional_arg(argc, argv);
break;
case 'D':
config_debug = 1;
@@ -619,14 +613,8 @@ static struct common_params
params->threshold = get_llong_from_str(optarg);
break;
case 't':
- if (optarg) {
- if (optarg[0] == '=')
- trace_output = &optarg[1];
- else
- trace_output = &optarg[0];
- } else if (optind < argc && argv[optind][0] != '0')
- trace_output = argv[optind];
- else
+ trace_output = parse_optional_arg(argc, argv);
+ if (!trace_output)
trace_output = "osnoise_trace.txt";
break;
case '0': /* no header */