On 3/6/26 16:10, Juri Lelli wrote:
> Add a comprehensive utility library for SCHED_DEADLINE scheduler tests.
> This library provides reusable helper functions that simplify test
> implementation and reduce code duplication across the test suite.
> 
> The utility library provides scheduling operations that wrap the
> sched_setattr and sched_getattr syscalls for setting and querying
> SCHED_DEADLINE parameters. These include dl_set_sched_attr() for
> configuring deadline parameters, dl_get_sched_attr() for querying
> scheduling attributes, dl_get_policy() for reading the policy from
> /proc, and dl_is_deadline_task() for checking if a task is using
> SCHED_DEADLINE. The library uses system headers for struct sched_attr
> to avoid redefinition conflicts and provides full control over
> SCHED_DEADLINE parameters.
> 
> Bandwidth management helpers allow tests to work within system
> constraints. The dl_get_rt_bandwidth() function reads RT bandwidth
> settings from /proc, while dl_calc_max_bandwidth_percent() calculates
> the available bandwidth for deadline tasks based on current system
> configuration.
> 
> Process management functions simplify creating and managing test
> workloads. The dl_create_cpuhog() function forks and schedules a cpuhog
> process by creating a child process, executing the cpuhog binary, and
> setting SCHED_DEADLINE policy on the child PID after fork. It waits for
> the child to start before configuring the scheduling policy. Supporting
> functions include dl_cleanup_cpuhog() for terminating processes,
> dl_find_cpuhogs() for locating running instances, and dl_wait_for_pid()
> for synchronizing with process startup.
> 
> CPU topology helpers enable tests that manipulate CPU hotplug state.
> These include dl_get_online_cpus() for counting available CPUs,
> dl_get_hotpluggable_cpus() for identifying which CPUs can be
> hotplugged, dl_cpu_online() and dl_cpu_offline() for controlling
> hotplug state, and dl_is_cpu_online() for checking current status.
> 
> Time conversion utilities provide convenient transformations between
> different time units. These include dl_ms_to_ns() and dl_us_to_ns()
> for converting to nanoseconds, and dl_ns_to_ms() and dl_ns_to_us() for
> converting from nanoseconds.
> 
> The library also includes the cpuhog helper program, which performs
> busy looping to consume CPU cycles. This provides a controllable
> workload for testing scheduler behavior under various deadline
> configurations.
> 
> Assisted-by: Claude Code: claude-sonnet-4-5@20250929
> Signed-off-by: Juri Lelli <[email protected]>
> ---
>  tools/testing/selftests/sched/deadline/Makefile  |  14 +-
>  tools/testing/selftests/sched/deadline/cpuhog.c  | 107 ++++++++
>  tools/testing/selftests/sched/deadline/dl_util.c | 335 
> +++++++++++++++++++++++
>  tools/testing/selftests/sched/deadline/dl_util.h | 227 +++++++++++++++
>  4 files changed, 680 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/testing/selftests/sched/deadline/Makefile 
> b/tools/testing/selftests/sched/deadline/Makefile
> index fd57794f1a543..ea3fdfbef459e 100644
> --- a/tools/testing/selftests/sched/deadline/Makefile
> +++ b/tools/testing/selftests/sched/deadline/Makefile
> @@ -1,6 +1,6 @@
>  # SPDX-License-Identifier: GPL-2.0
>  
> -TEST_GEN_PROGS := runner
> +TEST_GEN_PROGS := runner cpuhog
>  

This runs cpuhog as a test as well which prints misleading timeouts.


Reply via email to