Skip to content

Commit 0576be4

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

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,12 +63,13 @@ 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+
{"house-keeping", required_argument, 0, 'H'},
6667
{"priority", required_argument, 0, 'P'},
6768
{0, 0, 0, 0}
6869
};
6970

7071
opterr = 0;
71-
c = getopt_long(argc, argv, "c:C::Dd:e:P:", long_options, NULL);
72+
c = getopt_long(argc, argv, "c:C::Dd:e:H:P:", long_options, NULL);
7273
opterr = 1;
7374

7475
switch (c) {
@@ -98,6 +99,11 @@ int common_parse_options(int argc, char **argv, struct common_params *common)
9899
tevent->next = common->events;
99100
common->events = tevent;
100101
break;
102+
case 'H':
103+
common->hk_cpus = 1;
104+
if (parse_cpu_set(optarg, &common->hk_cpu_set))
105+
fatal("Error parsing house keeping CPUs");
106+
break;
101107
case 'P':
102108
if (parse_prio(optarg, &common->sched_param) == -1)
103109
fatal("Invalid -P priority");

tools/tracing/rtla/src/osnoise_hist.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,6 @@ static struct common_params
484484
{"auto", required_argument, 0, 'a'},
485485
{"bucket-size", required_argument, 0, 'b'},
486486
{"entries", required_argument, 0, 'E'},
487-
{"house-keeping", required_argument, 0, 'H'},
488487
{"help", no_argument, 0, 'h'},
489488
{"period", required_argument, 0, 'p'},
490489
{"runtime", required_argument, 0, 'r'},
@@ -508,7 +507,7 @@ static struct common_params
508507
if (common_parse_options(argc, argv, &params->common))
509508
continue;
510509

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

514513
/* detect the end of the options. */
@@ -544,12 +543,6 @@ static struct common_params
544543
case '?':
545544
osnoise_hist_usage();
546545
break;
547-
case 'H':
548-
params->common.hk_cpus = 1;
549-
retval = parse_cpu_set(optarg, &params->common.hk_cpu_set);
550-
if (retval)
551-
fatal("Error parsing house keeping CPUs");
552-
break;
553546
case 'p':
554547
params->period = get_llong_from_str(optarg);
555548
if (params->period > 10000000)

tools/tracing/rtla/src/osnoise_top.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,6 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
338338
while (1) {
339339
static struct option long_options[] = {
340340
{"auto", required_argument, 0, 'a'},
341-
{"house-keeping", required_argument, 0, 'H'},
342341
{"help", no_argument, 0, 'h'},
343342
{"period", required_argument, 0, 'p'},
344343
{"quiet", no_argument, 0, 'q'},
@@ -359,7 +358,7 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
359358
if (common_parse_options(argc, argv, &params->common))
360359
continue;
361360

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

365364
/* Detect the end of the options. */
@@ -383,12 +382,6 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
383382
case '?':
384383
osnoise_top_usage(params);
385384
break;
386-
case 'H':
387-
params->common.hk_cpus = 1;
388-
retval = parse_cpu_set(optarg, &params->common.hk_cpu_set);
389-
if (retval)
390-
fatal("Error parsing house keeping CPUs");
391-
break;
392385
case 'p':
393386
params->period = get_llong_from_str(optarg);
394387
if (params->period > 10000000)

tools/tracing/rtla/src/timerlat_hist.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,6 @@ static struct common_params
792792
{"auto", required_argument, 0, 'a'},
793793
{"bucket-size", required_argument, 0, 'b'},
794794
{"entries", required_argument, 0, 'E'},
795-
{"house-keeping", required_argument, 0, 'H'},
796795
{"help", no_argument, 0, 'h'},
797796
{"irq", required_argument, 0, 'i'},
798797
{"nano", no_argument, 0, 'n'},
@@ -826,7 +825,7 @@ static struct common_params
826825
if (common_parse_options(argc, argv, &params->common))
827826
continue;
828827

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

832831
/* detect the end of the options. */
@@ -865,12 +864,6 @@ static struct common_params
865864
case '?':
866865
timerlat_hist_usage();
867866
break;
868-
case 'H':
869-
params->common.hk_cpus = 1;
870-
retval = parse_cpu_set(optarg, &params->common.hk_cpu_set);
871-
if (retval)
872-
fatal("Error parsing house keeping CPUs");
873-
break;
874867
case 'i':
875868
params->common.stop_us = get_llong_from_str(optarg);
876869
break;

tools/tracing/rtla/src/timerlat_top.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,6 @@ static struct common_params
561561
static struct option long_options[] = {
562562
{"auto", required_argument, 0, 'a'},
563563
{"help", no_argument, 0, 'h'},
564-
{"house-keeping", required_argument, 0, 'H'},
565564
{"irq", required_argument, 0, 'i'},
566565
{"nano", no_argument, 0, 'n'},
567566
{"period", required_argument, 0, 'p'},
@@ -590,7 +589,7 @@ static struct common_params
590589
if (common_parse_options(argc, argv, &params->common))
591590
continue;
592591

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

596595
/* detect the end of the options. */
@@ -631,12 +630,6 @@ static struct common_params
631630
case '?':
632631
timerlat_top_usage();
633632
break;
634-
case 'H':
635-
params->common.hk_cpus = 1;
636-
retval = parse_cpu_set(optarg, &params->common.hk_cpu_set);
637-
if (retval)
638-
fatal("Error parsing house keeping CPUs");
639-
break;
640633
case 'i':
641634
params->common.stop_us = get_llong_from_str(optarg);
642635
break;

0 commit comments

Comments
 (0)