Re: [PATCH v10 40/40] selftests/sched: Share the helpers of the deadline tests

From: sashiko-bot

Date: Fri Nov 20 2026 - 16:15:33 EST


Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] selftests/sched: Makefile pattern rule shadowed by lib.mk
- [Low] selftests/sched: orphaned now_ns() comment and duplicate
cpu_time_ns()
--

commit 152ce0e30fc3ab83803e1441c43fe57ed1ceba20
Author: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>

selftests/sched: Share the helpers of the deadline tests

This commit extracts duplicated time, file I/O, cgroup, and reporting
helpers from deadline_bw_test, deadline_rebuild_test, and
deadline_switch_test into a shared deadline_util.h header.

> diff --git a/tools/testing/selftests/sched/deadline/Makefile b/tools/testing/selftests/sched/deadline/Makefile
> index 15f1e96a21e6f..c7a665a02d6f9 100644
> --- a/tools/testing/selftests/sched/deadline/Makefile
> +++ b/tools/testing/selftests/sched/deadline/Makefile
> @@ -6,3 +6,6 @@ LDLIBS += -lpthread
> TEST_GEN_PROGS := deadline_switch_test deadline_rebuild_test deadline_bw_test
>
> include ../../lib.mk
> +
> +$(OUTPUT)/%: %.c deadline_util.h
> + $(CC) $(CFLAGS) $< $(LDFLAGS) $(LDLIBS) -o $@

[Severity: Low]
Does this pattern rule ever take effect?

lib.mk already defines "$(OUTPUT)/%:%.c $(LOCAL_HDRS)". Because the
prerequisite patterns differ, GNU Make keeps both rules and always matches
the earlier one in lib.mk, so editing deadline_util.h does not trigger a
rebuild. Setting "LOCAL_HDRS += deadline_util.h" before including lib.mk
instead of adding a second pattern rule registers the header with lib.mk's
rule.

> diff --git a/tools/testing/selftests/sched/deadline/deadline_rebuild_test.c b/tools/testing/selftests/sched/deadline/deadline_rebuild_test.c
> index 85b24b868da72..7b0609e8e6edd 100644
> --- a/tools/testing/selftests/sched/deadline/deadline_rebuild_test.c
> +++ b/tools/testing/selftests/sched/deadline/deadline_rebuild_test.c
[ ... ]
> @@ -91,22 +93,6 @@ static int set_other(pid_t pid)
> * Return the CLOCK_MONOTONIC time in ns. clock_gettime() cannot fail: the
> * clock is always supported, and the pointer is valid.
> */
> -static uint64_t now_ns(void)
> -{
> - struct timespec ts;
> -
> - clock_gettime(CLOCK_MONOTONIC, &ts);
> - return ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec;
> -}
> -
> -static void sleep_ns(uint64_t ns)
> -{
> - struct timespec ts = { .tv_sec = ns / NSEC_PER_SEC, .tv_nsec = ns % NSEC_PER_SEC };
> -
> - while (nanosleep(&ts, &ts) && errno == EINTR)
> - ;
> -}
> -
> static void reap(pid_t pid)

[Severity: Low]
This isn't a bug, but removing now_ns() leaves its comment attached to
reap(). Also, cpu_time_ns() in this file is identical to thread_time_ns()
in deadline_util.h and could be replaced by it.

--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795207232.git.mathieu.desnoyers@xxxxxxxxxxxx?part=40