From: sashiko-bot@kernel.org
To: "Andrea Righi" <arighi@nvidia.com>
Cc: sched-ext@lists.linux.dev
Subject: Re: [PATCH 2/2] selftests/sched_ext: Validate dl_server attach/detach in total_bw test
Date: Thu, 21 May 2026 18:31:52 +0000 [thread overview]
Message-ID: <20260521183152.ED89C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260521174509.1534623-3-arighi@nvidia.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] Unchecked return value of fclose() in write_server_param() masks kernel-level debugfs write failures.
- [Medium] The test incorrectly assumes all CPUs share the same fair_server runtime and globally restores CPU 0's value to all CPUs.
- [Medium] Early exit in write_fair_runtime_all() prevents full system state restoration if a single CPU write fails during cleanup.
--
commit 694643dec460b3df43c360074223ec82f5be4cc8
Author: Andrea Righi <arighi@nvidia.com>
selftests/sched_ext: Validate dl_server attach/detach in total_bw test
Extend the total_bw selftest to validate the fair/ext dl_server
auto-attach/detach operations.
> diff --git a/tools/testing/selftests/sched_ext/total_bw.c b/tools/testing/selftests/sched_ext/total_bw.c
> index 5b0a619bab86e..8eea12e8868ac 100644
> --- a/tools/testing/selftests/sched_ext/total_bw.c
> +++ b/tools/testing/selftests/sched_ext/total_bw.c
[ ... ]
> @@ -100,6 +100,66 @@ static int read_total_bw_values(long *bw_values, int max_cpus)
[ ... ]
> +static int write_server_param(const char *server, const char *param,
> + int cpu, long value)
> +{
> + char path[128];
> + FILE *fp;
> + int ret = 0;
> +
> + snprintf(path, sizeof(path),
> + "/sys/kernel/debug/sched/%s_server/cpu%d/%s",
> + server, cpu, param);
> + fp = fopen(path, "w");
> + if (!fp)
> + return -1;
> + if (fprintf(fp, "%ld", value) < 0)
> + ret = -1;
> + fclose(fp);
[Severity: Medium]
Since FILE streams are fully buffered or line-buffered by default and
fprintf() writes a string without a newline, couldn't the actual write()
syscall to debugfs be triggered during fclose()?
If the kernel rejects the write (e.g., due to admission control), fclose()
would return EOF but fprintf() would have succeeded. By ignoring the fclose()
return value, could this incorrectly return 0 (success) even when the
parameter was not updated?
> +
> + return ret;
> +}
> +
> +static int write_fair_runtime_all(int nr_cpus, long value)
> +{
> + int i;
> +
> + for (i = 0; i < nr_cpus; i++) {
> + if (write_server_param("fair", "runtime", i, value) < 0) {
> + SCX_ERR("Failed to write fair_server runtime on CPU %d", i);
> + return -1;
[Severity: Medium]
If a single CPU write fails when this function is called from the cleanup
path, this early return will abort the loop. Could this prevent the remaining
CPUs from being restored to their original fair_server runtimes, leaving the
system in a permanently customized state?
> + }
> + }
> +
> + return 0;
> +}
[ ... ]
> @@ -217,6 +277,9 @@ static enum scx_test_status run(void *ctx)
[ ... ]
> + original_runtime = read_server_param("fair", "runtime", 0);
> + if (original_runtime <= 0) {
> + fprintf(stderr, "Skipping attach/detach validation: debugfs not accessible\n");
> + return SCX_TEST_PASS;
> + }
> + doubled_runtime = original_runtime * 2;
> +
> + fprintf(stderr,
> + "Setting fair_server runtime to %ld ns on all CPUs (orig %ld)\n",
> + doubled_runtime, original_runtime);
> +
> + if (write_fair_runtime_all(test_ctx->nr_cpus, doubled_runtime) < 0) {
> + ret = SCX_TEST_FAIL;
> + goto restore;
> + }
[Severity: Medium]
This reads the original fair_server runtime from CPU 0 only, and then
eventually restores this same value to all CPUs during cleanup.
On heterogeneous systems (like big.LITTLE) or manually tuned systems, CPUs may
have different initial runtimes. Does this destructively overwrite all unique
per-CPU runtimes with CPU 0's value after the test completes?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260521174509.1534623-1-arighi@nvidia.com?part=2
next prev parent reply other threads:[~2026-05-21 18:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-21 17:33 [PATCHSET sched_ext/for-7.2] sched_ext: Auto-manage ext/fair dl_server bandwidth Andrea Righi
2026-05-21 17:33 ` [PATCH 1/2] sched_ext: Auto-register/unregister dl_server reservations Andrea Righi
2026-05-21 18:23 ` sashiko-bot
2026-05-22 8:36 ` Peter Zijlstra
2026-05-22 10:02 ` Andrea Righi
2026-05-21 17:33 ` [PATCH 2/2] selftests/sched_ext: Validate dl_server attach/detach in total_bw test Andrea Righi
2026-05-21 18:31 ` sashiko-bot [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-05-26 8:27 [PATCHSET v2 sched_ext/for-7.2] sched_ext: Auto-manage ext/fair dl_server bandwidth Andrea Righi
2026-05-26 8:27 ` [PATCH 2/2] selftests/sched_ext: Validate dl_server attach/detach in total_bw test Andrea Righi
2026-05-26 16:42 [PATCHSET v3 sched_ext/for-7.2] sched_ext: Auto-manage ext/fair dl_server bandwidth Andrea Righi
2026-05-26 16:42 ` [PATCH 2/2] selftests/sched_ext: Validate dl_server attach/detach in total_bw test Andrea Righi
2026-05-26 17:33 ` sashiko-bot
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=20260521183152.ED89C1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=arighi@nvidia.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sched-ext@lists.linux.dev \
/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