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=1796321226; b=bY4MlWvpjq5g0lmzdBr2DyolZj+LMX0DO2bSa5GjdCimi6RR85cnRVlvOr4D01d6Tdvi Vvc5g/CNGqM/8qjHlcVfCR5PEdvx3qcP7ysExIC4VVLTKR2wDk3eyftNkRQYwxbtkBPIX eYnoSYOJdZlgbEcIAXTjIxCLciiF+hVNOVhKEFB6Anw8FrgYy+76DBcTFJo5NNE6uqx5X DbeCPQBy+gHlTtQ+HxTisR04vHHHLasHC4VdzhSZyYaR7No1nxN+wYEV5Cyn9npMNFcx2 5poFwQQ8ehBSFNYeKLoD2ykfONJKAA130AN6tnEgAaq5wz06rU7zij6nq3CkZOhJrfg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796321226; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=4iEdJi+ShPVbN4H4Hx3b/Y7SEda0eF31Y6awWUgv0AU=; b=CT9Hi06Wf2FyEHUlDBRwZ1G/BY8LsikU/I8rotaSkFj7iFhrit+85cNa2zE8NMCDQPRb 5q4OjOtlihboCjxkOERBd5fryXMjyFFz9DceeijEXl5SIawTQBTzyCQvFo3N7hfKMiZAY L5L8dk+m3d6JR6CDZ+RhxVpItntyMsa8UewaaEVu43frcG4TVcxvyTnQAfUsXLPwD+LQh y5/G45kNREq/qHZJKhyef8Th9p3lNr3i+c0L2xV5VOjQO7Idih+CydFHOJLt6o/6nxXc7 FCrSD81hcbFCTb0eJ0RVdU6bqp8ZGP6Uq4Vn+vNcayKfojgltpyGkORPbNqtHjRlR8A== 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=RSlfuSMZ; 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 4AF99606A32C; Thu, 3 Dec 2026 18:07:05 +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=RSlfuSMZ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C5111F00893; Thu, 3 Dec 2026 18:07:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796321225; bh=4iEdJi+ShPVbN4H4Hx3b/Y7SEda0eF31Y6awWUgv0AU=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=RSlfuSMZMehAU6uT9BkETGmx0QW6+ad/dllZdxCY589u6yK0y7YPNrYrvAcTOfhs4 pCLsBu1BfXWdM4Whq7rQYp9PaOOvS3pv0CrSzRbDWNTVFXbQckR2v7k5JDwZ0egjOc Qzx8xgUppBNKqj4NKAn3HZAze90PbScPX2N+TdVdHcnm/W+9CkH7lYDMqvp3gtLxuF TcUeZ+Gzq9p2m96i/gK8XBlsJI2PbbNl0icO3OFM7S5wL3xayivMiB9Sq/7lyKY78S Gymn2Yn2KB0fGZ4Zy8xwNK3C7wdkFLlRag1t2sekS45pVR5MIvP8zkFHTwgxvjHMWn 80vJBKwb6GtHQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v14 38/39] selftests/sched: Test PI against hotplug and rebuilds 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: References: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 18:07:05 +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 7 potential issues to consider: - [Medium] selftests/sched: untracked continue in pi_deboost_during_rebuild() loop - [Low] selftests/sched: race_w() publishes rs->w_tid before set_deadline() - [Low] selftests/sched: unbounded dmax can pass 0-lag time in deadline_bw_test - [Low] selftests/sched: pi_deboost_during_rebuild() fails instead of skipping - [Low] selftests/sched: dmax calibrated before deadline tasks in deadline_bw_test - [Low] selftests/sched: missing w_done check in pi_deboost_during_rebuild() - [Low] selftests/sched: heavy sched/debug polling in pi_deboost_during_rebuild() -- commit 422a087312079e778dce123e41c2cb32e6f07e4b Author: Mathieu Desnoyers selftests/sched: Test PI against hotplug and rebuilds in deadline_bw_test This commit adds two priority-inheritance test cases to deadline_bw_test: pi_departed_offline_boost and pi_deboost_during_rebuild. > diff --git a/tools/testing/selftests/sched/deadline/deadline_bw_test.c b/= tools/testing/selftests/sched/deadline/deadline_bw_test.c > index 58ec444cf1bbf..90f2f19bfb72b 100644 > --- a/tools/testing/selftests/sched/deadline/deadline_bw_test.c > +++ b/tools/testing/selftests/sched/deadline/deadline_bw_test.c [ ... ] > @@ -12504,6 +12663,322 @@ static int affinity_vs_setattr(void) [ ... ] > +static void *race_w(void *arg) > +{ > + int i =3D 0; > + > + rs->w_tid =3D gettid_(); > + if (set_deadline(0, RACE_W_RUNTIME, RACE_W_PERIOD)) { > + set_flag(&rs->w_err, -1); > + return arg; > + } [Severity: Low] Can publishing rs->w_tid before set_deadline() race with the parent's startup check in pi_deboost_during_rebuild()? parent W (race_w) rs->w_tid =3D gettid_() wait_for(..., rs->w_tid && ...) sees rs->w_tid !=3D 0, w_err =3D=3D 0 set_deadline(...) fails set_flag(&rs->w_err, -1) return arg sleep_ns(100ms) base =3D total_bw_of(...) - bw_w <-- W was never admitted Because rs->w_tid is visible before set_deadline() finishes, the parent can pass its startup wait with rs->w_err =3D=3D 0, compute a corrupted base, and fail later in round 1 instead of catching the startup failure. Even when set_deadline() succeeds, a delay past the 100ms sleep leaves base off by -bw_w. Moving rs->w_tid =3D gettid_() after the set_deadline() check closes both races. [ ... ] > + if (enter(cg, getpid()) || pthread_mutexattr_init(&a) || > + pthread_mutexattr_setprotocol(&a, PTHREAD_PRIO_INHERIT) || > + pthread_mutex_init(&race_m, &a) || pthread_mutex_lock(&race_m) || > + pthread_create(&w, NULL, race_w, NULL)) { > + set_flag(&rs->w_err, -1); > + _exit(1); > + } [Severity: Low] Should missing PTHREAD_PRIO_INHERIT support skip the test instead of failing it? Other PI cases in deadline_bw_test.c (such as pi_init() callers and shm_lock_init()) return KSFT_SKIP when PI mutex setup fails, whereas here rs->w_err =3D -1 jumps to out: with ret left at KSFT_FAIL. Distinguishing PI mutex initialization failure from other setup errors would keep this case consistent with kselftest policy on kernels without CONFIG_FUTEX_PI or C libraries without PI mutex support. [ ... ] > + /* The longest of 8 writes to Q sets the range of the timeouts. */ > + for (i =3D 0; i < 8; i++) { > + uint64_t t =3D now_ns(); > + > + if (toggle_q(&q_root)) { > + ksft_print_msg("Q cannot change between root and member\n"); > + ret =3D KSFT_SKIP; > + goto out; > + } > + d =3D now_ns() - t; > + if (d > dmax) > + dmax =3D d; > + } [Severity: Low] Does calibrating dmax before starting race_t(cg_r) miss the 1000-thread tasklist walk? When no SCHED_DEADLINE task exists yet, dl_nr_bw_tasks is 0 and dl_rebuild_rd_accounting() returns early before walking for_each_process_thread(). During the actual rounds, W and T are deadline tasks, so the walk runs at the end of partition_sched_domains_locked() and can fall past the 1.2 * dmax lead window, reducing race coverage. Running the 8 calibration writes after race_t(cg_r) starts W would measure the full rebuild duration. [ ... ] > + if (wait_for_step(100, 100 * NSEC_PER_USEC, proc_state_of(rs->t_tid) = =3D=3D 'S')) > + continue; [Severity: Medium] Can this continue allow pi_deboost_during_rebuild() to report KSFT_PASS after executing zero rounds? If runtime overhead exceeds the 2ms margin left after spin_ns(), T gets throttled in state 'R' for ~180ms, exceeding the 100ms wait on every iteration until the 25-second loop ends and unconditionally sets ret =3D KSFT_PASS. Tracking completed rounds and failing or skipping when none complete would prevent a silent pass. Also, jumping to continue skips set_other(rs->t_tid), so T stays in SCHED_DEADLINE with identical parameters and the next round's set_deadline() hits the no-op path in __sched_setscheduler() instead of starting a fresh period. > + /* Leave W 20ms to block, then time out within the write. */ > + lead =3D (int64_t)((double)rand() / RAND_MAX * 1.2 * dmax); > + abs =3D realtime_ns() + 20 * NSEC_PER_MSEC + dmax; > + rs->w_abs =3D abs; > + set_flag(&rs->w_go, i); > + if (wait_for_step(100, 100 * NSEC_PER_USEC, rs->w_blocked =3D=3D i) || > + wait_for_step(100, 100 * NSEC_PER_USEC, proc_state_of(rs->w_tid) = =3D=3D 'S')) { > + ksft_print_msg("round %d: W did not block\n", i); > + goto out; > + } > + if (set_other(rs->t_tid)) { > + ksft_print_msg("round %d: T cannot leave SCHED_DEADLINE\n", i); > + goto out; > + } > + if (prio_of(rs->t_tid) !=3D DL_TASK_PRIO) { > + ksft_print_msg("round %d: W does not boost T\n", i); > + goto out; > + } [Severity: Low] Can an early timeout of W trigger a spurious "W does not boost T" failure? parent W (race_w) abs =3D realtime_ns() + 20ms + dmax set_flag(&rs->w_go, i) rs->w_blocked =3D i pthread_mutex_timedlock(&race_m, &ts) (delayed > 20ms + dmax) times out, deboosts T set_flag(&rs->w_done, i) wait_change(&rs->w_go, i) (state 'S') proc_state_of(rs->w_tid) =3D=3D 'S' set_other(rs->t_tid) prio_of(rs->t_tid) !=3D DL_TASK_PRIO <-- spurious KSFT_FAIL Because wait_change() also sleeps in state 'S', the parent cannot tell whether W is still blocked on race_m or has already timed out and deboosted T. Checking rs->w_done =3D=3D i before treating the prio check a= s a kernel PI failure would distinguish an early timeout from a boost bug. [ ... ] > + tb =3D total_bw_of(cpu[0]); > + if (tb !=3D base + bw_w + bw_t) { > + ksft_print_msg("round %d: total_bw of R %lld, %lld expected%s\n", > + i, tb, base + bw_w + bw_t, > + tb =3D=3D base + bw_w ? ": T is missing" : ""); [Severity: Low] Can an uncapped dmax push this total_bw_of(cpu[0]) read past T's 0-lag time and cause a false failure? T's 0-lag time is at most ~162ms after it sleeps, while when lead is near 0, toggle_q() finishes roughly 20ms + 2 * dmax after T slept. On slower, virtualized, or debug kernels where dmax is ~70ms or more (or a single rebuild stalls), T's inactive timer can legitimately release bw_t before this read runs. Bounding dmax or checking elapsed time since T slept, as pi_departed_offline_boost() does, would avoid false KSFT_FAIL results. [ ... ] > + /* Past the 0-lag time of T: R counts W only. */ > + if (wait_for_step(1000, 5 * NSEC_PER_MSEC, total_bw_of(cpu[0]) =3D=3D = base + bw_w)) { [Severity: Low] Will polling total_bw_of(cpu[0]) every 5ms scale poorly on large SMP systems? Partition R is placed on top_cpu(4) and top_cpu(3), so each call to total_bw_of(cpu[0]) streams /sys/kernel/debug/sched/debug across nearly every online CPU, and print_rq() walks all threads (including the 1000 filler threads) under rcu_read_lock() for each CPU printed. Polling every 5ms across T's ~100-130ms 0-lag wait cuts into round throughput and makes the earlier total_bw_of(cpu[0]) read more likely to overrun the 0-lag window; placing R on low-numbered CPUs or sleeping toward the 0-lag time before polling would reduce that overhead. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/cover.1796296313.gi= t.mathieu.desnoyers@efficios.com?part=3D38