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=1796274841; b=GGRUw0mGHnacuO1pVpk52LfOIIA6w+9v6jwkfg2LWjNmMoTHfZxyCZ8AeLfFuK0NIMgA ucDXaEcF+tpplA4JQvoyRgBP04kF2EQ/ftIeVw839TLa2gZfM2IQzDEDzj6iiJJmzKfy8 q4gZPygOODUKayoaobHu2veY8TcKD5+uqWnpsF2qoCuPRcx/Fp43uS4V67gJuJYuZdcJd kcZ1ntjdWcwYdqPB3FglTwhIe6Hlzk8eA6XO7i98BWpwJmfdwoRGCnIVxRVDbsP9Bnm2w 7/TXPm9MZSD8QiXr+OvszluEb/V9WFwPQFO8tR2qz6fZGmFMoj7+Dg8E91jkWTrFPbA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796274841; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=AkIw5ZiUdY0ajL5f//5iVkoAa8t+v24V+2qFAgw18J0=; b=fmPoZUUTy3k9/kcAIAQ0pI3DQ9SU+HbBeuWBEsGDkieK96GUDmS+1N31QpTD5rRgcnKb WZiFfLS0nip2t/s6NScUDUYu/qDZpQbdD7T8tOh8WFuqz4zW04+PtxGHPUisc+W7eqiFk xsKd9QuVpUI9xDK2WpE+N8SFNyeVsnDYAkVKQa6rwxBEo/QQyap3r/W0lkoBYJBInNpBD 0mkARbjZupBDf1WIaZYSya91yi58VNTqP6JTP7BTzZ0yGdHJUlCa8/vTjczU3o6+p29Oh GHOhwrDm+Afej+qznjpPXEScpezXTeCQMh57X3igqM4aj1gisQAIogZP49DtQFDk6Tw== 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=dneNUxph; 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 C98D0606A322 for ; Thu, 3 Dec 2026 05:14:01 +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=dneNUxph Received: by smtp.kernel.org (Postfix) with ESMTPSA id E77221F00893; Thu, 3 Dec 2026 05:14:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796274841; bh=AkIw5ZiUdY0ajL5f//5iVkoAa8t+v24V+2qFAgw18J0=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=dneNUxphsHbyOD90HIYlk1FT0zVwHg0GtTpqmmLEYCjpstRDIq7y6Fd2hi5YMABGt x0/XVr5/zoqvGXGkfcQU20DSSpRxCmVkRtQzhfNgPnm3emC3zCsnPXTdQOnixqdWrN H5PsDssAPJ14Ojd9J3uegCS6pWHBSvBIgx14Dypq01AzkAJswbwFd/WHv55acLGBVt RGYwwwhoQ8wBr2ZXw1jhDCAppLllYxgO5cYMF1liA3BgDGtAjPUxAmRVSn/7pVmyU4 TDSg63xZ3lrX9Yf0wkZnBmO6CjXafKaIycuwUmPSDoJFRtatO374O1gnfEG4xVhhdy 84aHZCw9BJzoQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 4/8] selftests/sched_ext: Test scx_bpf_sched_id() and scx_bpf_task_sched_id() Reply-To: sashiko-reviews@lists.linux.dev To: "Changwoo Min" Cc: sched-ext@lists.linux.dev In-Reply-To: <20261203045618.982539-5-changwoo@igalia.com> References: <20261203045618.982539-1-changwoo@igalia.com> <20261203045618.982539-5-changwoo@igalia.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 05:14:00 +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 4 potential issues to consider: - [Low] selftests/sched_ext: leak BPF skeleton and FDs on error in load_and_check() - [Low] selftests/sched_ext: unassociated probe() bypasses ops->priv in scx_prog_sched() - [Low] selftests/sched_ext: SCX_EQ() evaluates load_and_check() twice on failure - [Low] selftests/sched_ext: sched_id passes getpid() to bpf_task_from_pid() -- commit 9708b30d3e6e6f4f027faf04578e789bbcd68ef1 Author: Changwoo Min selftests/sched_ext: Test scx_bpf_sched_id() and scx_bpf_task_sched_id() This commit adds the sched_id sched_ext selftest to verify scx_bpf_sched_id() and scx_bpf_task_sched_id() across scheduler load, unload, and reload. > diff --git a/tools/testing/selftests/sched_ext/sched_id.bpf.c b/tools/tes= ting/selftests/sched_ext/sched_id.bpf.c > new file mode 100644 > index 0000000000000..8828c3ecec3e4 > --- /dev/null > +++ b/tools/testing/selftests/sched_ext/sched_id.bpf.c > @@ -0,0 +1,47 @@ [ ... ] > +SEC("syscall") > +int probe(void *ctx) > +{ > + struct task_struct *p; > + > + p =3D bpf_task_from_pid(target_pid); > + if (!p) > + return -ESRCH; > + > + probe_sched_id =3D scx_bpf_sched_id(); > + probe_task_sched_id =3D scx_bpf_task_sched_id(p); > + bpf_task_release(p); > + return 0; > +} [Severity: Low] Can bpf_task_from_pid(target_pid) fail or inspect the wrong task when the test runs in a non-root PID namespace? load_and_check() stores getpid() in target_pid, which is relative to the caller's PID namespace, while bpf_task_from_pid() resolves PIDs in init_pid_ns. Since probe() runs in the calling task's context via bpf_prog_test_run_opts(), using bpf_get_current_task_btf() avoids the namespace mismatch. > diff --git a/tools/testing/selftests/sched_ext/sched_id.c b/tools/testing= /selftests/sched_ext/sched_id.c > new file mode 100644 > index 0000000000000..a926062e13c76 > --- /dev/null > +++ b/tools/testing/selftests/sched_ext/sched_id.c > @@ -0,0 +1,103 @@ [ ... ] > +static enum scx_test_status load_and_check(u64 *id) > +{ > + enum scx_test_status status =3D SCX_TEST_FAIL; > + struct sched_id *skel; > + struct bpf_link *link; > + > + skel =3D sched_id__open(); > + SCX_FAIL_IF(!skel, "Failed to open skel"); > + SCX_ENUM_INIT(skel); > + SCX_FAIL_IF(sched_id__load(skel), "Failed to load skel"); [Severity: Low] Does calling sched_id__load() without associating skel->progs.probe with skel->maps.sched_id_ops bypass the primary scx_prog_sched() path? Without bpf_program__assoc_struct_ops(), bpf_prog_get_assoc_struct_ops() returns NULL in scx_prog_sched(), so scx_bpf_sched_id() only passes via the legacy v6.19 scx_root fallback instead of testing ops->priv. Associating skel->progs.probe with skel->maps.sched_id_ops before loading would exercise the primary lookup directly. > + skel->bss->target_pid =3D getpid(); > + > + link =3D bpf_map__attach_struct_ops(skel->maps.sched_id_ops); > + SCX_FAIL_IF(!link, "Failed to attach struct_ops"); [Severity: Low] Do the SCX_FAIL_IF() checks on sched_id__load() and bpf_map__attach_struct_ops() leak skel? SCX_FAIL_IF() returns SCX_TEST_FAIL immediately and bypasses the out cleanup label, skipping sched_id__destroy(skel). Because runner.c runs all selftests in one process, the skeleton allocations and loaded BPF file descriptors stay leaked for subsequent tests. Initializing link to NULL and jumping to cleanup avoids this. [ ... ] > +static enum scx_test_status run(void *ctx) > +{ > + u64 id1 =3D 0, id2 =3D 0; > + > + SCX_EQ(load_and_check(&id1), SCX_TEST_PASS); > + > + /* Step 3: A new instance gets a larger id */ > + SCX_EQ(load_and_check(&id2), SCX_TEST_PASS); > + SCX_GT(id2, id1); [Severity: Low] Will SCX_EQ() invoke load_and_check() twice when it fails? SCX_EQ(_x, _y) expands _x both in the comparison and in the error format arguments, so a failing load_and_check() runs a second full load/attach/unload cycle, duplicates error output, and reports the second call's return value instead of the first. Storing the return value in a local variable before passing it to SCX_EQ() avoids the double evaluation. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203045618.9825= 39-1-changwoo@igalia.com?part=3D4