]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tools/sched_ext: fix getopt not re-parsed on restart
authorDavid Carlier <devnexen@gmail.com>
Wed, 18 Feb 2026 19:22:35 +0000 (19:22 +0000)
committerTejun Heo <tj@kernel.org>
Sat, 21 Feb 2026 03:17:38 +0000 (17:17 -1000)
After goto restart, optind retains its advanced position from the
previous getopt loop, causing getopt() to immediately return -1.
This silently drops all command-line options on the restarted skeleton.

Reset optind to 1 at the restart label so options are re-parsed.

Affected schedulers: scx_simple, scx_central, scx_flatcg, scx_pair,
scx_sdt, scx_cpu0.

Signed-off-by: David Carlier <devnexen@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
tools/sched_ext/scx_central.c
tools/sched_ext/scx_cpu0.c
tools/sched_ext/scx_flatcg.c
tools/sched_ext/scx_pair.c
tools/sched_ext/scx_sdt.c
tools/sched_ext/scx_simple.c

index 39f21b00a208296c8e56edf0d30d16834d7f273f..2a805f1d6c8fbcd64d9b707bb803c61afb773e40 100644 (file)
@@ -56,6 +56,7 @@ int main(int argc, char **argv)
        signal(SIGINT, sigint_handler);
        signal(SIGTERM, sigint_handler);
 restart:
+       optind = 1;
        skel = SCX_OPS_OPEN(central_ops, scx_central);
 
        skel->rodata->central_cpu = 0;
index 1e4fa4ab8da9b4868e5683e4d5a16415c3697811..a6fba9978b9cecc594c7e368d08cc5176111386c 100644 (file)
@@ -69,6 +69,7 @@ int main(int argc, char **argv)
        signal(SIGINT, sigint_handler);
        signal(SIGTERM, sigint_handler);
 restart:
+       optind = 1;
        skel = SCX_OPS_OPEN(cpu0_ops, scx_cpu0);
 
        skel->rodata->nr_cpus = libbpf_num_possible_cpus();
index a8446509949ef3d18cc2327406c4d08e85842926..d865c381589bbf66fbc00d41715ef3d53f240e6c 100644 (file)
@@ -141,6 +141,7 @@ int main(int argc, char **argv)
        signal(SIGINT, sigint_handler);
        signal(SIGTERM, sigint_handler);
 restart:
+       optind = 1;
        skel = SCX_OPS_OPEN(flatcg_ops, scx_flatcg);
 
        skel->rodata->nr_cpus = libbpf_num_possible_cpus();
index 2a82d8a8a0aa189a004afe409095df9f51f51f79..2e509391f3dab9e4f47544af66e92ce866894bce 100644 (file)
@@ -53,6 +53,7 @@ int main(int argc, char **argv)
        signal(SIGINT, sigint_handler);
        signal(SIGTERM, sigint_handler);
 restart:
+       optind = 1;
        skel = SCX_OPS_OPEN(pair_ops, scx_pair);
 
        skel->rodata->nr_cpu_ids = libbpf_num_possible_cpus();
index b0363363476de00f1e3f48f1aba854c447057e31..d8ca9aa316a586a1ce9993c6f9344fa58142c8fd 100644 (file)
@@ -51,6 +51,7 @@ int main(int argc, char **argv)
        signal(SIGINT, sigint_handler);
        signal(SIGTERM, sigint_handler);
 restart:
+       optind = 1;
        skel = SCX_OPS_OPEN(sdt_ops, scx_sdt);
 
        while ((opt = getopt(argc, argv, "fvh")) != -1) {
index 06d4b13bf76bcc4121954da78fa692823a9ae7ed..c3b48611712ba51630b6889081ef7cb9f2c45b0a 100644 (file)
@@ -71,6 +71,7 @@ int main(int argc, char **argv)
        signal(SIGINT, sigint_handler);
        signal(SIGTERM, sigint_handler);
 restart:
+       optind = 1;
        skel = SCX_OPS_OPEN(simple_ops, scx_simple);
 
        while ((opt = getopt(argc, argv, "fvh")) != -1) {