* [PATCH 0/3] sched/eevdf: Introduce functional invariants for EEVDF
@ 2025-04-23 0:20 Dhaval Giani (AMD)
2025-04-23 0:20 ` [PATCH 1/3] sched/fair: Introduce a new debugfs directory for EEVDF tests Dhaval Giani (AMD)
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Dhaval Giani (AMD) @ 2025-04-23 0:20 UTC (permalink / raw)
To: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
Valentin Schneider
Cc: linux-kernel, Dhaval Giani, Gautham Shenoy, K Prateek Nayak,
Dhaval Giani (AMD)
Introducing test cases for testing invariants for EEVDF. These are based
of the original tech report available at
https://citeseerx.ist.psu.edu/document?repid=rep1&type=pdf&doi=805acf7726282721504c8f00575d91ebfd750564
There are two invariants being tested here
1. This is based of Lemma 1 in the paper, which states that if a task
has positive lag, it is eligible. We do not test exactly this. Instead
we test if a task is eligible (which it is, if it is being to run), that
it has a positive lag.
2. This test is based of Lemma 2, which states that the sum of the lags
of all the tasks in the system is zero.
The patch series introduce a debugfs directory with triggers to run
each test.
This is not meant to enabled in production. This is a development tool
for scheduler developers
Changes since v1
- Add a tunable to change number of tasks to check for Lemma 1
- Remove the recursion in Lemma 2
- Use functions to detect overflows in Lemma 2
Signed-off-by: Dhaval Giani (AMD) <dhaval@gianis.ca>
---
Dhaval Giani (AMD) (3):
sched/fair: Introduce a new debugfs directory for EEVDF tests
sched/fair: Add a test to test that a task selected to run has positive lag
sched/fair: Test that the average lag across the system is zero
include/linux/sched.h | 7 ++
kernel/Kconfig.preempt | 9 ++
kernel/sched/Makefile | 1 +
kernel/sched/debug.c | 2 +
kernel/sched/eevdf-tests.c | 242 +++++++++++++++++++++++++++++++++++++++++++++
kernel/sched/fair.c | 5 +
kernel/sched/sched.h | 9 ++
7 files changed, 275 insertions(+)
---
base-commit: c70fc32f44431bb30f9025ce753ba8be25acbba3
change-id: 20250402-b4-eevdf-tests-v1-post-a7550c4a94cf
Best regards,
--
Dhaval Giani (AMD) <dhaval@gianis.ca>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/3] sched/fair: Introduce a new debugfs directory for EEVDF tests
2025-04-23 0:20 [PATCH 0/3] sched/eevdf: Introduce functional invariants for EEVDF Dhaval Giani (AMD)
@ 2025-04-23 0:20 ` Dhaval Giani (AMD)
2025-05-07 10:03 ` kernel test robot
2025-04-23 0:20 ` [PATCH 2/3] sched/fair: Add a test to test that a task selected to run has positive lag Dhaval Giani (AMD)
2025-04-23 0:20 ` [PATCH 3/3] sched/fair: Test that the average lag across the system is zero Dhaval Giani (AMD)
2 siblings, 1 reply; 9+ messages in thread
From: Dhaval Giani (AMD) @ 2025-04-23 0:20 UTC (permalink / raw)
To: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
Valentin Schneider
Cc: linux-kernel, Dhaval Giani, Gautham Shenoy, K Prateek Nayak,
Dhaval Giani (AMD)
To: Ingo Molnar <mingo@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
To: Juri Lelli <juri.lelli@redhat.com>
To: Vincent Guittot <vincent.guittot@linaro.org>
To: Dietmar Eggemann <dietmar.eggemann@arm.com>
To: Steven Rostedt <rostedt@goodmis.org>
To: Ben Segall <bsegall@google.com>
To: Mel Gorman <mgorman@suse.de>
To: Valentin Schneider <vschneid@redhat.com>
Cc: linux-kernel@vger.kernel.org
Cc: Dhaval Giani <dhaval.giani@amd.com>
Cc: Gautham Shenoy <gautham.shenoy@amd.com>
Cc: K Prateek Nayak <kprateek.nayak@amd.com>
Signed-off-by: Dhaval Giani (AMD) <dhaval@gianis.ca>
---
kernel/Kconfig.preempt | 9 +++++++++
kernel/sched/Makefile | 1 +
kernel/sched/debug.c | 2 ++
kernel/sched/eevdf-tests.c | 27 +++++++++++++++++++++++++++
kernel/sched/sched.h | 7 +++++++
5 files changed, 46 insertions(+)
diff --git a/kernel/Kconfig.preempt b/kernel/Kconfig.preempt
index 54ea59ff8fbeb653b7084a78bd0d933076deaad5..96f47cf498aa10d7cbb375093e5533753ed7a414 100644
--- a/kernel/Kconfig.preempt
+++ b/kernel/Kconfig.preempt
@@ -176,3 +176,12 @@ config SCHED_CLASS_EXT
For more information:
Documentation/scheduler/sched-ext.rst
https://github.com/sched-ext/scx
+
+config SCHED_EEVDF_TESTING
+ bool "EEVDF testing"
+ help
+ This option is a debug option to test that your changes to the
+ fair scheduling code do not break EEVDF invariants. There are
+ controls exposted in debugfs to allow tests to be run. This has a
+ performance impact, so do not enable unless you are a scheduler
+ developer and know what you are doing.
diff --git a/kernel/sched/Makefile b/kernel/sched/Makefile
index 8ae86371ddcddf836172ee93ca34f2e91b4057a7..1a8416b8009ebf7cf38ac7b326f4b6472e62909a 100644
--- a/kernel/sched/Makefile
+++ b/kernel/sched/Makefile
@@ -37,3 +37,4 @@ obj-y += core.o
obj-y += fair.o
obj-y += build_policy.o
obj-y += build_utility.o
+obj-y += eevdf-tests.o
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 557246880a7e0839277df662703b7bfabeb3a497..e61acd5463145e4a54dcc816c1da774922ed0127 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -536,6 +536,8 @@ static __init int sched_init_debug(void)
debugfs_fair_server_init();
+ debugfs_eevdf_testing_init(debugfs_sched);
+
return 0;
}
late_initcall(sched_init_debug);
diff --git a/kernel/sched/eevdf-tests.c b/kernel/sched/eevdf-tests.c
new file mode 100644
index 0000000000000000000000000000000000000000..3bc016d3025733e53f586e30fcd31f650156d47e
--- /dev/null
+++ b/kernel/sched/eevdf-tests.c
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/*
+ * Copyright (C) 2025 Advanced Micro Devices, Inc
+ *
+ * Author: Dhaval Giani (AMD) <dhaval@gianis.ca>
+ *
+ * Basic functional tests for EEVDF - Invariants
+ *
+ * Use the debugfs triggers to run them
+ *
+ */
+
+#include <linux/debugfs.h>
+#include <linux/sched.h>
+
+#include "sched.h"
+
+#ifdef CONFIG_SCHED_EEVDF_TESTING
+
+static struct dentry *debugfs_eevdf_testing;
+void debugfs_eevdf_testing_init(struct dentry *debugfs_sched)
+{
+ debugfs_eevdf_testing = debugfs_create_dir("eevdf-testing", debugfs_sched);
+
+}
+#endif /* CONFIG_SCHED_EEVDF_TESTING */
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index c5a6a503eb6de3867ea25f13dca3660da2805ff8..09cefe2aa871bbd533a413c76026895e969a58e7 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -44,6 +44,7 @@
#include <linux/lockdep.h>
#include <linux/minmax.h>
#include <linux/mm.h>
+#include <linux/mmu_context.h>
#include <linux/module.h>
#include <linux/mutex_api.h>
#include <linux/plist.h>
@@ -3987,4 +3988,10 @@ void sched_enq_and_set_task(struct sched_enq_and_set_ctx *ctx);
#include "ext.h"
+#ifdef CONFIG_SCHED_EEVDF_TESTING
+void debugfs_eevdf_testing_init(struct dentry *debugfs_sched);
+#else /* CONFIG_SCHED_EEVDF_TESTING */
+static inline void init_eevdf_testing_debugfs(struct dentry *debugfs_sched) {}
+#endif /* CONFIG_SCHED_EEVDF_TESTING */
+
#endif /* _KERNEL_SCHED_SCHED_H */
--
2.49.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/3] sched/fair: Add a test to test that a task selected to run has positive lag
2025-04-23 0:20 [PATCH 0/3] sched/eevdf: Introduce functional invariants for EEVDF Dhaval Giani (AMD)
2025-04-23 0:20 ` [PATCH 1/3] sched/fair: Introduce a new debugfs directory for EEVDF tests Dhaval Giani (AMD)
@ 2025-04-23 0:20 ` Dhaval Giani (AMD)
2025-05-07 10:25 ` kernel test robot
2025-04-23 0:20 ` [PATCH 3/3] sched/fair: Test that the average lag across the system is zero Dhaval Giani (AMD)
2 siblings, 1 reply; 9+ messages in thread
From: Dhaval Giani (AMD) @ 2025-04-23 0:20 UTC (permalink / raw)
To: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
Valentin Schneider
Cc: linux-kernel, Dhaval Giani, Gautham Shenoy, K Prateek Nayak,
Dhaval Giani (AMD)
Lemma 1 from the original EEVDF paper says that any task that
has a positive lag is eligible to run.
This test tests the opposite - any task that is picked to run must
have a positive lag for it to be eligible to run.
To: Ingo Molnar <mingo@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
To: Juri Lelli <juri.lelli@redhat.com>
To: Vincent Guittot <vincent.guittot@linaro.org>
To: Dietmar Eggemann <dietmar.eggemann@arm.com>
To: Steven Rostedt <rostedt@goodmis.org>
To: Ben Segall <bsegall@google.com>
To: Mel Gorman <mgorman@suse.de>
To: Valentin Schneider <vschneid@redhat.com>
Cc: linux-kernel@vger.kernel.org
Cc: Dhaval Giani <dhaval.giani@amd.com>
Cc: Gautham Shenoy <gautham.shenoy@amd.com>
Cc: K Prateek Nayak <kprateek.nayak@amd.com>
Signed-off-by: Dhaval Giani (AMD) <dhaval@gianis.ca>
---
kernel/sched/eevdf-tests.c | 41 +++++++++++++++++++++++++++++++++++++++++
kernel/sched/fair.c | 2 ++
kernel/sched/sched.h | 2 ++
3 files changed, 45 insertions(+)
diff --git a/kernel/sched/eevdf-tests.c b/kernel/sched/eevdf-tests.c
index 3bc016d3025733e53f586e30fcd31f650156d47e..8532330769bcc93dbf9cd98ebba75c838f62c045 100644
--- a/kernel/sched/eevdf-tests.c
+++ b/kernel/sched/eevdf-tests.c
@@ -18,10 +18,51 @@
#ifdef CONFIG_SCHED_EEVDF_TESTING
+/*
+ * Test parameters
+ */
+bool eevdf_positive_lag_test;
+u8 eevdf_positive_lag_count = 10;
+
static struct dentry *debugfs_eevdf_testing;
void debugfs_eevdf_testing_init(struct dentry *debugfs_sched)
{
debugfs_eevdf_testing = debugfs_create_dir("eevdf-testing", debugfs_sched);
+ debugfs_create_bool("eevdf_positive_lag_test", 0700,
+ debugfs_eevdf_testing, &eevdf_positive_lag_test);
+ debugfs_create_u8("eevdf_positive_lag_test_count", 0600,
+ debugfs_eevdf_testing, &eevdf_positive_lag_count);
+
}
+
+void test_eevdf_positive_lag(struct cfs_rq *cfs, struct sched_entity *se)
+{
+ static int eevdf_positive_lag_test_counter;
+ u64 eevdf_average_vruntime;
+
+ if (!eevdf_positive_lag_test)
+ return;
+
+ if (!se || !cfs)
+ return;
+
+ eevdf_average_vruntime = avg_vruntime(cfs);
+ eevdf_positive_lag_test_counter++;
+
+ if (se->vruntime > eevdf_average_vruntime) {
+ trace_printk("FAIL: Lemma 1 failed - selected task has negative lag\n");
+ eevdf_positive_lag_test = 0;
+ eevdf_positive_lag_test_counter = 0;
+ return;
+ }
+
+ if (eevdf_positive_lag_test_counter > eevdf_positive_lag_count) {
+ eevdf_positive_lag_test = 0;
+ eevdf_positive_lag_test_counter = 0;
+ trace_printk("PASS: At least %u selected tasks had positive lag\n",
+ eevdf_positive_lag_count);
+ }
+}
+
#endif /* CONFIG_SCHED_EEVDF_TESTING */
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index eb5a2572b4f8b6b5517befc299312b6ae7476e88..924d9d35c2aa937bc0f4ca9565ba774397b90f77 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -980,6 +980,8 @@ static struct sched_entity *pick_eevdf(struct cfs_rq *cfs_rq)
if (!best || (curr && entity_before(curr, best)))
best = curr;
+ test_eevdf_positive_lag(cfs_rq, best);
+
return best;
}
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 09cefe2aa871bbd533a413c76026895e969a58e7..5ad5e033e1c81167b712ab176d4d55e6b5d82d06 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -3990,8 +3990,10 @@ void sched_enq_and_set_task(struct sched_enq_and_set_ctx *ctx);
#ifdef CONFIG_SCHED_EEVDF_TESTING
void debugfs_eevdf_testing_init(struct dentry *debugfs_sched);
+void test_eevdf_positive_lag(struct cfs_rq *cfs, struct sched_entity *se);
#else /* CONFIG_SCHED_EEVDF_TESTING */
static inline void init_eevdf_testing_debugfs(struct dentry *debugfs_sched) {}
+static inline void test_eevdf_positive_lag(struct cfs_rq *cfs, struct sched_entity *se) {}
#endif /* CONFIG_SCHED_EEVDF_TESTING */
#endif /* _KERNEL_SCHED_SCHED_H */
--
2.49.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/3] sched/fair: Test that the average lag across the system is zero
2025-04-23 0:20 [PATCH 0/3] sched/eevdf: Introduce functional invariants for EEVDF Dhaval Giani (AMD)
2025-04-23 0:20 ` [PATCH 1/3] sched/fair: Introduce a new debugfs directory for EEVDF tests Dhaval Giani (AMD)
2025-04-23 0:20 ` [PATCH 2/3] sched/fair: Add a test to test that a task selected to run has positive lag Dhaval Giani (AMD)
@ 2025-04-23 0:20 ` Dhaval Giani (AMD)
2 siblings, 0 replies; 9+ messages in thread
From: Dhaval Giani (AMD) @ 2025-04-23 0:20 UTC (permalink / raw)
To: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
Valentin Schneider
Cc: linux-kernel, Dhaval Giani, Gautham Shenoy, K Prateek Nayak,
Dhaval Giani (AMD)
Lemma 2 of the EEVDF paper says that the sum of lags of all the
tasks in the system is zero.
The test is slightly different - the sum of lag across a runqueue is
zero.
The linux EEVDF implementation doesn't track a global vruntime.
Instead it tracks the "zero-lag" vruntime. This can be obtained by
calling avg_vruntime(cfs_rq).
Walk through every single CFS runqueue (per CPU as well as per-cgroup),
and add up the vruntimes. The average should be the same as
avg_vruntime.
To: Ingo Molnar <mingo@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
To: Juri Lelli <juri.lelli@redhat.com>
To: Vincent Guittot <vincent.guittot@linaro.org>
To: Dietmar Eggemann <dietmar.eggemann@arm.com>
To: Steven Rostedt <rostedt@goodmis.org>
To: Ben Segall <bsegall@google.com>
To: Mel Gorman <mgorman@suse.de>
To: Valentin Schneider <vschneid@redhat.com>
Cc: linux-kernel@vger.kernel.org
Cc: Dhaval Giani <dhaval.giani@amd.com>
Cc: Gautham Shenoy <gautham.shenoy@amd.com>
Cc: K Prateek Nayak <kprateek.nayak@amd.com>
Signed-off-by: Dhaval Giani (AMD) <dhaval@gianis.ca>
---
include/linux/sched.h | 7 ++
kernel/sched/eevdf-tests.c | 174 +++++++++++++++++++++++++++++++++++++++++++++
kernel/sched/fair.c | 3 +
3 files changed, 184 insertions(+)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index f96ac198289349199b9c671240a20fc7826228ad..72788d51912657919adfad7f451983e80be4fa39 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -610,6 +610,13 @@ struct sched_entity {
*/
struct sched_avg avg;
#endif
+#ifdef CONFIG_SCHED_EEVDF_TESTING
+ /*
+ * Add a list element so that we don't recurse
+ * in the EEVDF unit test
+ */
+ struct list_head tg_entry;
+#endif
};
struct sched_rt_entity {
diff --git a/kernel/sched/eevdf-tests.c b/kernel/sched/eevdf-tests.c
index 8532330769bcc93dbf9cd98ebba75c838f62c045..c343e94b9a44ad32d01a0eedcb61c1bbf5fdbaf6 100644
--- a/kernel/sched/eevdf-tests.c
+++ b/kernel/sched/eevdf-tests.c
@@ -24,6 +24,35 @@
bool eevdf_positive_lag_test;
u8 eevdf_positive_lag_count = 10;
+static int test_total_zero_lag(void *);
+static void launch_test_zero_lag(void);
+
+static int eevdf_zero_lag_show(struct seq_file *m, void *v)
+{
+ return 0;
+}
+
+static int eevdf_zero_lag_open(struct inode *inode, struct file *filp)
+{
+ return single_open(filp, eevdf_zero_lag_show, NULL);
+}
+
+static ssize_t eevdf_zero_lag_write(struct file *filp, const char __user *ubuf,
+ size_t cnt, loff_t *ppos)
+{
+ launch_test_zero_lag();
+ return 1;
+
+}
+
+static const struct file_operations eevdf_zero_lag_fops = {
+ .open = eevdf_zero_lag_open,
+ .write = eevdf_zero_lag_write,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
static struct dentry *debugfs_eevdf_testing;
void debugfs_eevdf_testing_init(struct dentry *debugfs_sched)
{
@@ -33,6 +62,8 @@ void debugfs_eevdf_testing_init(struct dentry *debugfs_sched)
debugfs_eevdf_testing, &eevdf_positive_lag_test);
debugfs_create_u8("eevdf_positive_lag_test_count", 0600,
debugfs_eevdf_testing, &eevdf_positive_lag_count);
+ debugfs_create_file("eevdf_zero_lag_test", 0700, debugfs_eevdf_testing,
+ NULL, &eevdf_zero_lag_fops);
}
@@ -65,4 +96,147 @@ void test_eevdf_positive_lag(struct cfs_rq *cfs, struct sched_entity *se)
}
}
+/*
+ * we do, what we need to do
+ */
+#define __node_2_se(node) \
+ rb_entry((node), struct sched_entity, run_node)
+
+static bool test_eevdf_cfs_rq_zero_lag(struct cfs_rq *cfs, struct list_head *tg_se)
+{
+ u64 cfs_avg_vruntime;
+ u64 calculated_avg_vruntime;
+
+ u64 total_vruntime = 0;
+ u64 nr_tasks = 0;
+
+ struct sched_entity *se;
+ struct rb_node *node;
+ struct rb_root *root;
+
+ cfs_avg_vruntime = avg_vruntime(cfs);
+
+ /*
+ * Walk through the rb tree -> look at the se->vruntime value and add it
+ */
+
+ total_vruntime = 0;
+ nr_tasks = 0;
+
+ root = &cfs->tasks_timeline.rb_root;
+
+ for (node = rb_first(root); node; node = rb_next(node)) {
+ se = __node_2_se(node);
+ WARN_ON_ONCE(__builtin_add_overflow(total_vruntime,
+ se->vruntime, &total_vruntime));
+ /*
+ * if it is a task group, add to a list to look at later
+ */
+ if (!entity_is_task(se))
+ list_add_tail(&se->tg_entry, tg_se);
+ nr_tasks++;
+ }
+
+ if (cfs->curr) {
+ WARN_ON_ONCE(__builtin_add_overflow(total_vruntime,
+ cfs->curr->vruntime, &total_vruntime));
+ nr_tasks++;
+ }
+
+ /* If there are no tasks, there is no lag :-) */
+ if (!nr_tasks)
+ return true;
+
+ calculated_avg_vruntime = total_vruntime / nr_tasks;
+
+ return (calculated_avg_vruntime == cfs_avg_vruntime);
+
+}
+
+/*
+ * Call with rq lock held
+ *
+ * return false on failure
+ */
+static bool test_eevdf_zero_lag(struct cfs_rq *cfs)
+{
+ struct list_head tg_se = LIST_HEAD_INIT(tg_se);
+ struct list_head *se_entry;
+
+ /*
+ * The base CFS runqueue will always have sched entities queued.
+ * Test it, and start populating the tg_se list.
+ *
+ * If it fails, short circuit and return fail.
+ */
+
+ if (!test_eevdf_cfs_rq_zero_lag(cfs, &tg_se))
+ return false;
+
+ /*
+ * We made it here, let's walk through the list. Since it is
+ * setup as a queue, as we continue calling the rq test, it
+ * will add new task_groups to the list. Once drained, if we
+ * haven't failed, we will return true.
+ */
+
+ list_for_each(se_entry, &tg_se) {
+ struct sched_entity *se = list_entry(se_entry, struct sched_entity, tg_entry);
+
+ if (!test_eevdf_cfs_rq_zero_lag(group_cfs_rq(se), &tg_se))
+ return false;
+ }
+
+ /*
+ * WOOT! We succeeded!
+ */
+ return true;
+
+}
+
+/*
+ * The average vruntime of the entire cfs_rq should be equal
+ * to the avg_vruntime(cfs_rq)
+ */
+static int test_total_zero_lag(void *data)
+{
+ int cpu;
+ struct rq *rq;
+ struct cfs_rq *cfs;
+ bool success = false;
+
+ for_each_online_cpu(cpu) {
+
+ rq = cpu_rq(cpu);
+ guard(rq_lock_irq)(rq);
+
+ cfs = &rq->cfs;
+
+ success = test_eevdf_zero_lag(cfs);
+
+ if (!success)
+ break;
+ }
+ if (!success) {
+ trace_printk("FAILED: tracked average vruntime doesn't match calculated average vruntime\n");
+ return -1;
+ }
+ trace_printk("PASS: Tracked average runtime matches calculated average vruntime\n");
+ return 0;
+}
+
+static void launch_test_zero_lag(void)
+{
+ struct task_struct *kt;
+
+ kt = kthread_create(&test_total_zero_lag, NULL, "eevdf-tester-%d",
+ smp_processor_id());
+ if (!kt) {
+ trace_printk("Failed to launch kthread\n");
+ return;
+ }
+
+ wake_up_process(kt);
+}
+
#endif /* CONFIG_SCHED_EEVDF_TESTING */
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 924d9d35c2aa937bc0f4ca9565ba774397b90f77..858c4e1b8fac661996d879a8dcab2776db09d1c8 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -13473,6 +13473,9 @@ void init_tg_cfs_entry(struct task_group *tg, struct cfs_rq *cfs_rq,
/* guarantee group entities always have weight */
update_load_set(&se->load, NICE_0_LOAD);
se->parent = parent;
+#ifdef CONFIG_SCHED_EEVDF_TESTING
+ INIT_LIST_HEAD(&(se->group_node));
+#endif
}
static DEFINE_MUTEX(shares_mutex);
--
2.49.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] sched/fair: Introduce a new debugfs directory for EEVDF tests
2025-04-23 0:20 ` [PATCH 1/3] sched/fair: Introduce a new debugfs directory for EEVDF tests Dhaval Giani (AMD)
@ 2025-05-07 10:03 ` kernel test robot
0 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2025-05-07 10:03 UTC (permalink / raw)
To: Dhaval Giani (AMD),
Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
Valentin Schneider
Cc: llvm, oe-kbuild-all, linux-kernel, Dhaval Giani, Gautham Shenoy,
K Prateek Nayak, Dhaval Giani (AMD)
Hi Dhaval,
kernel test robot noticed the following build errors:
[auto build test ERROR on c70fc32f44431bb30f9025ce753ba8be25acbba3]
url: https://github.com/intel-lab-lkp/linux/commits/Dhaval-Giani-AMD/sched-fair-Introduce-a-new-debugfs-directory-for-EEVDF-tests/20250423-082221
base: c70fc32f44431bb30f9025ce753ba8be25acbba3
patch link: https://lore.kernel.org/r/20250422-b4-eevdf-tests-v1-post-v1-1-35d158254c72%40gianis.ca
patch subject: [PATCH 1/3] sched/fair: Introduce a new debugfs directory for EEVDF tests
config: x86_64-kexec (https://download.01.org/0day-ci/archive/20250507/202505071739.GJbmEQJp-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250507/202505071739.GJbmEQJp-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202505071739.GJbmEQJp-lkp@intel.com/
All errors (new ones prefixed by >>):
In file included from kernel/sched/build_utility.c:71:
>> kernel/sched/debug.c:539:2: error: call to undeclared function 'debugfs_eevdf_testing_init'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
539 | debugfs_eevdf_testing_init(debugfs_sched);
| ^
1 error generated.
vim +/debugfs_eevdf_testing_init +539 kernel/sched/debug.c
534
535 debugfs_create_file("debug", 0444, debugfs_sched, NULL, &sched_debug_fops);
536
537 debugfs_fair_server_init();
538
> 539 debugfs_eevdf_testing_init(debugfs_sched);
540
541 return 0;
542 }
543 late_initcall(sched_init_debug);
544
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/3] sched/fair: Add a test to test that a task selected to run has positive lag
2025-04-23 0:20 ` [PATCH 2/3] sched/fair: Add a test to test that a task selected to run has positive lag Dhaval Giani (AMD)
@ 2025-05-07 10:25 ` kernel test robot
0 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2025-05-07 10:25 UTC (permalink / raw)
To: Dhaval Giani (AMD),
Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
Valentin Schneider
Cc: oe-kbuild-all, linux-kernel, Dhaval Giani, Gautham Shenoy,
K Prateek Nayak, Dhaval Giani (AMD)
Hi Dhaval,
kernel test robot noticed the following build warnings:
[auto build test WARNING on c70fc32f44431bb30f9025ce753ba8be25acbba3]
url: https://github.com/intel-lab-lkp/linux/commits/Dhaval-Giani-AMD/sched-fair-Introduce-a-new-debugfs-directory-for-EEVDF-tests/20250423-082221
base: c70fc32f44431bb30f9025ce753ba8be25acbba3
patch link: https://lore.kernel.org/r/20250422-b4-eevdf-tests-v1-post-v1-2-35d158254c72%40gianis.ca
patch subject: [PATCH 2/3] sched/fair: Add a test to test that a task selected to run has positive lag
config: mips-randconfig-r121-20250426 (https://download.01.org/0day-ci/archive/20250507/202505071826.dQRr4AyC-lkp@intel.com/config)
compiler: mips-linux-gcc (GCC) 10.5.0
reproduce: (https://download.01.org/0day-ci/archive/20250507/202505071826.dQRr4AyC-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202505071826.dQRr4AyC-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
>> kernel/sched/eevdf-tests.c:24:6: sparse: sparse: symbol 'eevdf_positive_lag_test' was not declared. Should it be static?
>> kernel/sched/eevdf-tests.c:25:4: sparse: sparse: symbol 'eevdf_positive_lag_count' was not declared. Should it be static?
vim +/eevdf_positive_lag_test +24 kernel/sched/eevdf-tests.c
20
21 /*
22 * Test parameters
23 */
> 24 bool eevdf_positive_lag_test;
> 25 u8 eevdf_positive_lag_count = 10;
26
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] sched/fair: Introduce a new debugfs directory for EEVDF tests
2025-04-23 0:15 [PATCH 1/3] sched/fair: Introduce a new debugfs directory for EEVDF tests Dhaval Giani (AMD)
@ 2025-05-07 6:56 ` kernel test robot
0 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2025-05-07 6:56 UTC (permalink / raw)
To: Dhaval Giani (AMD)
Cc: oe-kbuild-all, linux-kernel, Dhaval Giani, Gautham Shenoy,
K Prateek Nayak, Dhaval Giani (AMD)
Hi Dhaval,
kernel test robot noticed the following build errors:
[auto build test ERROR on tip/sched/core]
[also build test ERROR on linus/master v6.15-rc5 next-20250506]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Dhaval-Giani-AMD/sched-fair-Add-a-test-to-test-that-a-task-selected-to-run-has-positive-lag/20250423-081648
base: tip/sched/core
patch link: https://lore.kernel.org/r/20250422-b4-eevdf-tests-v1-post-v1-1-5b174f040f55%40gianis.ca
patch subject: [PATCH 1/3] sched/fair: Introduce a new debugfs directory for EEVDF tests
config: arc-allnoconfig (https://download.01.org/0day-ci/archive/20250507/202505071441.9cwPFBsc-lkp@intel.com/config)
compiler: arc-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250507/202505071441.9cwPFBsc-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202505071441.9cwPFBsc-lkp@intel.com/
All errors (new ones prefixed by >>):
In file included from kernel/sched/build_utility.c:71:
kernel/sched/debug.c: In function 'sched_init_debug':
>> kernel/sched/debug.c:539:9: error: implicit declaration of function 'debugfs_eevdf_testing_init' [-Wimplicit-function-declaration]
539 | debugfs_eevdf_testing_init(debugfs_sched);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
vim +/debugfs_eevdf_testing_init +539 kernel/sched/debug.c
534
535 debugfs_create_file("debug", 0444, debugfs_sched, NULL, &sched_debug_fops);
536
537 debugfs_fair_server_init();
538
> 539 debugfs_eevdf_testing_init(debugfs_sched);
540
541 return 0;
542 }
543 late_initcall(sched_init_debug);
544
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/3] sched/fair: Introduce a new debugfs directory for EEVDF tests
@ 2025-04-23 0:15 Dhaval Giani (AMD)
2025-05-07 6:56 ` kernel test robot
0 siblings, 1 reply; 9+ messages in thread
From: Dhaval Giani (AMD) @ 2025-04-23 0:15 UTC (permalink / raw)
Cc: linux-kernel, Dhaval Giani, Gautham Shenoy, K Prateek Nayak,
Dhaval Giani (AMD)
Signed-off-by: Dhaval Giani (AMD) <dhaval@gianis.ca>
---
kernel/Kconfig.preempt | 9 +++++++++
kernel/sched/Makefile | 1 +
kernel/sched/debug.c | 2 ++
kernel/sched/eevdf-tests.c | 27 +++++++++++++++++++++++++++
kernel/sched/sched.h | 7 +++++++
5 files changed, 46 insertions(+)
diff --git a/kernel/Kconfig.preempt b/kernel/Kconfig.preempt
index 54ea59ff8fbeb653b7084a78bd0d933076deaad5..96f47cf498aa10d7cbb375093e5533753ed7a414 100644
--- a/kernel/Kconfig.preempt
+++ b/kernel/Kconfig.preempt
@@ -176,3 +176,12 @@ config SCHED_CLASS_EXT
For more information:
Documentation/scheduler/sched-ext.rst
https://github.com/sched-ext/scx
+
+config SCHED_EEVDF_TESTING
+ bool "EEVDF testing"
+ help
+ This option is a debug option to test that your changes to the
+ fair scheduling code do not break EEVDF invariants. There are
+ controls exposted in debugfs to allow tests to be run. This has a
+ performance impact, so do not enable unless you are a scheduler
+ developer and know what you are doing.
diff --git a/kernel/sched/Makefile b/kernel/sched/Makefile
index 8ae86371ddcddf836172ee93ca34f2e91b4057a7..1a8416b8009ebf7cf38ac7b326f4b6472e62909a 100644
--- a/kernel/sched/Makefile
+++ b/kernel/sched/Makefile
@@ -37,3 +37,4 @@ obj-y += core.o
obj-y += fair.o
obj-y += build_policy.o
obj-y += build_utility.o
+obj-y += eevdf-tests.o
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 557246880a7e0839277df662703b7bfabeb3a497..e61acd5463145e4a54dcc816c1da774922ed0127 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -536,6 +536,8 @@ static __init int sched_init_debug(void)
debugfs_fair_server_init();
+ debugfs_eevdf_testing_init(debugfs_sched);
+
return 0;
}
late_initcall(sched_init_debug);
diff --git a/kernel/sched/eevdf-tests.c b/kernel/sched/eevdf-tests.c
new file mode 100644
index 0000000000000000000000000000000000000000..3bc016d3025733e53f586e30fcd31f650156d47e
--- /dev/null
+++ b/kernel/sched/eevdf-tests.c
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/*
+ * Copyright (C) 2025 Advanced Micro Devices, Inc
+ *
+ * Author: Dhaval Giani (AMD) <dhaval@gianis.ca>
+ *
+ * Basic functional tests for EEVDF - Invariants
+ *
+ * Use the debugfs triggers to run them
+ *
+ */
+
+#include <linux/debugfs.h>
+#include <linux/sched.h>
+
+#include "sched.h"
+
+#ifdef CONFIG_SCHED_EEVDF_TESTING
+
+static struct dentry *debugfs_eevdf_testing;
+void debugfs_eevdf_testing_init(struct dentry *debugfs_sched)
+{
+ debugfs_eevdf_testing = debugfs_create_dir("eevdf-testing", debugfs_sched);
+
+}
+#endif /* CONFIG_SCHED_EEVDF_TESTING */
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index c5a6a503eb6de3867ea25f13dca3660da2805ff8..09cefe2aa871bbd533a413c76026895e969a58e7 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -44,6 +44,7 @@
#include <linux/lockdep.h>
#include <linux/minmax.h>
#include <linux/mm.h>
+#include <linux/mmu_context.h>
#include <linux/module.h>
#include <linux/mutex_api.h>
#include <linux/plist.h>
@@ -3987,4 +3988,10 @@ void sched_enq_and_set_task(struct sched_enq_and_set_ctx *ctx);
#include "ext.h"
+#ifdef CONFIG_SCHED_EEVDF_TESTING
+void debugfs_eevdf_testing_init(struct dentry *debugfs_sched);
+#else /* CONFIG_SCHED_EEVDF_TESTING */
+static inline void init_eevdf_testing_debugfs(struct dentry *debugfs_sched) {}
+#endif /* CONFIG_SCHED_EEVDF_TESTING */
+
#endif /* _KERNEL_SCHED_SCHED_H */
--
2.49.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/3] sched/fair: Introduce a new debugfs directory for EEVDF tests
2025-04-23 0:10 [PATCH 0/3] sched/eevdf: Introduce functional invariants for EEVDF Dhaval Giani (AMD)
@ 2025-04-23 0:11 ` Dhaval Giani (AMD)
0 siblings, 0 replies; 9+ messages in thread
From: Dhaval Giani (AMD) @ 2025-04-23 0:11 UTC (permalink / raw)
Cc: linux-kernel, Dhaval Giani, Gautham Shenoy, K Prateek Nayak,
Dhaval Giani (AMD)
Signed-off-by: Dhaval Giani (AMD) <dhaval@gianis.ca>
---
kernel/Kconfig.preempt | 9 +++++++++
kernel/sched/Makefile | 1 +
kernel/sched/debug.c | 2 ++
kernel/sched/eevdf-tests.c | 27 +++++++++++++++++++++++++++
kernel/sched/sched.h | 7 +++++++
5 files changed, 46 insertions(+)
diff --git a/kernel/Kconfig.preempt b/kernel/Kconfig.preempt
index 54ea59ff8fbeb653b7084a78bd0d933076deaad5..96f47cf498aa10d7cbb375093e5533753ed7a414 100644
--- a/kernel/Kconfig.preempt
+++ b/kernel/Kconfig.preempt
@@ -176,3 +176,12 @@ config SCHED_CLASS_EXT
For more information:
Documentation/scheduler/sched-ext.rst
https://github.com/sched-ext/scx
+
+config SCHED_EEVDF_TESTING
+ bool "EEVDF testing"
+ help
+ This option is a debug option to test that your changes to the
+ fair scheduling code do not break EEVDF invariants. There are
+ controls exposted in debugfs to allow tests to be run. This has a
+ performance impact, so do not enable unless you are a scheduler
+ developer and know what you are doing.
diff --git a/kernel/sched/Makefile b/kernel/sched/Makefile
index 8ae86371ddcddf836172ee93ca34f2e91b4057a7..1a8416b8009ebf7cf38ac7b326f4b6472e62909a 100644
--- a/kernel/sched/Makefile
+++ b/kernel/sched/Makefile
@@ -37,3 +37,4 @@ obj-y += core.o
obj-y += fair.o
obj-y += build_policy.o
obj-y += build_utility.o
+obj-y += eevdf-tests.o
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 557246880a7e0839277df662703b7bfabeb3a497..e61acd5463145e4a54dcc816c1da774922ed0127 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -536,6 +536,8 @@ static __init int sched_init_debug(void)
debugfs_fair_server_init();
+ debugfs_eevdf_testing_init(debugfs_sched);
+
return 0;
}
late_initcall(sched_init_debug);
diff --git a/kernel/sched/eevdf-tests.c b/kernel/sched/eevdf-tests.c
new file mode 100644
index 0000000000000000000000000000000000000000..3bc016d3025733e53f586e30fcd31f650156d47e
--- /dev/null
+++ b/kernel/sched/eevdf-tests.c
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/*
+ * Copyright (C) 2025 Advanced Micro Devices, Inc
+ *
+ * Author: Dhaval Giani (AMD) <dhaval@gianis.ca>
+ *
+ * Basic functional tests for EEVDF - Invariants
+ *
+ * Use the debugfs triggers to run them
+ *
+ */
+
+#include <linux/debugfs.h>
+#include <linux/sched.h>
+
+#include "sched.h"
+
+#ifdef CONFIG_SCHED_EEVDF_TESTING
+
+static struct dentry *debugfs_eevdf_testing;
+void debugfs_eevdf_testing_init(struct dentry *debugfs_sched)
+{
+ debugfs_eevdf_testing = debugfs_create_dir("eevdf-testing", debugfs_sched);
+
+}
+#endif /* CONFIG_SCHED_EEVDF_TESTING */
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index c5a6a503eb6de3867ea25f13dca3660da2805ff8..09cefe2aa871bbd533a413c76026895e969a58e7 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -44,6 +44,7 @@
#include <linux/lockdep.h>
#include <linux/minmax.h>
#include <linux/mm.h>
+#include <linux/mmu_context.h>
#include <linux/module.h>
#include <linux/mutex_api.h>
#include <linux/plist.h>
@@ -3987,4 +3988,10 @@ void sched_enq_and_set_task(struct sched_enq_and_set_ctx *ctx);
#include "ext.h"
+#ifdef CONFIG_SCHED_EEVDF_TESTING
+void debugfs_eevdf_testing_init(struct dentry *debugfs_sched);
+#else /* CONFIG_SCHED_EEVDF_TESTING */
+static inline void init_eevdf_testing_debugfs(struct dentry *debugfs_sched) {}
+#endif /* CONFIG_SCHED_EEVDF_TESTING */
+
#endif /* _KERNEL_SCHED_SCHED_H */
--
2.49.0
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-05-07 10:26 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-23 0:20 [PATCH 0/3] sched/eevdf: Introduce functional invariants for EEVDF Dhaval Giani (AMD)
2025-04-23 0:20 ` [PATCH 1/3] sched/fair: Introduce a new debugfs directory for EEVDF tests Dhaval Giani (AMD)
2025-05-07 10:03 ` kernel test robot
2025-04-23 0:20 ` [PATCH 2/3] sched/fair: Add a test to test that a task selected to run has positive lag Dhaval Giani (AMD)
2025-05-07 10:25 ` kernel test robot
2025-04-23 0:20 ` [PATCH 3/3] sched/fair: Test that the average lag across the system is zero Dhaval Giani (AMD)
-- strict thread matches above, loose matches on Subject: below --
2025-04-23 0:15 [PATCH 1/3] sched/fair: Introduce a new debugfs directory for EEVDF tests Dhaval Giani (AMD)
2025-05-07 6:56 ` kernel test robot
2025-04-23 0:10 [PATCH 0/3] sched/eevdf: Introduce functional invariants for EEVDF Dhaval Giani (AMD)
2025-04-23 0:11 ` [PATCH 1/3] sched/fair: Introduce a new debugfs directory for EEVDF tests Dhaval Giani (AMD)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®