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=1796318723; b=ltxRxZZO58tiAfvEVeNoxq4jCUKJsmVJ40qVJ04fC0kvZIqgw+ttWFZYM/6R5yOV1iDF 85gGG9o+DinBmn7W1hLzexI7EV5RcdogC/E0aME6vaIoqCNw9e8B/qzhKwXbdHWVOfmQ1 pDfZR821iLFiMkW8ztx07N664oEfPxU+gjYbVmGa3kjjJpGxPotEVkCd7oYy+j1ietPJO zHJQK3VGUXC1vRnNaq/M9u73P8cBdJXJFgnsy0f76hz2PUak3/huK6RByDYlLbkAoxZ0A XxZs1b0qfXa86kGYFuEJgbv6X87OpEKsjTAR9CMFGitk7NeSHmgaGQJhrcn0bQtIHrg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796318723; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=GOP3aQ/dYVsneUwTHtBTX+vktvGQHS9uUCPHom/6B+k=; b=K9Vwxz30NuhghOVXadZm57ec/7bTa4CYWeJi7uCUG2t8VkV7Vz8blVRS8XhKeluKwUWp 0/3izZVByF84kALJIHlut/oCk+xY/eyp9AqI1YElOR7x2FPdsaKDB0EQtajvLAamLpeEI 3uISPrkMv4YC9g9xZwUAIALFLxlxdyiWXcFi+PO8Als3hUNdVTV+5r43nKpqnb8RMaHTQ ZEkOapBPkU1NYEKzAeoAZU/Xm02vuIbS3OE5qzmxqUhZiKZUuc7Evye1qbBOhyb1pYb5L kfIWfCya4fkEz4Trz6t1qmaiLIcQD9etEK7/tHaNy+kv1P/SkvUJ/x+GrOhotpsv+ug== 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=N4+hyCgG; 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 6EDFA606A322; Thu, 3 Dec 2026 17:25:23 +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=N4+hyCgG Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2AC21F000C1; Thu, 3 Dec 2026 17:25:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796318723; bh=GOP3aQ/dYVsneUwTHtBTX+vktvGQHS9uUCPHom/6B+k=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=N4+hyCgGuScctv6S/Q6UJtF5pY+g4EOoYp9kJuixc4+MgCRrPCC2hZfdY6W/85xKR yDBbTVjQlGWMAHHmz6LcohfN7zx8TSQAMQncoOHVfZTPTbpZLoWds+mO1Vt2zyJM17 K7cXZVtTeeF+3UtERvKDoOiNrM3PuGOfhiB+zBjIuMnu3UnI8j72HageyIYzhE6Ys6 Yk1VVABuBSNLyYKFFKiW0tuP5P+LPAkWXAAzO1s4Tn6DTBU6wChAIIfEDPrt+4tzr9 3Gjg+tT1JXeE9vZp3DNt3393aSehVZKWaN33tVdanc/pibTQd2h4f8+GUUTokv0YVl JAhctRmr9pdDQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v14 26/39] selftests/sched: Test the root domain of a task 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: <008cb3bfa7b0e6e390a5b96a12c95dd6be8660d1.1796296313.git.mathieu.desnoyers@efficios.com> References: <008cb3bfa7b0e6e390a5b96a12c95dd6be8660d1.1796296313.git.mathieu.desnoyers@efficios.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 17:25:22 +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 11 potential issues to consider: - [Low] selftests/sched: stack buffer overflow in rebuild_record_taken() - [Low] selftests/sched: unchecked buffer truncation in partition_invalidate_refused() - [Low] selftests/sched: unclosed ack[1] pipe end hangs two partition tests - [Low] selftests/sched: inverted tell flag in partition_swap_accepted() - [Low] selftests/sched: unpinned migration window causes flaky deadline_bw_test cases - [Low] selftests/sched: silent or misleading KSFT_SKIP returns in deadline_bw_test - [Low] selftests/sched: wrong isolcpus count comment and cs_setup() duplication - [Low] selftests/sched: missing ext_switched_all() check before hotplug with server - [Low] selftests/sched: woken_on() accepts negative task_cpu_of() error as valid CPU - [Low] selftests/sched: no_admission_affinity_moves() restores sysctl before 0-lag - [Low] selftests/sched: hotplug_no_admission_pinned() restores sysctl before 0-lag -- commit 771f314a11047ea4b849341ab0c81a8587315b6a Author: Mathieu Desnoyers selftests/sched: Test the root domain of a task in deadline_bw_test This commit adds 40 test cases to deadline_bw_test covering CPU hotplug, cpuset partition changes, and root domain accounting for SCHED_DEADLINE tasks with and without isolcpus=3Ddomain. > diff --git a/tools/testing/selftests/sched/deadline/deadline_bw_test.c b/= tools/testing/selftests/sched/deadline/deadline_bw_test.c > index f50d45dd57994..8c2a2ccb3c600 100644 > --- a/tools/testing/selftests/sched/deadline/deadline_bw_test.c > +++ b/tools/testing/selftests/sched/deadline/deadline_bw_test.c [ ... ] > @@ -45,7 +46,7 @@ > * > * The test needs root, deadline admission control and 3 housekeeping > * CPUs. Some cases need 4. Most also need the cgroup v2 cpuset > - * controller. Some need debugfs or CPU hotplug. Five need > + * controller. Some need debugfs or CPU hotplug. Twenty-nine need > * isolcpus=3D"domain" at boot. > */ [Severity: Low] Should this say thirty-one rather than twenty-nine, given the five existing cases plus the 26 new cases that require isolcpus=3Ddomain? Two other small cleanups in the added code: fallback_case() declares a local cg_q that shadows the file-scope cg_q and duplicates the cgroup setup and teardown from cs_setup()/cs_cleanup(); and hotplug_partition_invalid_refuse= d() leaves cs_n[0] non-zero if snprintf() truncates before jumping to out:, unlike hotplug_sibling_partition_refused() which clears cs_d[0] =3D 0. [ ... ] > + snprintf(path, sizeof(path), "%s/cgroup.subtree_control", root); > + if (read_file(path, buf, sizeof(buf))) > + return KSFT_SKIP; > + if (!strstr(buf, "cpuset")) { > + if (write_file(root, "cgroup.subtree_control", "+cpuset")) > + return KSFT_SKIP; > + added =3D 1; > + } [Severity: Low] Should these early KSFT_SKIP returns print a skip reason? cs_setup() also returns -1 without logging, so the roughly 20 new cases calling it (as well as partition_grows_child_valid() and hotplug_top_last_refused()) skip silently when prerequisites are missing. In addition, partition_shrink_moves_refused(), partition_shrink_isolated_moves_refused(), partition_invalidate_refused(), and partition_child_invalidate_refused() combine their CPU-count check with cs_setup(), printing a misleading CPU-count message when cs_setup() fails. Most new cases also initialize ret =3D KSFT_SKIP and only switch to KSFT_FA= IL after pipe(fd), so a pipe() error jumps to out: and silently skips instead of failing. [ ... ] > +out: > + reap(pid); > + if (write_file("/proc/sys/kernel", "sched_rt_runtime_us", saved)) { > + ksft_print_msg("admission control cannot be turned on again\n"); > + return KSFT_FAIL; > + } > + sleep_ns(3 * PERIOD); [Severity: Low] Can restoring /proc/sys/kernel/sched_rt_runtime_us before sleep_ns(3 * PERI= OD) fail with -EBUSY? While the killed spinning task's 0-lag timer still holds its bandwidth in dl_b->total_bw, sched_dl_global_validate() rejects the write if new_bw * cpus < dl_b->total_bw. That returns KSFT_FAIL immediately and leaves global admission control disabled (-1) for the remaining test cases and after the test exits. Waiting 3 * PERIOD before restoring sched_rt_runtime_us avoids this. [Severity: Low] In commit "selftests/sched: Test the root domain rebuild in deadline_bw_tes= t" earlier in this series, does hotplug_no_admission_pinned() have the same ordering problem? Its out: path restores sched_rt_runtime_us immediately after reaping the spinning 50% deadline task and before sleep_ns(3 * PERIOD= ), which can fail with -EBUSY and leave admission control at -1 for all subsequent cases. [ ... ] > + err =3D enter(cs_c, pid); > + cpu =3D task_cpu_of(pid); > + if (bw <=3D 0 || def !=3D def0 || err || cpu !=3D fb_h) { > + ksft_print_msg("a deadline task adds %lld, %lld to total_bw, in C: %s,= on CPU %d\n", > + def - def0, bw, strerror(-err), cpu); > + goto out; > + } [Severity: Low] Can hotplug_nested_refused() fail spuriously if the child migrates off fb_h before sleeping? task_from() widens the child's affinity to all CPUs before calling set_deadline() and blocking in read(), so preemption or load balancing can move it to another CPU before it sleeps, and enter() does not migrate a sleeping task's CPU. Unlike fallback_case(), which treats sleeping off fb_h as KSFT_SKIP, hotplug_nested_refused(), hotplug_dead_accepted(), partition_takes_fallback_refused(), partition_swap_refused(), partition_refused_no_warn(), and hotplug_asleep_setattr() all return KSFT_FAIL in that case. [ ... ] > + c =3D 'x'; > + if (enter(cs_b, pid) || write(go[1], &c, 1) !=3D 1 || read(ack[0], &c, = 1) !=3D 1) { > + ksft_print_msg("the task never ran in B\n"); > + goto out; > + } [Severity: Low] Can read(ack[0], &c, 1) block forever if the child exits before writing to ack[1]? The parent keeps ack[1] open until out:, so if the child terminates early (for example if read(go[0], &c, 1) fails and it calls _exit(1)), the kernel never delivers EOF on ack[0] and the test hangs until the harness timeout. hotplug_top_last_refused() has the same unclosed ack[1] before read(ack[0], &c, 1). Closing ack[1] and go[0] in the parent right after fork_child() avoids the hang. [ ... ] > + if (ic < 0 || x < 0 || !cpu_hotpluggable(x) || !server_found || cs_setu= p()) { > + ksft_print_msg("needs isolcpus=3D\"domain\", 2 housekeeping CPUs, CPU = hotplug, fair server files\n"); > + return KSFT_SKIP; > + } [Severity: Low] Should hotplug_isolated_partition_falls_back() also skip when ext_switched_all() is true, like hotplug_server() and hotplug_server_refused()? Because it reads server_get() and checks totals_check() across cpu_online(x, 0), a CPU hotplug that terminates a sched_ext switch_all=3D1 scheduler switches accounting from ext_server back to fair_server and causes a spurious failure. [ ... ] > + snprintf(buf, sizeof(buf), "%d", h2); > + if (write_file(cs_q, "cpuset.cpus", buf) || partition_has(cs_q, "invali= d", 1) || > + fallback_wake(fd[1], pid)) > + goto out; [Severity: Low] Is the tell flag in partition_has(cs_q, "invalid", 1) inverted? partition_has() only prints cpuset.cpus.partition when the substring is absent and tell is non-zero, so this logs a spurious message on every passing run when Q is "root", stays silent if Q becomes invalid, and omits checking that Q remains "root". Using !partition_has(cs_q, "root", 1) || partition_has(cs_q, "invalid", 0) matches the other valid-partition checks. [ ... ] > + /* Q has every housekeeping CPU but A, B and D. */ > + for (i =3D n =3D 0; i < ncpus - 3; i++) > + n +=3D snprintf(buf + n, sizeof(buf) - n, "%s%d", n ? "," : "", > + online[i]); [ ... ] > + for (i =3D 1, n =3D 0; i < ncpus - 3; i++) > + n +=3D snprintf(buf + n, sizeof(buf) - n, "%d,", online[i]); > + snprintf(buf + n, sizeof(buf) - n, "%d", d); [Severity: Low] Can these snprintf() loops overflow buf[4096] on the stack? Because snprintf() returns the untruncated length, on a large-CPU system where the formatted CPU list exceeds 4095 bytes, n grows past sizeof(buf) and sizeof(buf) - n underflows size_t on the next iteration or the trailing snprintf(), writing past buf on the stack. Guarding both loops with n < (int)sizeof(buf) and skipping when n >=3D (int)sizeof(buf) (as mask_grows_refused() does) prevents the overflow. [ ... ] > + cpu =3D task_cpu_of(pid); > + if (want_isol ? !is_isol(cpu) : want >=3D 0 ? cpu !=3D want : is_isol(c= pu)) { > + ksft_print_msg("woken on CPU %d\n", cpu); > + return -1; > + } > + return 0; [Severity: Low] Does woken_on() accept a -1 error from task_cpu_of() as a valid housekeeping CPU? When called with want_isol =3D=3D 0 and want < 0 (as in partition_shrink_isolated_moves_refused()), cpu =3D=3D -1 makes is_isol(-1) return 0, so woken_on() returns 0 instead of -1. Checking cpu < 0 first avoids this. [ ... ] > + for (i =3D 0; i < ncpus && n < (int)sizeof(buf); i++) > + n +=3D snprintf(buf + n, sizeof(buf) - n, "%s%d", i ? "," : "", online= [i]); > + for (i =3D 0; i < nisol && n < (int)sizeof(buf); i++) > + n +=3D snprintf(buf + n, sizeof(buf) - n, ",%d", isol[i]); > + err =3D write_file(cs_q, "cpuset.cpus", buf); [Severity: Low] Should partition_invalidate_refused() check n >=3D (int)sizeof(buf) before calling write_file()? On a host with roughly 540 or more online CPUs, the formatted CPU list truncates at 2048 bytes and write_file() receives a partial or malformed list, causing a spurious KSFT_FAIL instead of skipping. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/cover.1796296313.gi= t.mathieu.desnoyers@efficios.com?part=3D26