mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 01:24:47 +01:00
tools/sched_ext: fix getopt not re-parsed on restart
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>
This commit is contained in:
parent
f892f9f994
commit
640c9dc72f
6 changed files with 6 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue