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=1796128013; b=bHt4Y4pA9UDW7fduL9fNUE7Zw9Be8mCBXeMqnXcVqAs648MP///5pnQchdoqMYMy6xs+ rNkNDQ6btFrfQ2791upRvfo9CGIXICkivASaVy3WIUc+C6mobpTPa2B9+j8HbWgxPR2um GrPeNLXujVq0riEPw0aXdgunfesGfomS8pJNSB4DfW+WAVfU7mirDNifHVHb1wOcq5Tw4 Q/corVQ1smeMhUmIs8OW5cYWKdaf0kECZBgDndUN9TMFb0F97HvsGsSlahsdKfphESeQ5 BaQCSgG+4zEfG6upinrG1ztT0l2PsHw3vgzg4ats56WwQQYjFGp9RViB/0VwHTU8ixg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796128013; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=HlBpdDapjv/JKzkC5zLWEVYl58M336BdQptcgVU83kQ=; b=3BrTf9MeA+m4O/7HkOtNa9ac5QWlM7+rZboG0fiLqdyW+/I7BLMmqo7T5d0MtbS/fT5m yKpNRTRurfQy18cryRf8t0J8Pk4FKOg7/GO3yyuZY4Lq2Qg8XVfnKjSKBt5JsCzWiZAdh ofr2WYXWmgxJuhiusWO9bn3jHPeKqNThN+6JWw/Omp1WLyDyUobrlIlL1ym1jES/IABUS m0DJ5DEt0w3ldp592RnhTrO4PgVwbEb1k2d0TC1X4+qDn3ELv3BmwfF3clXXcwKPWveIF qdIcwfZ3rKY6c/jsdXe8W4In4B+k3u6A/u3mPRSMMzTXw0gSS3RRlGDB+E95OJeYW8g== 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=JpiyKCwT; 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 A48CD606A31A for ; Tue, 1 Dec 2026 12:26:53 +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=JpiyKCwT Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00E1C1F0089A; Tue, 1 Dec 2026 12:26:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796128013; bh=HlBpdDapjv/JKzkC5zLWEVYl58M336BdQptcgVU83kQ=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=JpiyKCwT28juMVfxuDW/CI7RgMX1ITf7iqfYbmtwzGabGwtBQ7bc5GRRmef0UW1Nj OvET767Y8l3scl9BNupSf+8LhZKfPULy31m9yCja18cbPQ+yyX8W3OwE50gS+KHw80 JvkZrYiDSe383hdTaFGcaBe55D+C3aiQ3hADrFUAX0+D7C5x4uFrlYQ0sRfIvfOKGO TnDhJVlFIrHcnHQUaHB/K3Q7lg/GSrrYPSwuIslb3H7x3QBbCNJDoUo3bjRaBk/ZnF 9r0FWjzqnobD0vA7uSpUK5C49Jg7HjFHFFBDb6oCLCYqUcsvx0SMEYHSI1ec2hSlmQ eW7U1XlqQKN7w== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 2/2] selftests/sched_ext: Add core_forceidle test for voluntary idle picks Reply-To: sashiko-reviews@lists.linux.dev To: "Kuba Piecuch" Cc: sched-ext@lists.linux.dev In-Reply-To: <20261201120123.3678974-3-jpiecuch@google.com> References: <20261201120123.3678974-1-jpiecuch@google.com> <20261201120123.3678974-3-jpiecuch@google.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 12:26:52 +0000 X-Mailing-List: sched-ext@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] selftests/sched_ext: Phase 2 in run() bypasses core-wide pick_next_task() -- commit ad2b5e66c62d106475f2b8ad4083ca89741fc68e Author: Kuba Piecuch selftests/sched_ext: Add core_forceidle test for voluntary idle picks This commit adds a sched_ext selftest that verifies core-scheduling forced-idle accounting across three phases when a task with a core cookie is parked on a user DSQ and its CPU voluntarily picks idle. > diff --git a/tools/testing/selftests/sched_ext/core_forceidle.bpf.c b/too= ls/testing/selftests/sched_ext/core_forceidle.bpf.c > new file mode 100644 > index 0000000000000..12c8be46cc126 > --- /dev/null > +++ b/tools/testing/selftests/sched_ext/core_forceidle.bpf.c > @@ -0,0 +1,176 @@ [ ... ] > +void BPF_STRUCT_OPS(core_forceidle_enqueue, struct task_struct *p, u64 e= nq_flags) > +{ > + u32 ph =3D phase; > + > + if (p->pid =3D=3D parked_pid) { > + if ((ph =3D=3D 1 || ph =3D=3D 2) && (enq_flags & SCX_ENQ_LAST)) { > + scx_bpf_dsq_insert(p, PARK_DSQ, 1000000ULL, enq_flags); > + parked_in_dsq =3D 1; > + return; > + } > + scx_bpf_dsq_insert(p, SCX_DSQ_LOCAL, 1000000ULL, enq_flags); > + return; > + } > + > + if (p->pid =3D=3D busy_pid) { > + scx_bpf_dsq_insert(p, SCX_DSQ_LOCAL, SCX_SLICE_DFL, enq_flags); > + return; > + } > + > + scx_bpf_dsq_insert(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, enq_flags); > +} > + > +void BPF_STRUCT_OPS(core_forceidle_dispatch, s32 cpu, struct task_struct= *prev) > +{ > + if (cpu =3D=3D sib0 && phase !=3D 1 && phase !=3D 2) > + scx_bpf_dsq_move_to_local(PARK_DSQ, 0); > +} [ ... ] > diff --git a/tools/testing/selftests/sched_ext/core_forceidle.c b/tools/t= esting/selftests/sched_ext/core_forceidle.c > new file mode 100644 > index 0000000000000..962863b3c0c19 > --- /dev/null > +++ b/tools/testing/selftests/sched_ext/core_forceidle.c > @@ -0,0 +1,490 @@ [ ... ] > +static enum scx_test_status run(void *ctx_ptr) > +{ > + struct core_forceidle_ctx *ctx =3D ctx_ptr; > + struct core_forceidle *skel =3D ctx->skel; > + struct worker_state parked_st =3D { .wake_pipe =3D { -1, -1 }, .ready_p= ipe =3D { -1, -1 } }; > + struct worker_state busy_st =3D { .wake_pipe =3D { -1, -1 }, .ready_pip= e =3D { -1, -1 } }; > + struct bpf_link *link =3D NULL; > + enum scx_test_status status =3D SCX_TEST_FAIL; > + char c =3D 1; > + > + if (start_worker(&parked_st, ctx->sib0, true, false)) { > + SCX_ERR("Failed to start parked worker"); > + goto out; > + } > + /* > + * Leave busy_st untagged (cookie 0) so unrelated untagged kernel > + * threads on sib0 match it in Phase 2 instead of causing genuine > + * forced idle, while Phase 3 still sees a cookie mismatch against > + * parked_st. > + */ > + if (start_worker(&busy_st, ctx->sib1, false, true)) { > + SCX_ERR("Failed to start busy worker"); > + goto out; > + } [ ... ] > + /* > + * Phase 1: sib0's cookied task is parked in PARK_DSQ on SCX_ENQ_LAST > + * while sib1 is idle (occ =3D=3D 0). Neither sibling is forced idle. > + */ > + __atomic_store_n(&skel->bss->phase, 1, __ATOMIC_RELEASE); > + if (!wait_u32_nonzero(&skel->bss->phase1_obs, WAIT_TIMEOUT_MS)) { > + SCX_ERR("Phase 1: sib0 never entered voluntary idle"); > + goto out; > + } > + /* Let ticks fire so __sched_core_account_forceidle() runs if buggy. */ > + usleep(50000); > + > + /* > + * Phase 2: sib0 stays voluntarily idle with parked_pid in PARK_DSQ > + * while busy_pid (different cookie) runs on sib1 (occ =3D=3D 1). > + */ > + __atomic_store_n(&skel->bss->phase, 2, __ATOMIC_RELEASE); > + __atomic_store_n(&busy_st.pause_flag, 0, __ATOMIC_RELEASE); > + if (write(busy_st.wake_pipe[1], &c, 1) !=3D 1) { > + SCX_ERR("Phase 2: failed to wake busy worker"); > + goto out; > + } [Severity: Medium] Does Phase 2 ever enter the core-wide selection loop in pick_next_task()? When Phase 1 parks parked_st in PARK_DSQ and both siblings pick idle, pick_next_task() resets rq->core->core_cookie to 0 while rq->core->core_forceidle_count remains 0. Because core_forceidle_dispatch() keeps PARK_DSQ parked when phase is 2, parked_st never runs on sib0 between Phase 1 and Phase 2, and the ph =3D=3D 2 branch in core_forceidle_enqueue() is never reached. When Phase 2 wakes untagged busy_st (core_cookie =3D=3D 0) on sib1, pick_next_task() sees !need_sync && !next->core_cookie and takes the single-rq fast path to out_set_next, bypassing the core-wide sibling loop where occ =3D=3D 1 and core_forceidle_count are evaluated. Also, busy_runn= ing in core_forceidle.bpf.c is updated in running/stopping but never read. Should parked_st be unparked once busy_st is running on sib1 so that sib0 enters Phase 2 with a non-zero core_cookie before re-parking on SCX_ENQ_LAST? --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201120123.3678= 974-1-jpiecuch@google.com?part=3D2