From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796320563; b=0U28udpy88BVpWFN+bJ4Z1g3yq5ESh1wCzsNxiDcY4i7QbTuz4UhJUlCTaTF/BMUOxmH Zo7qSjAIxyt3ouWY4YsygWPQsuejNAuIl1jdUgU/asU4H6voKPElf7IjYJY5NNlCPrd2R i0uIj5lcBixBS4TY0YPxKoRapYFqbwYlndKeQ9Jr8uJrBneEGpgt/A9kyO96NeeIKtHWs PbXrio7JeP7bUV9iuVleFQ0ZVWpzYjk4pA1dyRZUipgMReGbmdmJ1/5LnMAPUBJML1abs omTtXC7zC05A9IJV0+CwFwhWYkn7u/RGXXVOcXxFxrU+q28sj2e2DfmeFzpcyGzu4rw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796320563; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=zVbpYw51kymTEtfA7ar+8HjWuK5WLxrPkPyZbcnz/Tk=; b=d/fYozgzdyL+MBmmK2cjwn8LdGrXvRsnENOc3voGfBb9UP6hwQpFcZHoHzTVJwzET/3P bqdzB8COMcD0SMKvk9HgEWjxz/R5eQBC7Sh/gamlDHGT6ZlZfh+AERGWz+fv3Mru3Nkte yYSwGDvUHJP6pjswUfkms+82oMJPa1vk4fBACN6VvY4DbcPDlA7R4kinSOIavcgCcFjtX sDIz1y8Srv2SjcVHunRfZfx1wPlhFenezMheFB6uOb7A/ykBFVQMAunfR/JIIZXSTfCr3 a1IIFUnMedxQiUx3ITtp63WhYPHFTgD1BIhvuWASkO86iOPRfOJMykKNzP3+ZJj+kFA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=C0CdutOy; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C117606A33A; Thu, 3 Dec 2026 17:56:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=C0CdutOy Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6FD481F00926; Thu, 3 Dec 2026 17:56:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796320562; bh=zVbpYw51kymTEtfA7ar+8HjWuK5WLxrPkPyZbcnz/Tk=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=C0CdutOyf2WGkMdCPO/h3n2NTSbgN6+8TMW+GAhqBVem4ZM4fKrFwt3qByAy1r+ld irELSiBqYpe/5yrjUAEomVESO+BTZszGGqPO9yu2zjEMoRZl26qN1ORARnUxaG3mjk jSh4T1t3lmIzDGp2qkBm5KZeq9FdemCz0uG/vwf0PT0Z+XiHLaogD3h2l3tnfU2rLH OxiuNOsTkhnTnavsRwqZlT3UGh3Yrr8JYWHR4Hm5UOiQtfWJqm/BXH617Gw7e0y1NX gV5C5Q06W4VnfvQpZhv74tfmjayWe7+JB+GHxYItcYkk3kYTL7XU2i+XAif6dTTPoR ZgTwkg8ehvnNg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v14 33/39] selftests/sched: Test parameter changes in deadline_bw_test Reply-To: sashiko-reviews@lists.linux.dev To: "Mathieu Desnoyers" Cc: linux-rt-devel@lists.linux.dev, tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, linux-kernel@vger.kernel.org In-Reply-To: <79fec47f037759dc9473351f7f718bb6f570a6a0.1796296313.git.mathieu.desnoyers@efficios.com> References: <79fec47f037759dc9473351f7f718bb6f570a6a0.1796296313.git.mathieu.desnoyers@efficios.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 17:56:02 +0000 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 9 potential issues to consider: - [Medium] selftests/sched: run_p_cases() skips debt wait without debugfs - [Low] selftests/sched: reenter_runnable_in_gap() 2ms window races with SCHED_OTHER - [Low] selftests/sched: reenter_pi_blocked_in_gap() fails instead of skipping ENOSYS - [Low] selftests/sched: constrained_after_job() fails instead of skipping on EBUSY - [Low] selftests/sched: params_swap_overload() uses unchecked zero t0 on stall - [Low] selftests/sched: timeout checked before syscall error in params_return_full() - [Low] selftests/sched: ignored negative error from probe() in params_return_full() - [Low] selftests/sched: stale exited TID used on admission error in deadline_bw_test - [Low] selftests/sched: redundant sched/debug scans and 40s waits in run_p_cases() -- commit 35a6d94959219214223fe0bdf45f6150f74deca4 Author: Mathieu Desnoyers selftests/sched: Test parameter changes in deadline_bw_test This commit adds 25 test cases to deadline_bw_test covering SCHED_DEADLINE parameter changes, constrained-deadline gap re-entry, and bandwidth retention, and adds post-case bandwidth drain waits in run_p_cases(). > diff --git a/tools/testing/selftests/sched/deadline/deadline_bw_test.c b/= tools/testing/selftests/sched/deadline/deadline_bw_test.c > index dbe0de739e476..58ec444cf1bbf 100644 > --- a/tools/testing/selftests/sched/deadline/deadline_bw_test.c > +++ b/tools/testing/selftests/sched/deadline/deadline_bw_test.c [ ... ] > @@ -1455,6 +1477,82 @@ static int params_refused(void) [ ... ] > + err =3D set_other(t_tid); > + if (!err) > + err =3D set_deadline(t_tid, 60 * NSEC_PER_MSEC, PERIOD); > + slept =3D now_ns() - rt_t_slept; > + if (slept > 15 * NSEC_PER_MSEC) { > + /* Too late: the 0-lag time may have passed. */ > + ksft_print_msg("T switched back %llums after it slept\n", > + (unsigned long long)(slept / NSEC_PER_MSEC)); > + ret =3D KSFT_SKIP; > + } else if (err) { > + ksft_print_msg("T refused back as a deadline task: %s\n", strerror(-er= r)); > + ret =3D KSFT_FAIL; > + } [Severity: Low] Should err be checked before slept > 15 * NSEC_PER_MSEC here? Passing T's 0-lag time releases its old 60% bandwidth, so a late switch can only make a zero err inconclusive. A non-zero err (such as -EBUSY on a kernel without the fix) is still a real failure, but checking slept first downgrades it to KSFT_SKIP whenever jitter pushes slept past 15ms. > + if (ret =3D=3D KSFT_PASS && probe(NULL) >=3D 6) { > + ksft_print_msg("P has room for two tasks of 60%%\n"); > + ret =3D KSFT_SKIP; > + } [Severity: Low] What happens if probe(NULL) fails and returns -1 here? -1 >=3D 6 is false, so a probe() error falls through as KSFT_PASS without verifying that P lacks room for two 60% tasks. Capturing the return value and handling < 0 (as measured() does) would avoid masking probe failures. [ ... ] > @@ -1867,169 +1966,1833 @@ static void *refill_owner(void *arg) [ ... ] > + shrink_tid =3D gettid_(); > + err =3D set_deadline(0, 10 * NSEC_PER_MSEC, PERIOD); > + t0 =3D now_ns(); > + shrink_t0 =3D t0; > + sem_post(&shrink_ready); > + if (err) { > + ksft_print_msg("T refused as a deadline task: %s\n", strerror(-err)); > + return (void *)1; > + } [Severity: Low] Can wake_after_deadline_shrunk() operate on a stale TID when set_deadline() fails in shrink_t()? shrink_t() posts shrink_ready and exits immediately on error without recording an error flag, which autoreaps the thread and releases shrink_tid before pthread_join(). wake_after_deadline_shrunk() then sleeps until 105ms and calls proc_state_of(shrink_tid) and set_constrained(shrink_tid, ...) on the exited TID. The same pattern appears in widen_t()/deadline_widened_asleep(), shorten_t()/shorten_case(), and flip_t()/params_flip_no_gain(); storing err before sem_post() and aborting early (as pr_h() and vic_b() do) would avoid it. [ ... ] > +static void *cmix_a(void *arg) > +{ > + int err =3D set_deadline(0, 15 * NSEC_PER_MSEC, PERIOD); > + > + if (err) { > + ksft_print_msg("A refused as a deadline task: %s\n", strerror(-err)); > + cmix_stop =3D 1; > + sem_post(&cmix_go); > + return (void *)1; > + } [Severity: Low] Should constrained_after_job() return KSFT_SKIP instead of KSFT_FAIL when cmix_a() or cmix_b() gets -EBUSY? Together with the 5% fair server, B (75%) and A (15%) require the full 95% default admission limit. On systems where sched_rt_runtime_us is lower or the fair/ext server reserves more than 5%, set_deadline() returns -EBUSY, which currently fails the test rather than skipping as params_swap_overload() does. [ ... ] > + rb2_t_locking =3D 1; > + if (syscall(SYS_futex, &rb2_pi, FUTEX_LOCK_PI | FUTEX_PRIVATE_FLAG, > + 0, NULL, NULL, 0)) { > + ksft_print_msg("FUTEX_LOCK_PI: %s\n", strerror(errno)); > + set_other(0); > + return (void *)1; > + } [Severity: Low] Should reenter_pi_blocked_in_gap() skip on ENOSYS and wake the main thread immediately if FUTEX_LOCK_PI fails? Unlike the other PI cases, this one bypasses pi_init() and invokes FUTEX_LOCK_PI directly, which returns -ENOSYS when CONFIG_FUTEX_PI is disabled. Because rb2_t() returns without setting rb2_t_locking negative, the main thread stalls for the full 1s wait_for() timeout and returns KSFT_FAIL instead of KSFT_SKIP. [ ... ] > + while (!rr_stop) { > + uint64_t t =3D now_ns(), b =3D rr_back_at; > + > + if (b && !rr_t_ran && t > b + 2 * NSEC_PER_MSEC) > + rr_t_ran =3D t; > + } [ ... ] > + /* Store it before the switch back. A T given a new period runs at once= . */ > + rr_back_at =3D now_ns(); > + err =3D set_constrained(rr_t_tid, 10 * NSEC_PER_MSEC, 20 * NSEC_PER_MSE= C, 5 * PERIOD); [Severity: Low] Can the 2ms grace window in rr_t() expire while T is still running as SCHED_OTHER, causing a false failure in reenter_runnable_in_gap()? Both threads share P's single CPU, and T is already runnable as SCHED_OTHER when rr_back_at is published: reenter_runnable_in_gap() set_other(rr_t_tid) rr_back_at =3D now_ns() spins for > 2ms (e.g. EEVDF slice or HZ=3D250/HZ=3D100 tick) rr_t_ran =3D t <-- recorded while SCHED_OTHER set_constrained(rr_t_tid, ...) On systems with 4+ CPUs (where the EEVDF base slice exceeds 2ms) or HZ=3D250/HZ=3D100 kernels, T can run past b + 2ms before set_constrained() takes effect. Checking sched_getscheduler(0) =3D=3D SCHED_DEADLINE before recording rr_t_ran would avoid the race. [ ... ] > @@ -5937,6 +7832,144 @@ static int params_waking(void) [ ... ] > + while (!err && (t =3D now_ns()) < start + SW_SETTLE + SW_WINDOW) { > + if (!t0 && t >=3D start + SW_SETTLE) { > + t0 =3D t; > + cpu0[0] =3D sw_state[2]; > + cpu0[1] =3D sw_state[3]; > + } [ ... ] > + t1 =3D now_ns(); > + used[0] =3D sw_state[2] - cpu0[0]; > + used[1] =3D sw_state[3] - cpu0[1]; > + if (err) { > + ksft_print_msg("a change refused: %s\n", strerror(-err)); > + goto out; > + } > + if (100000 * (used[0] + used[1]) >=3D SW_MAX_SHARE * (long long)(t1 - t= 0)) { [Severity: Low] What if the main process stalls past start + SW_SETTLE + SW_WINDOW before any loop iteration sets t0? The loop exits with t0 still 0, so t1 - t0 becomes total monotonic uptime since boot. That inflates the denominator and lets the test silently pass without measuring the window (and can overflow signed long long if uptime exceeds ~3.4 years). Checking !t0 || t1 <=3D t0 and skipping or failing would catch this. [ ... ] > @@ -11250,6 +13319,12 @@ static void run_p_cases(void) > } > for (i =3D 0; i < N_P_CASES; i++) { > const struct p_case *c =3D &p_cases[i]; > + long long bw0 =3D total_bw_of(top_cpu(1)); > + long this0[3]; > + int k; > + > + for (k =3D 0; k < 3; k++) > + this0[k] =3D this_bw_of(top_cpu(k + 1)); > =20 > if (ok && make_p()) { > remove_p(); [ ... ] > @@ -11269,6 +13344,34 @@ static void run_p_cases(void) > ret =3D c->fn(); > remove_p(); > server_restore(); > + /* > + * A task of the case can keep its bandwidth counted after it > + * exits: until its 0-lag time, or until its debt is repaid. Wait > + * for that, so that the next case starts from the same total_bw. > + * A lower total_bw also ends the wait. Bandwidth lost by a case > + * would never come back, and the wait would then cost the whole > + * 10s. > + */ > + if (bw0 >=3D 0 && > + wait_for_step(10000, 10 * NSEC_PER_MSEC, > + total_bw_of(top_cpu(1)) <=3D bw0)) > + ksft_print_msg("%s: total_bw %lld after the case, %lld before\n", > + c->name, total_bw_of(top_cpu(1)), bw0); > + /* > + * this_bw can stay higher than total_bw shows. A task moved to > + * another cpuset while it sleeps leaves its bandwidth in the > + * this_bw of its old CPU until it wakes up or dies. Wait for > + * the three CPUs that random_mix() checks. > + */ > + for (k =3D 0; k < 3; k++) { > + int cpu =3D top_cpu(k + 1); > + > + if (this0[k] >=3D 0 && > + wait_for_step(10000, 10 * NSEC_PER_MSEC, > + this_bw_of(cpu) <=3D this0[k])) > + ksft_print_msg("%s: this_bw of CPU %d %ld after the case, %ld before= \n", > + c->name, cpu, this_bw_of(cpu), this0[k]); > + } > report(c->name, ret); > } [Severity: Medium] Does skipping these post-case waits when debugfs is unavailable still leave random_mix() failing after params_swap_overload()? total_bw_of() and this_bw_of() both return -1 without /sys/kernel/debug/sched/debug, so both wait loops are bypassed completely. params_swap_overload() runs right before random_mix() and exits while its reaped children still carry multi-second 0-lag debt on P's CPU; when random_mix() falls back to admission-only checks without debugfs, probe(cg_p) measures a depressed base_p before the debt drains, and admits_in() fails once the debt expires mid-test. [Severity: Low] Can these pre- and post-case sched/debug reads be combined into a single pass and guarded by ok? Right now run_p_cases() does four separate full scans of /sys/kernel/debug/sched/debug per case even when !ok causes all cases to skip, and each scan walks every thread on every CPU up to top_cpu(1..3). After each case, the four sequential 10s wait loops can also stall up to 40s (4,000 full scans) on a leaking case, risking the 600s kselftest timeout; polling all four values in one pass inside a single wait loop would avoid both. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/cover.1796296313.gi= t.mathieu.desnoyers@efficios.com?part=3D33