From: Jonathan Bastari Thamrin via B4 Relay <devnull+thamrinjonathan.gmail.com@kernel.org>
To: Tejun Heo <tj@kernel.org>, David Vernet <void@manifault.com>,
Andrea Righi <arighi@nvidia.com>,
Changwoo Min <changwoo@igalia.com>,
Shuah Khan <shuah@kernel.org>,
Joel Fernandes <joelagnelf@nvidia.com>,
Emil Tsalapatis <emil@etsalapatis.com>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>
Cc: sched-ext@lists.linux.dev, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org,
Ihor Solodrai <ihor.solodrai@linux.dev>,
Cheng-Yang Chou <yphbchou0911@gmail.com>,
Jonathan Bastari Thamrin <thamrinjonathan@gmail.com>
Subject: [PATCH sched_ext for-7.4-fixes] selftests/sched_ext: Measure rt_stall runtime over sleep window only
Date: Sat, 14 Nov 2026 14:34:26 +0700 [thread overview]
Message-ID: <20261114-scx-rt-stall-v1-1-4188a9378067@gmail.com> (raw)
From: Jonathan Bastari Thamrin <thamrinjonathan@gmail.com>
In sched_stress_test(), the parent can be slow to start as it has
to wait for the DL server before reaching sleep() while the RT task
still runs. The runtime of each task is read as a total since fork
instead of during sleep(). This adds extra time to RT and makes the
ratio inaccurate which causes flaky failures on CI.
With the parent pinned to CORE_ID, the RT task had already run for
~0.95s before sleep(), so it was measured at 5.69s in a 5s window and
the EXT share dropped to ~4.2% against the 4% threshold. CI has seen
3.0-3.9%.
Measure CPU time right before calling sleep() and use deltas to get
an accurate measurement window. With the parent pinned to CORE_ID, RT
measures 4.75s and EXT share stays between 4.81% and 5.57% over 20
runs.
Fixes: be621a76341c ("selftests/sched_ext: Add test for sched_ext dl_server")
Link: https://github.com/kernel-patches/vmtest/issues/458
Cc: Ihor Solodrai <ihor.solodrai@linux.dev>
Cc: Cheng-Yang Chou <yphbchou0911@gmail.com>
Signed-off-by: Jonathan Bastari Thamrin <thamrinjonathan@gmail.com>
---
tools/testing/selftests/sched_ext/rt_stall.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/sched_ext/rt_stall.c b/tools/testing/selftests/sched_ext/rt_stall.c
index a1552b38a6e8..0c6403d25298 100644
--- a/tools/testing/selftests/sched_ext/rt_stall.c
+++ b/tools/testing/selftests/sched_ext/rt_stall.c
@@ -149,7 +149,7 @@ static bool sched_stress_test(bool is_ext)
const float expected_min_ratio = 0.04; /* 4% */
const char *class_str = is_ext ? "EXT" : "FAIR";
- float ext_runtime, rt_runtime, actual_ratio;
+ float ext_runtime_start, rt_runtime_start, ext_runtime, rt_runtime, actual_ratio;
int ext_pid, rt_pid;
int ext_ready[2], rt_ready[2];
bool ret = false;
@@ -201,6 +201,23 @@ static bool sched_stress_test(bool is_ext)
if (!wait_ready(ext_ready[0]) || !wait_ready(rt_ready[0]))
goto out_kill;
+ /*
+ * The parent can be delayed before reaching sleep(). Record each task's
+ * CPU time right before calling sleep() so only time used during the
+ * measurement window is counted.
+ */
+ ext_runtime_start = get_process_runtime(ext_pid);
+ if (ext_runtime_start == -1) {
+ fprintf(stderr, "Failed to read %s task runtime\n", class_str);
+ goto out_kill;
+ }
+
+ rt_runtime_start = get_process_runtime(rt_pid);
+ if (rt_runtime_start == -1) {
+ fprintf(stderr, "Failed to read RT task runtime\n");
+ goto out_kill;
+ }
+
/* Let the processes run for the specified time */
sleep(RUN_TIME);
@@ -218,6 +235,8 @@ static bool sched_stress_test(bool is_ext)
goto out_kill;
}
+ ext_runtime = ext_runtime - ext_runtime_start;
+ rt_runtime = rt_runtime - rt_runtime_start;
/* Verify that the scx task got enough runtime */
actual_ratio = ext_runtime / (ext_runtime + rt_runtime);
fprintf(stderr, "%s task ran %.3fs, RT task ran %.3fs (%.2f%% of runtime)\n",
---
base-commit: 0021f17128de5dc0b19f1a523f448df2440d8088
change-id: 20261114-scx-rt-stall-ca1767a8ab4f
Best regards,
--
Jonathan Bastari Thamrin <thamrinjonathan@gmail.com>
next reply other threads:[~2026-11-14 7:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-14 7:34 Jonathan Bastari Thamrin via B4 Relay [this message]
2026-11-14 9:33 ` Andrea Righi
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=20261114-scx-rt-stall-v1-1-4188a9378067@gmail.com \
--to=devnull+thamrinjonathan.gmail.com@kernel.org \
--cc=arighi@nvidia.com \
--cc=changwoo@igalia.com \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=joelagnelf@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=sched-ext@lists.linux.dev \
--cc=shuah@kernel.org \
--cc=thamrinjonathan@gmail.com \
--cc=tj@kernel.org \
--cc=void@manifault.com \
--cc=yphbchou0911@gmail.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
all inboxes | Powered by JetHome®