Re: [PATCH v7 38/40] selftests/sched: Add a test of SCHED_DEADLINE policy round trips
From: sashiko-bot
Date: Tue Nov 17 2026 - 10:23:54 EST
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] selftests/sched: 64 KiB FILLER_STACK fails
pthread_attr_setstacksize()
- [Low] selftests/sched: missing sem_destroy() and pipe leak in
deadline_switch_test
--
commit 84b080b4abc565be69cf0d196565fbf11ac9aa91
Author: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
selftests/sched: Add a test of SCHED_DEADLINE policy round trips
This commit adds a new sched/deadline selftest covering SCHED_DEADLINE
policy round trips to SCHED_OTHER and back, as well as sysrq-n
normalization with deadline tasks and priority-inheritance lock owners.
> diff --git a/tools/testing/selftests/sched/deadline/deadline_switch_test.c b/tools/testing/selftests/sched/deadline/deadline_switch_test.c
> new file mode 100644
> index 0000000000000..daf10f81cb968
> --- /dev/null
> +++ b/tools/testing/selftests/sched/deadline/deadline_switch_test.c
[ ... ]
> +static int test_sysrq_boosted_owner(int normalized)
> +{
[ ... ]
> + if (sem_init(&owner_locked, 0, 0) || sem_init(&owner_go, 0, 0)) {
> + ksft_print_msg("sem_init: %s\n", strerror(errno));
> + ret = KSFT_FAIL;
> + goto out;
> + }
[ ... ]
> +out:
> + close(fd);
> + pthread_mutex_destroy(&pi_lock);
> + return ret;
> +}
> +
> +#define FILLERS 2048
> +#define FILLER_STACK (64 * 1024)
[ ... ]
> +static int test_sysrq_running_owner(int normalized)
> +{
[ ... ]
> + fill = calloc(FILLERS, sizeof(*fill));
> + if (!fill || pipe(filler_pipe) || sem_init(&owner_locked, 0, 0) ||
> + sem_init(&filler_ready, 0, 0) || sem_init(&waiter_go, 0, 0) ||
> + pthread_attr_init(&fa) || pthread_attr_setstacksize(&fa, FILLER_STACK)) {
> + ksft_print_msg("setup: %s\n", strerror(errno));
> + free(fill);
> + close(fd);
> + pthread_mutex_destroy(&pi_lock);
> + return KSFT_FAIL;
> + }
[Severity: Medium]
Does pthread_attr_setstacksize(&fa, FILLER_STACK) fail with EINVAL on
architectures where PTHREAD_STACK_MIN is larger than 64 KiB, such as arm64
and powerpc64 (128 KiB)? That causes test_sysrq_running_owner() to fail
during setup on those architectures.
Also, pthread_attr_init() and pthread_attr_setstacksize() return an error
number directly without setting errno, so strerror(errno) reports a stale
errno (typically "Success"), and this error path returns without closing
filler_pipe or destroying fa.
[ ... ]
> +out:
> + close(filler_pipe[1]);
> + for (i = 0; i < started; i++)
> + if (join(fill[i]))
> + ret = KSFT_FAIL;
> + close(filler_pipe[0]);
> + sched_setaffinity(0, sizeof(old), &old);
> + pthread_attr_destroy(&fa);
> + free(fill);
> + close(fd);
> + pthread_mutex_destroy(&pi_lock);
> + return ret;
> +}
[Severity: Low]
Should test_sysrq_boosted_owner() and test_sysrq_running_owner() call
sem_destroy() on owner_locked, owner_go, filler_ready, and waiter_go during
cleanup? Without sem_destroy(&owner_locked) in test_sysrq_boosted_owner(),
test_sysrq_running_owner() calls sem_init() on an already initialized
owner_locked semaphore, which is undefined behavior in POSIX.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1794922146.git.mathieu.desnoyers@xxxxxxxxxxxx?part=38