Skip to content

Commit 5cc90b1

Browse files
makelinuxlenticularis39
authored andcommitted
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>
1 parent c93c25f commit 5cc90b1

5 files changed

Lines changed: 11 additions & 33 deletions

File tree

tools/tracing/rtla/src/common.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,12 @@ int common_parse_options(int argc, char **argv, struct common_params *common)
6363
{"debug", no_argument, 0, 'D'},
6464
{"duration", required_argument, 0, 'd'},
6565
{"event", required_argument, 0, 'e'},
66+
{"priority", required_argument, 0, 'P'},
6667
{0, 0, 0, 0}
6768
};
6869

6970
opterr = 0;
70-
c = getopt_long(argc, argv, "c:C::Dd:e:", long_options, NULL);
71+
c = getopt_long(argc, argv, "c:C::Dd:e:P:", long_options, NULL);
7172
opterr = 1;
7273

7374
switch (c) {
@@ -97,6 +98,11 @@ int common_parse_options(int argc, char **argv, struct common_params *common)
9798
tevent->next = common->events;
9899
common->events = tevent;
99100
break;
101+
case 'P':
102+
if (parse_prio(optarg, &common->sched_param) == -1)
103+
fatal("Invalid -P priority");
104+
common->set_sched = 1;
105+
break;
100106
default:
101107
optind = saved_state;
102108
return 0;

tools/tracing/rtla/src/osnoise_hist.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,6 @@ static struct common_params
487487
{"house-keeping", required_argument, 0, 'H'},
488488
{"help", no_argument, 0, 'h'},
489489
{"period", required_argument, 0, 'p'},
490-
{"priority", required_argument, 0, 'P'},
491490
{"runtime", required_argument, 0, 'r'},
492491
{"stop", required_argument, 0, 's'},
493492
{"stop-total", required_argument, 0, 'S'},
@@ -509,7 +508,7 @@ static struct common_params
509508
if (common_parse_options(argc, argv, &params->common))
510509
continue;
511510

512-
c = getopt_long(argc, argv, "a:b:E:hH:p:P:r:s:S:t::T:01234:5:6:7:",
511+
c = getopt_long(argc, argv, "a:b:E:hH:p:r:s:S:t::T:01234:5:6:7:",
513512
long_options, NULL);
514513

515514
/* detect the end of the options. */
@@ -556,12 +555,6 @@ static struct common_params
556555
if (params->period > 10000000)
557556
fatal("Period longer than 10 s");
558557
break;
559-
case 'P':
560-
retval = parse_prio(optarg, &params->common.sched_param);
561-
if (retval == -1)
562-
fatal("Invalid -P priority");
563-
params->common.set_sched = 1;
564-
break;
565558
case 'r':
566559
params->runtime = get_llong_from_str(optarg);
567560
if (params->runtime < 100)

tools/tracing/rtla/src/osnoise_top.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,6 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
341341
{"house-keeping", required_argument, 0, 'H'},
342342
{"help", no_argument, 0, 'h'},
343343
{"period", required_argument, 0, 'p'},
344-
{"priority", required_argument, 0, 'P'},
345344
{"quiet", no_argument, 0, 'q'},
346345
{"runtime", required_argument, 0, 'r'},
347346
{"stop", required_argument, 0, 's'},
@@ -360,7 +359,7 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
360359
if (common_parse_options(argc, argv, &params->common))
361360
continue;
362361

363-
c = getopt_long(argc, argv, "a:hH:p:P:qr:s:S:t::T:0:1:2:3:",
362+
c = getopt_long(argc, argv, "a:hH:p:qr:s:S:t::T:0:1:2:3:",
364363
long_options, NULL);
365364

366365
/* Detect the end of the options. */
@@ -395,12 +394,6 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
395394
if (params->period > 10000000)
396395
fatal("Period longer than 10 s");
397396
break;
398-
case 'P':
399-
retval = parse_prio(optarg, &params->common.sched_param);
400-
if (retval == -1)
401-
fatal("Invalid -P priority");
402-
params->common.set_sched = 1;
403-
break;
404397
case 'q':
405398
params->common.quiet = 1;
406399
break;

tools/tracing/rtla/src/timerlat_hist.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,6 @@ static struct common_params
797797
{"irq", required_argument, 0, 'i'},
798798
{"nano", no_argument, 0, 'n'},
799799
{"period", required_argument, 0, 'p'},
800-
{"priority", required_argument, 0, 'P'},
801800
{"stack", required_argument, 0, 's'},
802801
{"thread", required_argument, 0, 'T'},
803802
{"trace", optional_argument, 0, 't'},
@@ -827,7 +826,7 @@ static struct common_params
827826
if (common_parse_options(argc, argv, &params->common))
828827
continue;
829828

830-
c = getopt_long(argc, argv, "a:b:E:hH:i:knp:P:s:t::T:uU0123456:7:8:9\1\2:\3:",
829+
c = getopt_long(argc, argv, "a:b:E:hH:i:knp:s:t::T:uU0123456:7:8:9\1\2:\3:",
831830
long_options, NULL);
832831

833832
/* detect the end of the options. */
@@ -886,12 +885,6 @@ static struct common_params
886885
if (params->timerlat_period_us > 1000000)
887886
fatal("Period longer than 1 s");
888887
break;
889-
case 'P':
890-
retval = parse_prio(optarg, &params->common.sched_param);
891-
if (retval == -1)
892-
fatal("Invalid -P priority");
893-
params->common.set_sched = 1;
894-
break;
895888
case 's':
896889
params->print_stack = get_llong_from_str(optarg);
897890
break;

tools/tracing/rtla/src/timerlat_top.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,6 @@ static struct common_params
565565
{"irq", required_argument, 0, 'i'},
566566
{"nano", no_argument, 0, 'n'},
567567
{"period", required_argument, 0, 'p'},
568-
{"priority", required_argument, 0, 'P'},
569568
{"quiet", no_argument, 0, 'q'},
570569
{"stack", required_argument, 0, 's'},
571570
{"thread", required_argument, 0, 'T'},
@@ -591,7 +590,7 @@ static struct common_params
591590
if (common_parse_options(argc, argv, &params->common))
592591
continue;
593592

594-
c = getopt_long(argc, argv, "a:hH:i:knp:P:qs:t::T:uU0:1:2:345:6:7:",
593+
c = getopt_long(argc, argv, "a:hH:i:knp:qs:t::T:uU0:1:2:345:6:7:",
595594
long_options, NULL);
596595

597596
/* detect the end of the options. */
@@ -652,12 +651,6 @@ static struct common_params
652651
if (params->timerlat_period_us > 1000000)
653652
fatal("Period longer than 1 s");
654653
break;
655-
case 'P':
656-
retval = parse_prio(optarg, &params->common.sched_param);
657-
if (retval == -1)
658-
fatal("Invalid -P priority");
659-
params->common.set_sched = 1;
660-
break;
661654
case 'q':
662655
params->common.quiet = 1;
663656
break;

0 commit comments

Comments
 (0)