Hi, On 2024-04-25 17:36:26+0000, Thijs Raymakers wrote: > Co-authored-by: Phil Auld <pauld@xxxxxxxxxx> > Signed-off-by: Phil Auld <pauld@xxxxxxxxxx> > Signed-off-by: Thijs Raymakers <thijs@xxxxxxxxxxxx> > --- > > I noticed that the CI pipeline failed because the coresched test reported > a "No such device" error. > > https://download.copr.fedorainfracloud.org/results/packit/util-linux-util-linux-2990/fedora-rawhide-x86_64/07343926-util-linux/builder-live.log.gz > > This happens because the following check in the kernel's > kernel/sched/core_sched.c fails: > > > /* Called from prctl interface: PR_SCHED_CORE */ > > int sched_core_share_pid(unsigned int cmd, pid_t pid, enum pid_type type, > > unsigned long uaddr) > > { > > [snip] > > > > if (!static_branch_likely(&sched_smt_present)) > > return -ENODEV; > > The prctl call will return ENODEV whenever SMT is not available, > but the kernel is compiled with CONFIG_SCHED_CORE. I've added a check that skips > the tests for coresched when this is the case. > > Thijs > > > Interdiff against v10: > diff --git a/schedutils/coresched.c b/schedutils/coresched.c > index 7bc5c9d38..beeb01702 100644 > --- a/schedutils/coresched.c > +++ b/schedutils/coresched.c > @@ -328,7 +328,7 @@ int main(int argc, char **argv) > > if (!is_core_sched_supported()) > errx(EXIT_FAILURE, > - _("No support for core scheduling found. Does your kernel" > + _("No support for core scheduling found. Does your kernel " > "support CONFIG_SCHED_CORE?")); > > sched_core_cookie cookie; > diff --git a/tests/ts/schedutils/coresched b/tests/ts/schedutils/coresched > index e34fa319f..debb8cbfc 100755 > --- a/tests/ts/schedutils/coresched > +++ b/tests/ts/schedutils/coresched > @@ -22,6 +22,12 @@ if [[ $CORESCHED_TEST_KERNEL_SUPPORT_CMD == *"CONFIG_SCHED_CORE"* ]]; then > ts_skip "Kernel has no CONFIG_SCHED_CORE support" > fi > > +# Kernel and the machine must support SMT > +CORESCHED_HAS_SMT_SUPPORT=$(</sys/devices/system/cpu/smt/control) > +if [[ "$CORESCHED_HAS_SMT_SUPPORT" != "on" ]]; then > + ts_skip "SMT is unavailable (state: $CORESCHED_HAS_SMT_SUPPORT)" > +fi > + > # The output of coresched contains PIDs and core scheduling cookies, both of which should be > # assumed to be random values as we have no control over them. The tests replace these values > # with sed before writing them to the output file, so it can match the expected output file. > > .gitignore | 1 + > bash-completion/coresched | 0 > configure.ac | 12 +- > meson.build | 16 +- > meson_options.txt | 2 +- > schedutils/Makemodule.am | 8 + > schedutils/coresched.1.adoc | 139 +++++++ > schedutils/coresched.c | 358 ++++++++++++++++++ > tests/commands.sh | 1 + > .../coresched-copy-from-child-to-parent | 1 + > ...coresched-copy-from-parent-to-nested-child | 1 + > .../schedutils/coresched-get-cookie-own-pid | 1 + > .../coresched-get-cookie-parent-pid | 1 + > .../coresched-new-child-with-new-cookie | 1 + > .../coresched-set-cookie-parent-pid.err | 1 + > .../expected/schedutils/set-cookie-parent-pid | 1 + > tests/ts/schedutils/coresched | 89 +++++ > 17 files changed, 627 insertions(+), 6 deletions(-) > create mode 100644 bash-completion/coresched > create mode 100644 schedutils/coresched.1.adoc > create mode 100644 schedutils/coresched.c > create mode 100644 tests/expected/schedutils/coresched-copy-from-child-to-parent > create mode 100644 tests/expected/schedutils/coresched-copy-from-parent-to-nested-child > create mode 100644 tests/expected/schedutils/coresched-get-cookie-own-pid > create mode 100644 tests/expected/schedutils/coresched-get-cookie-parent-pid > create mode 100644 tests/expected/schedutils/coresched-new-child-with-new-cookie > create mode 100644 tests/expected/schedutils/coresched-set-cookie-parent-pid.err > create mode 100644 tests/expected/schedutils/set-cookie-parent-pid > create mode 100755 tests/ts/schedutils/coresched [..] > +// If PR_SCHED_CORE is not recognized, or not supported on this system, > +// then prctl will set errno to EINVAL. Assuming all other operands of > +// prctl are valid, we can use errno==EINVAL as a check to see whether > +// core scheduling is available on this system. > +static bool is_core_sched_supported(void) > +{ > + sched_core_cookie cookie = 0; > + if (prctl(PR_SCHED_CORE, PR_SCHED_CORE_GET, getpid(), > + PR_SCHED_CORE_SCOPE_THREAD, &cookie)) > + if (errno == EINVAL) > + return false; IMO the ENODEV should be handled here. So the user can get a proper error message. This would then also remove the need for another ts_skip in the testcase. > + > + return true; > +} > + [..]