summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCosta Shulyupin <costa.shul@redhat.com>2025-12-09 13:00:44 +0300
committerTomas Glozar <tglozar@redhat.com>2026-01-07 17:57:17 +0300
commit76975581fb0eba03820fe312094981c995c225f9 (patch)
treecc2974f541cc2a4780718b08fa6b189d92413b4b
parentfd788c49a90328f5b2edaa87aa5af18648ade718 (diff)
downloadlinux-76975581fb0eba03820fe312094981c995c225f9.tar.xz
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>
-rw-r--r--tools/tracing/rtla/src/common.c8
-rw-r--r--tools/tracing/rtla/src/osnoise_hist.c8
-rw-r--r--tools/tracing/rtla/src/osnoise_top.c8
-rw-r--r--tools/tracing/rtla/src/timerlat_hist.c8
-rw-r--r--tools/tracing/rtla/src/timerlat_top.c8
5 files changed, 11 insertions, 29 deletions
diff --git a/tools/tracing/rtla/src/common.c b/tools/tracing/rtla/src/common.c
index f71cf7c7f4e3..0776f1568d23 100644
--- a/tools/tracing/rtla/src/common.c
+++ b/tools/tracing/rtla/src/common.c
@@ -60,11 +60,12 @@ int common_parse_options(int argc, char **argv, struct common_params *common)
{"cpus", required_argument, 0, 'c'},
{"cgroup", optional_argument, 0, 'C'},
{"debug", no_argument, 0, 'D'},
+ {"duration", required_argument, 0, 'd'},
{0, 0, 0, 0}
};
opterr = 0;
- c = getopt_long(argc, argv, "c:C::D", long_options, NULL);
+ c = getopt_long(argc, argv, "c:C::Dd:", long_options, NULL);
opterr = 1;
switch (c) {
@@ -80,6 +81,11 @@ int common_parse_options(int argc, char **argv, struct common_params *common)
case 'D':
config_debug = 1;
break;
+ case 'd':
+ common->duration = parse_seconds_duration(optarg);
+ if (!common->duration)
+ fatal("Invalid -d duration");
+ break;
default:
optind = saved_state;
return 0;
diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src/osnoise_hist.c
index c9422b596622..f34c88fd57e2 100644
--- a/tools/tracing/rtla/src/osnoise_hist.c
+++ b/tools/tracing/rtla/src/osnoise_hist.c
@@ -485,7 +485,6 @@ static struct common_params
{"auto", required_argument, 0, 'a'},
{"bucket-size", required_argument, 0, 'b'},
{"entries", required_argument, 0, 'E'},
- {"duration", required_argument, 0, 'd'},
{"house-keeping", required_argument, 0, 'H'},
{"help", no_argument, 0, 'h'},
{"period", required_argument, 0, 'p'},
@@ -512,7 +511,7 @@ static struct common_params
if (common_parse_options(argc, argv, &params->common))
continue;
- c = getopt_long(argc, argv, "a:b:d:e:E:hH:p:P:r:s:S:t::T:01234:5:6:7:",
+ c = getopt_long(argc, argv, "a:b:e:E:hH:p:P:r:s:S:t::T:01234:5:6:7:",
long_options, NULL);
/* detect the end of the options. */
@@ -538,11 +537,6 @@ static struct common_params
params->common.hist.bucket_size >= 1000000)
fatal("Bucket size needs to be > 0 and <= 1000000");
break;
- case 'd':
- params->common.duration = parse_seconds_duration(optarg);
- if (!params->common.duration)
- fatal("Invalid -D duration");
- break;
case 'e':
tevent = trace_event_alloc(optarg);
if (!tevent)
diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/osnoise_top.c
index 8d49042d10f0..695c6ecf0098 100644
--- a/tools/tracing/rtla/src/osnoise_top.c
+++ b/tools/tracing/rtla/src/osnoise_top.c
@@ -339,7 +339,6 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
while (1) {
static struct option long_options[] = {
{"auto", required_argument, 0, 'a'},
- {"duration", required_argument, 0, 'd'},
{"event", required_argument, 0, 'e'},
{"house-keeping", required_argument, 0, 'H'},
{"help", no_argument, 0, 'h'},
@@ -363,7 +362,7 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
if (common_parse_options(argc, argv, &params->common))
continue;
- c = getopt_long(argc, argv, "a:d:e:hH:p:P:qr:s:S:t::T:0:1:2:3:",
+ c = getopt_long(argc, argv, "a:e:hH:p:P:qr:s:S:t::T:0:1:2:3:",
long_options, NULL);
/* Detect the end of the options. */
@@ -383,11 +382,6 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
trace_output = "osnoise_trace.txt";
break;
- case 'd':
- params->common.duration = parse_seconds_duration(optarg);
- if (!params->common.duration)
- fatal("Invalid -d duration");
- break;
case 'e':
tevent = trace_event_alloc(optarg);
if (!tevent)
diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/src/timerlat_hist.c
index c08f628047c1..d625dbe44676 100644
--- a/tools/tracing/rtla/src/timerlat_hist.c
+++ b/tools/tracing/rtla/src/timerlat_hist.c
@@ -793,7 +793,6 @@ static struct common_params
{"auto", required_argument, 0, 'a'},
{"bucket-size", required_argument, 0, 'b'},
{"entries", required_argument, 0, 'E'},
- {"duration", required_argument, 0, 'd'},
{"house-keeping", required_argument, 0, 'H'},
{"help", no_argument, 0, 'h'},
{"irq", required_argument, 0, 'i'},
@@ -830,7 +829,7 @@ static struct common_params
if (common_parse_options(argc, argv, &params->common))
continue;
- c = getopt_long(argc, argv, "a:b:d:e:E:hH:i:knp:P:s:t::T:uU0123456:7:8:9\1\2:\3:",
+ c = getopt_long(argc, argv, "a:b:e:E:hH:i:knp:P:s:t::T:uU0123456:7:8:9\1\2:\3:",
long_options, NULL);
/* detect the end of the options. */
@@ -859,11 +858,6 @@ static struct common_params
params->common.hist.bucket_size >= 1000000)
fatal("Bucket size needs to be > 0 and <= 1000000");
break;
- case 'd':
- params->common.duration = parse_seconds_duration(optarg);
- if (!params->common.duration)
- fatal("Invalid -D duration");
- break;
case 'e':
tevent = trace_event_alloc(optarg);
if (!tevent)
diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src/timerlat_top.c
index 7c0a3f582273..95e949f49cbd 100644
--- a/tools/tracing/rtla/src/timerlat_top.c
+++ b/tools/tracing/rtla/src/timerlat_top.c
@@ -561,7 +561,6 @@ static struct common_params
while (1) {
static struct option long_options[] = {
{"auto", required_argument, 0, 'a'},
- {"duration", required_argument, 0, 'd'},
{"event", required_argument, 0, 'e'},
{"help", no_argument, 0, 'h'},
{"house-keeping", required_argument, 0, 'H'},
@@ -594,7 +593,7 @@ static struct common_params
if (common_parse_options(argc, argv, &params->common))
continue;
- c = getopt_long(argc, argv, "a:d:e:hH:i:knp:P:qs:t::T:uU0:1:2:345:6:7:",
+ c = getopt_long(argc, argv, "a:e:hH:i:knp:P:qs:t::T:uU0:1:2:345:6:7:",
long_options, NULL);
/* detect the end of the options. */
@@ -631,11 +630,6 @@ static struct common_params
/* set aa_only to avoid parsing the trace */
params->common.aa_only = 1;
break;
- case 'd':
- params->common.duration = parse_seconds_duration(optarg);
- if (!params->common.duration)
- fatal("Invalid -d duration");
- break;
case 'e':
tevent = trace_event_alloc(optarg);
if (!tevent)