summaryrefslogtreecommitdiff
path: root/tools/tracing
diff options
context:
space:
mode:
authorCosta Shulyupin <costa.shul@redhat.com>2025-12-09 12:00:45 +0200
committerTomas Glozar <tglozar@redhat.com>2026-01-07 15:57:17 +0100
commitc93c25fca5ab3c27b42f1f941871209573c0b41b (patch)
tree4bb03ff99cd054d8387facc20193a455ae5957cb /tools/tracing
parent76975581fb0eba03820fe312094981c995c225f9 (diff)
downloadlinux-next-c93c25fca5ab3c27b42f1f941871209573c0b41b.tar.gz
linux-next-c93c25fca5ab3c27b42f1f941871209573c0b41b.zip
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>
Diffstat (limited to 'tools/tracing')
-rw-r--r--tools/tracing/rtla/src/common.c13
-rw-r--r--tools/tracing/rtla/src/osnoise_hist.c14
-rw-r--r--tools/tracing/rtla/src/osnoise_top.c14
-rw-r--r--tools/tracing/rtla/src/timerlat_hist.c14
-rw-r--r--tools/tracing/rtla/src/timerlat_top.c13
5 files changed, 16 insertions, 52 deletions
diff --git a/tools/tracing/rtla/src/common.c b/tools/tracing/rtla/src/common.c
index 0776f1568d23..fbd38d80f1ac 100644
--- a/tools/tracing/rtla/src/common.c
+++ b/tools/tracing/rtla/src/common.c
@@ -53,6 +53,7 @@ static void set_signals(struct common_params *params)
*/
int common_parse_options(int argc, char **argv, struct common_params *common)
{
+ struct trace_events *tevent;
int saved_state = optind;
int c;
@@ -61,11 +62,12 @@ int common_parse_options(int argc, char **argv, struct common_params *common)
{"cgroup", optional_argument, 0, 'C'},
{"debug", no_argument, 0, 'D'},
{"duration", required_argument, 0, 'd'},
+ {"event", required_argument, 0, 'e'},
{0, 0, 0, 0}
};
opterr = 0;
- c = getopt_long(argc, argv, "c:C::Dd:", long_options, NULL);
+ c = getopt_long(argc, argv, "c:C::Dd:e:", long_options, NULL);
opterr = 1;
switch (c) {
@@ -86,6 +88,15 @@ int common_parse_options(int argc, char **argv, struct common_params *common)
if (!common->duration)
fatal("Invalid -d duration");
break;
+ case 'e':
+ tevent = trace_event_alloc(optarg);
+ if (!tevent)
+ fatal("Error alloc trace event");
+
+ if (common->events)
+ tevent->next = common->events;
+ common->events = tevent;
+ 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 f34c88fd57e2..8b3eab6092bb 100644
--- a/tools/tracing/rtla/src/osnoise_hist.c
+++ b/tools/tracing/rtla/src/osnoise_hist.c
@@ -463,7 +463,6 @@ static struct common_params
*osnoise_hist_parse_args(int argc, char *argv[])
{
struct osnoise_params *params;
- struct trace_events *tevent;
int retval;
int c;
char *trace_output = NULL;
@@ -493,7 +492,6 @@ static struct common_params
{"stop", required_argument, 0, 's'},
{"stop-total", required_argument, 0, 'S'},
{"trace", optional_argument, 0, 't'},
- {"event", required_argument, 0, 'e'},
{"threshold", required_argument, 0, 'T'},
{"no-header", no_argument, 0, '0'},
{"no-summary", no_argument, 0, '1'},
@@ -511,7 +509,7 @@ static struct common_params
if (common_parse_options(argc, argv, &params->common))
continue;
- c = getopt_long(argc, argv, "a:b:e:E:hH:p:P:r:s:S:t::T:01234:5:6:7:",
+ c = getopt_long(argc, argv, "a:b:E:hH:p:P:r:s:S:t::T:01234:5:6:7:",
long_options, NULL);
/* detect the end of the options. */
@@ -537,16 +535,6 @@ static struct common_params
params->common.hist.bucket_size >= 1000000)
fatal("Bucket size needs to be > 0 and <= 1000000");
break;
- case 'e':
- tevent = trace_event_alloc(optarg);
- if (!tevent)
- fatal("Error alloc trace event");
-
- if (params->common.events)
- tevent->next = params->common.events;
-
- params->common.events = tevent;
- break;
case 'E':
params->common.hist.entries = get_llong_from_str(optarg);
if (params->common.hist.entries < 10 ||
diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/osnoise_top.c
index 695c6ecf0098..47aac00e2848 100644
--- a/tools/tracing/rtla/src/osnoise_top.c
+++ b/tools/tracing/rtla/src/osnoise_top.c
@@ -315,7 +315,6 @@ static void osnoise_top_usage(struct osnoise_params *params)
struct common_params *osnoise_top_parse_args(int argc, char **argv)
{
struct osnoise_params *params;
- struct trace_events *tevent;
int retval;
int c;
char *trace_output = NULL;
@@ -339,7 +338,6 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
while (1) {
static struct option long_options[] = {
{"auto", required_argument, 0, 'a'},
- {"event", required_argument, 0, 'e'},
{"house-keeping", required_argument, 0, 'H'},
{"help", no_argument, 0, 'h'},
{"period", required_argument, 0, 'p'},
@@ -362,7 +360,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:e:hH:p:P:qr:s:S:t::T:0:1:2:3:",
+ c = getopt_long(argc, argv, "a:hH:p:P:qr:s:S:t::T:0:1:2:3:",
long_options, NULL);
/* Detect the end of the options. */
@@ -382,16 +380,6 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
trace_output = "osnoise_trace.txt";
break;
- case 'e':
- tevent = trace_event_alloc(optarg);
- if (!tevent)
- fatal("Error alloc trace event");
-
- if (params->common.events)
- tevent->next = params->common.events;
- params->common.events = tevent;
-
- break;
case 'h':
case '?':
osnoise_top_usage(params);
diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/src/timerlat_hist.c
index d625dbe44676..32424e2bd34a 100644
--- a/tools/tracing/rtla/src/timerlat_hist.c
+++ b/tools/tracing/rtla/src/timerlat_hist.c
@@ -761,7 +761,6 @@ static struct common_params
*timerlat_hist_parse_args(int argc, char *argv[])
{
struct timerlat_params *params;
- struct trace_events *tevent;
int auto_thresh;
int retval;
int c;
@@ -805,7 +804,6 @@ static struct common_params
{"user-threads", no_argument, 0, 'u'},
{"kernel-threads", no_argument, 0, 'k'},
{"user-load", no_argument, 0, 'U'},
- {"event", required_argument, 0, 'e'},
{"no-irq", no_argument, 0, '0'},
{"no-thread", no_argument, 0, '1'},
{"no-header", no_argument, 0, '2'},
@@ -829,7 +827,7 @@ static struct common_params
if (common_parse_options(argc, argv, &params->common))
continue;
- c = getopt_long(argc, argv, "a:b:e:E:hH:i:knp:P:s:t::T:uU0123456:7:8:9\1\2:\3:",
+ c = getopt_long(argc, argv, "a:b:E:hH:i:knp:P:s:t::T:uU0123456:7:8:9\1\2:\3:",
long_options, NULL);
/* detect the end of the options. */
@@ -858,16 +856,6 @@ static struct common_params
params->common.hist.bucket_size >= 1000000)
fatal("Bucket size needs to be > 0 and <= 1000000");
break;
- case 'e':
- tevent = trace_event_alloc(optarg);
- if (!tevent)
- fatal("Error alloc trace event");
-
- if (params->common.events)
- tevent->next = params->common.events;
-
- params->common.events = tevent;
- break;
case 'E':
params->common.hist.entries = get_llong_from_str(optarg);
if (params->common.hist.entries < 10 ||
diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src/timerlat_top.c
index 95e949f49cbd..928d887e0c2e 100644
--- a/tools/tracing/rtla/src/timerlat_top.c
+++ b/tools/tracing/rtla/src/timerlat_top.c
@@ -533,7 +533,6 @@ static struct common_params
*timerlat_top_parse_args(int argc, char **argv)
{
struct timerlat_params *params;
- struct trace_events *tevent;
long long auto_thresh;
int retval;
int c;
@@ -561,7 +560,6 @@ static struct common_params
while (1) {
static struct option long_options[] = {
{"auto", required_argument, 0, 'a'},
- {"event", required_argument, 0, 'e'},
{"help", no_argument, 0, 'h'},
{"house-keeping", required_argument, 0, 'H'},
{"irq", required_argument, 0, 'i'},
@@ -593,7 +591,7 @@ static struct common_params
if (common_parse_options(argc, argv, &params->common))
continue;
- c = getopt_long(argc, argv, "a:e:hH:i:knp:P:qs:t::T:uU0:1:2:345:6:7:",
+ c = getopt_long(argc, argv, "a:hH:i:knp:P:qs:t::T:uU0:1:2:345:6:7:",
long_options, NULL);
/* detect the end of the options. */
@@ -630,15 +628,6 @@ static struct common_params
/* set aa_only to avoid parsing the trace */
params->common.aa_only = 1;
break;
- case 'e':
- tevent = trace_event_alloc(optarg);
- if (!tevent)
- fatal("Error alloc trace event");
-
- if (params->common.events)
- tevent->next = params->common.events;
- params->common.events = tevent;
- break;
case 'h':
case '?':
timerlat_top_usage();