From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: kunit: Add backtrace suppression self-tests Date: Sat, 16 May 2026 09:36:17 +1000 Message-ID: In-Reply-To: <20260515-kunit_add_support-v12-2-a216dc228be8@redhat.com> References: <20260515-kunit_add_support-v12-0-a216dc228be8@redhat.com> <20260515-kunit_add_support-v12-2-a216dc228be8@redhat.com> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Patch Review Good test coverage. Tests both API forms, incremental counting, active-stat= e transitions, and cross-kthread isolation. **1. `backtrace_suppression_test_multi_scope` accesses handles after cleanu= p:** ```c + sw1 =3D kunit_start_suppress_warning(test); + trigger_backtrace_warn_on(); + WARN(1, "suppressed by sw1"); + kunit_end_suppress_warning(test, sw1); + + sw2 =3D kunit_start_suppress_warning(test); + WARN(1, "suppressed by sw2"); + kunit_end_suppress_warning(test, sw2); + + KUNIT_EXPECT_EQ(test, kunit_suppressed_warning_count(sw1), 2); + KUNIT_EXPECT_EQ(test, kunit_suppressed_warning_count(sw2), 1); ``` After `kunit_end_suppress_warning(test, sw1)`, the cleanup path runs `kunit= _suppress_warning_remove(sw1)` which calls `call_rcu(&w->rcu, kunit_suppres= s_warning_free)`. The `sw1` pointer remains valid because the RCU grace per= iod cannot complete while the current task is still executing without sched= uling =E2=80=94 so this is safe *in practice*. However, it's a fragile patt= ern: if someone inserts a `schedule()`, `msleep()`, or even `cond_resched()= ` between the end calls and the count checks, it becomes a use-after-free. = A brief comment here explaining the RCU grace period guarantee would help f= uture maintainers. Alternatively, reading the count *before* calling `kunit= _end_suppress_warning` would be more robust. **2. `cross_kthread_fn` uses busy-loop pattern:** ```c + while (!kthread_should_stop()) + schedule(); ``` This was noted in v10's changelog as fixing a use-after-free on kthread exi= t. The pattern is correct =E2=80=94 the thread waits until `kthread_stop()`= is called, preventing the stack-allocated `data` from going out of scope b= efore the thread accesses it. **3. Good use of `noinline` on helper trigger functions:** ```c +static noinline void trigger_backtrace_warn(void) +static noinline void trigger_backtrace_warn_on(void) ``` Prevents the compiler from inlining these into the suppression scope, ensur= ing the warning actually goes through the full WARN path. Good. --- Generated by Claude Code Patch Reviewer