From: Gabriele Monaco <gmonaco@redhat.com>
To: Juri Lelli <juri.lelli@redhat.com>, Shuah Khan <shuah@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>
Cc: Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Valentin Schneider <vschneid@redhat.com>,
Clark Williams <williams@redhat.com>,
Tommaso Cucinotta <tommaso.cucinotta@santannapisa.it>,
Luca Abeni <luca.abeni@santannapisa.it>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH RFC 4/7] selftests/sched: Add basic SCHED_DEADLINE functionality tests
Date: Mon, 09 Mar 2026 09:15:55 +0100 [thread overview]
Message-ID: <64fa81f453d7909e5669cc32284f7c9f48f2fea9.camel@redhat.com> (raw)
In-Reply-To: <20260306-upstream-deadline-kselftests-v1-4-2b23ef74c46a@redhat.com>
Hello,
On Fri, 2026-03-06 at 17:10 +0100, Juri Lelli wrote:
> Add initial test coverage for SCHED_DEADLINE scheduler functionality.
> This patch introduces two fundamental tests that validate core
> SCHED_DEADLINE behavior using the test framework and utility library.
>
> The basic_scheduling test creates a cpuhog process with SCHED_DEADLINE
> policy and verifies the scheduling policy is correctly set to policy 6
> (SCHED_DEADLINE). It confirms the task executes successfully for the
> specified duration using reasonable parameters with 30ms runtime, 100ms
> deadline, and 100ms period. This validates the fundamental operation of
> setting SCHED_DEADLINE policy and running deadline-scheduled tasks.
>
> The parameter_validation test ensures the kernel properly validates
> SCHED_DEADLINE parameters. It tests that invalid parameter combinations
> such as runtime greater than deadline are correctly rejected with
> EINVAL, while valid parameter configurations are accepted. This confirms
> the kernel's parameter validation logic is working correctly and
> prevents misconfigured deadline tasks from being scheduled.
>
> Both tests use the dl_util library for SCHED_DEADLINE operations and
> follow the framework pattern with automatic registration via
> REGISTER_DL_TEST(). The tests pass cleanly in VM environments with 2
> tests passing, 0 skipped, and 0 failed.
>
> Assisted-by: Claude Code: claude-sonnet-4-5@20250929
> Signed-off-by: Juri Lelli <juri.lelli@redhat.com>
> ---
...
>
> +# Test files
> +$(OUTPUT)/basic.o: basic.c dl_test.h dl_util.h | $(OUTPUT_DIR)
> + $(CC) $(CFLAGS) -c $< -o $@
> +
This seems a constant in all tests, what about just having make do the trick:
$(OUTPUT)/%.o: %.c dl_test.h dl_util.h | $(OUTPUT_DIR)
$(CC) $(CFLAGS) -c $< -o $@
The rest looks neat.
Thanks,
Gabriele
> $(OUTPUT_DIR):
> mkdir -p $@
>
> diff --git a/tools/testing/selftests/sched/deadline/basic.c
> b/tools/testing/selftests/sched/deadline/basic.c
> new file mode 100644
> index 0000000000000..f1c4e8c751b61
> --- /dev/null
> +++ b/tools/testing/selftests/sched/deadline/basic.c
> @@ -0,0 +1,127 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Basic SCHED_DEADLINE functionality tests
> + *
> + * Validates fundamental SCHED_DEADLINE scheduler operations including
> + * policy setup, parameter validation, and basic task execution.
> + */
> +
> +#define _GNU_SOURCE
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <unistd.h>
> +#include <sys/types.h>
> +#include <sys/wait.h>
> +#include <errno.h>
> +#include <sched.h>
> +#include "dl_test.h"
> +#include "dl_util.h"
> +
> +/*
> + * Test: Basic SCHED_DEADLINE scheduling
> + *
> + * Verifies that a task can be successfully scheduled with SCHED_DEADLINE
> + * policy and executes correctly.
> + */
> +static enum dl_test_status test_basic_scheduling_run(void *ctx)
> +{
> + pid_t pid;
> + int policy;
> + int status;
> + uint64_t runtime_ns, deadline_ns, period_ns;
> +
> + /* Use reasonable deadline parameters: 30ms/100ms/100ms */
> + runtime_ns = dl_ms_to_ns(30);
> + deadline_ns = dl_ms_to_ns(100);
> + period_ns = dl_ms_to_ns(100);
> +
> + /* Create a cpuhog process with SCHED_DEADLINE */
> + pid = dl_create_cpuhog(runtime_ns, deadline_ns, period_ns, 2);
> + DL_FAIL_IF(pid < 0, "Failed to create cpuhog process: %s",
> + strerror(errno));
> +
> + /* Process is now running with SCHED_DEADLINE set */
> + printf(" Created cpuhog with SCHED_DEADLINE (PID %d)\n", pid);
> +
> + /* Verify it's using SCHED_DEADLINE (policy 6) */
> + policy = dl_get_policy(pid);
> + DL_FAIL_IF(policy < 0, "Failed to read scheduling policy");
> + DL_EQ(policy, SCHED_DEADLINE);
> +
> + /* Alternative check using helper */
> + DL_ASSERT(dl_is_deadline_task(pid));
> +
> + printf(" cpuhog running with SCHED_DEADLINE (PID %d)\n", pid);
> +
> + /* Wait for cpuhog to complete (2 seconds) */
> + if (waitpid(pid, &status, 0) < 0) {
> + dl_cleanup_cpuhog(pid);
> + DL_FAIL("waitpid failed: %s", strerror(errno));
> + }
> +
> + /* Verify it exited successfully */
> + DL_FAIL_IF(!WIFEXITED(status), "Process did not exit normally");
> + DL_EQ(WEXITSTATUS(status), 0);
> +
> + printf(" cpuhog completed successfully\n");
> +
> + return DL_TEST_PASS;
> +}
> +
> +static struct dl_test test_basic_scheduling = {
> + .name = "basic_scheduling",
> + .description = "Verify basic SCHED_DEADLINE policy setup and
> execution",
> + .run = test_basic_scheduling_run,
> +};
> +REGISTER_DL_TEST(&test_basic_scheduling);
> +
> +/*
> + * Test: SCHED_DEADLINE parameter validation
> + *
> + * Verifies that the kernel correctly validates deadline parameters,
> + * rejecting invalid configurations and accepting valid ones.
> + */
> +static enum dl_test_status test_parameter_validation_run(void *ctx)
> +{
> + int ret;
> + uint64_t runtime_ns, deadline_ns, period_ns;
> +
> + printf(" Testing invalid parameters (runtime > deadline)...\n");
> +
> + /* Invalid: runtime (200ms) > deadline (100ms) */
> + runtime_ns = dl_ms_to_ns(200);
> + deadline_ns = dl_ms_to_ns(100);
> + period_ns = dl_ms_to_ns(100);
> +
> + ret = dl_set_sched_attr(0, runtime_ns, deadline_ns, period_ns);
> + DL_FAIL_IF(ret == 0, "Invalid parameters were accepted (runtime >
> deadline)");
> + DL_FAIL_IF(errno != EINVAL, "Expected EINVAL, got %s",
> strerror(errno));
> +
> + printf(" Invalid parameters correctly rejected with EINVAL\n");
> +
> + printf(" Testing valid parameters...\n");
> +
> + /* Valid: runtime (30ms) <= deadline (100ms) <= period (100ms) */
> + runtime_ns = dl_ms_to_ns(30);
> + deadline_ns = dl_ms_to_ns(100);
> + period_ns = dl_ms_to_ns(100);
> +
> + ret = dl_set_sched_attr(0, runtime_ns, deadline_ns, period_ns);
> + DL_FAIL_IF(ret < 0, "Valid parameters were rejected: %s",
> strerror(errno));
> +
> + printf(" Valid parameters correctly accepted\n");
> +
> + /* Reset to normal scheduling using sched_setscheduler */
> + struct sched_param param = { .sched_priority = 0 };
> +
> + sched_setscheduler(0, SCHED_OTHER, ¶m);
> +
> + return DL_TEST_PASS;
> +}
> +
> +static struct dl_test test_parameter_validation = {
> + .name = "parameter_validation",
> + .description = "Verify SCHED_DEADLINE parameter validation
> (accept/reject)",
> + .run = test_parameter_validation_run,
> +};
> +REGISTER_DL_TEST(&test_parameter_validation);
next prev parent reply other threads:[~2026-03-09 8:16 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-06 16:10 [PATCH RFC 0/7] selftests/sched: Add comprehensive SCHED_DEADLINE test suite Juri Lelli
2026-03-06 16:10 ` [PATCH RFC 1/7] selftests/sched: Add SCHED_DEADLINE test framework infrastructure Juri Lelli
2026-03-09 8:20 ` Gabriele Monaco
2026-03-09 9:10 ` Juri Lelli
2026-03-06 16:10 ` [PATCH RFC 2/7] selftests/sched: Add SCHED_DEADLINE utility library Juri Lelli
2026-03-11 9:39 ` Christian Loehle
2026-03-11 13:15 ` Juri Lelli
2026-03-06 16:10 ` [PATCH RFC 3/7] selftests/sched: Integrate SCHED_DEADLINE tests into kselftest framework Juri Lelli
2026-03-06 16:10 ` [PATCH RFC 4/7] selftests/sched: Add basic SCHED_DEADLINE functionality tests Juri Lelli
2026-03-09 8:15 ` Gabriele Monaco [this message]
2026-03-09 9:11 ` Juri Lelli
2026-03-06 16:10 ` [PATCH RFC 5/7] selftests/sched: Add SCHED_DEADLINE bandwidth tests to kselftest Juri Lelli
2026-03-11 9:31 ` Christian Loehle
2026-03-11 13:23 ` Juri Lelli
2026-03-11 13:44 ` Christian Loehle
2026-03-11 14:26 ` Christian Loehle
2026-03-12 10:43 ` Christian Loehle
2026-03-12 11:30 ` Christian Loehle
2026-03-12 14:13 ` Juri Lelli
2026-03-06 16:10 ` [PATCH RFC 6/7] selftests/sched: Add SCHED_DEADLINE fair_server " Juri Lelli
2026-03-06 16:10 ` [PATCH RFC 7/7] selftests/sched: Add SCHED_DEADLINE ENQUEUE_REPLENISH bug test Juri Lelli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=64fa81f453d7909e5669cc32284f7c9f48f2fea9.camel@redhat.com \
--to=gmonaco@redhat.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=luca.abeni@santannapisa.it \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=shuah@kernel.org \
--cc=tommaso.cucinotta@santannapisa.it \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=williams@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox