]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
tools/rtla: Consolidate -P/--priority option parsing
authorCosta Shulyupin <costa.shul@redhat.com>
Tue, 9 Dec 2025 10:00:46 +0000 (12:00 +0200)
committerTomas Glozar <tglozar@redhat.com>
Wed, 7 Jan 2026 14:57:17 +0000 (15:57 +0100)
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>
tools/tracing/rtla/src/common.c
tools/tracing/rtla/src/osnoise_hist.c
tools/tracing/rtla/src/osnoise_top.c
tools/tracing/rtla/src/timerlat_hist.c
tools/tracing/rtla/src/timerlat_top.c

index fbd38d80f1ac528a62f8e04455afefd4be10a00c..90f1bbb7e18936cd6a075f46acf37d65e3f0f652 100644 (file)
@@ -63,11 +63,12 @@ int common_parse_options(int argc, char **argv, struct common_params *common)
                {"debug",               no_argument,            0, 'D'},
                {"duration",            required_argument,      0, 'd'},
                {"event",               required_argument,      0, 'e'},
+               {"priority",            required_argument,      0, 'P'},
                {0, 0, 0, 0}
        };
 
        opterr = 0;
-       c = getopt_long(argc, argv, "c:C::Dd:e:", long_options, NULL);
+       c = getopt_long(argc, argv, "c:C::Dd:e:P:", long_options, NULL);
        opterr = 1;
 
        switch (c) {
@@ -97,6 +98,11 @@ int common_parse_options(int argc, char **argv, struct common_params *common)
                        tevent->next = common->events;
                common->events = tevent;
                break;
+       case 'P':
+               if (parse_prio(optarg, &common->sched_param) == -1)
+                       fatal("Invalid -P priority");
+               common->set_sched = 1;
+               break;
        default:
                optind = saved_state;
                return 0;
index 8b3eab6092bbb43a930542b66c01f44b8babfc7e..6e66726766a1f4e0635f621103327f8644998b6c 100644 (file)
@@ -487,7 +487,6 @@ static struct common_params
                        {"house-keeping",       required_argument,              0, 'H'},
                        {"help",                no_argument,            0, 'h'},
                        {"period",              required_argument,      0, 'p'},
-                       {"priority",            required_argument,      0, 'P'},
                        {"runtime",             required_argument,      0, 'r'},
                        {"stop",                required_argument,      0, 's'},
                        {"stop-total",          required_argument,      0, 'S'},
@@ -509,7 +508,7 @@ static struct common_params
                if (common_parse_options(argc, argv, &params->common))
                        continue;
 
-               c = getopt_long(argc, argv, "a:b:E:hH:p:P:r:s:S:t::T:01234:5:6:7:",
+               c = getopt_long(argc, argv, "a:b:E:hH:p:r:s:S:t::T:01234:5:6:7:",
                                 long_options, NULL);
 
                /* detect the end of the options. */
@@ -556,12 +555,6 @@ static struct common_params
                        if (params->period > 10000000)
                                fatal("Period longer than 10 s");
                        break;
-               case 'P':
-                       retval = parse_prio(optarg, &params->common.sched_param);
-                       if (retval == -1)
-                               fatal("Invalid -P priority");
-                       params->common.set_sched = 1;
-                       break;
                case 'r':
                        params->runtime = get_llong_from_str(optarg);
                        if (params->runtime < 100)
index 47aac00e2848528338f02a3e09e2dd01377ed8fe..7ac992ec7439c3f1eaabc20f14f3582555211b24 100644 (file)
@@ -341,7 +341,6 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
                        {"house-keeping",       required_argument,      0, 'H'},
                        {"help",                no_argument,            0, 'h'},
                        {"period",              required_argument,      0, 'p'},
-                       {"priority",            required_argument,      0, 'P'},
                        {"quiet",               no_argument,            0, 'q'},
                        {"runtime",             required_argument,      0, 'r'},
                        {"stop",                required_argument,      0, 's'},
@@ -360,7 +359,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:hH:p:P:qr:s:S:t::T:0:1:2:3:",
+               c = getopt_long(argc, argv, "a:hH:p:qr:s:S:t::T:0:1:2:3:",
                                 long_options, NULL);
 
                /* Detect the end of the options. */
@@ -395,12 +394,6 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
                        if (params->period > 10000000)
                                fatal("Period longer than 10 s");
                        break;
-               case 'P':
-                       retval = parse_prio(optarg, &params->common.sched_param);
-                       if (retval == -1)
-                               fatal("Invalid -P priority");
-                       params->common.set_sched = 1;
-                       break;
                case 'q':
                        params->common.quiet = 1;
                        break;
index 32424e2bd34a505d6fab48fe5a5b143e9181e4f2..99b416ccfc5b0b7e45ebacece049c09ae2c17969 100644 (file)
@@ -797,7 +797,6 @@ static struct common_params
                        {"irq",                 required_argument,      0, 'i'},
                        {"nano",                no_argument,            0, 'n'},
                        {"period",              required_argument,      0, 'p'},
-                       {"priority",            required_argument,      0, 'P'},
                        {"stack",               required_argument,      0, 's'},
                        {"thread",              required_argument,      0, 'T'},
                        {"trace",               optional_argument,      0, 't'},
@@ -827,7 +826,7 @@ static struct common_params
                if (common_parse_options(argc, argv, &params->common))
                        continue;
 
-               c = getopt_long(argc, argv, "a:b: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:s:t::T:uU0123456:7:8:9\1\2:\3:",
                                 long_options, NULL);
 
                /* detect the end of the options. */
@@ -886,12 +885,6 @@ static struct common_params
                        if (params->timerlat_period_us > 1000000)
                                fatal("Period longer than 1 s");
                        break;
-               case 'P':
-                       retval = parse_prio(optarg, &params->common.sched_param);
-                       if (retval == -1)
-                               fatal("Invalid -P priority");
-                       params->common.set_sched = 1;
-                       break;
                case 's':
                        params->print_stack = get_llong_from_str(optarg);
                        break;
index 928d887e0c2e235619ddfa67614e2980bf849d67..027aad1b639f7432e6b8dcdc212ba77a8df662b8 100644 (file)
@@ -565,7 +565,6 @@ static struct common_params
                        {"irq",                 required_argument,      0, 'i'},
                        {"nano",                no_argument,            0, 'n'},
                        {"period",              required_argument,      0, 'p'},
-                       {"priority",            required_argument,      0, 'P'},
                        {"quiet",               no_argument,            0, 'q'},
                        {"stack",               required_argument,      0, 's'},
                        {"thread",              required_argument,      0, 'T'},
@@ -591,7 +590,7 @@ static struct common_params
                if (common_parse_options(argc, argv, &params->common))
                        continue;
 
-               c = getopt_long(argc, argv, "a:hH:i:knp:P:qs:t::T:uU0:1:2:345:6:7:",
+               c = getopt_long(argc, argv, "a:hH:i:knp:qs:t::T:uU0:1:2:345:6:7:",
                                 long_options, NULL);
 
                /* detect the end of the options. */
@@ -652,12 +651,6 @@ static struct common_params
                        if (params->timerlat_period_us > 1000000)
                                fatal("Period longer than 1 s");
                        break;
-               case 'P':
-                       retval = parse_prio(optarg, &params->common.sched_param);
-                       if (retval == -1)
-                               fatal("Invalid -P priority");
-                       params->common.set_sched = 1;
-                       break;
                case 'q':
                        params->common.quiet = 1;
                        break;