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=1796274882; b=AGVU8Xz+Ow9DfTy+Z6CzBhTcMxDleieXVmFD9Xlgt1n5eWvJH+3rcXBb6LFj9/oLAfID j6lQ/U4aWAz1oN1dTnmet5CracSxyoTNw3r4ehKAT8pCJ7SfJdx+FxJHnu2aTvDZKlSM3 sSB2WKtrZ0t9Tx9C3tzlv43pEGXjLMErr+Hrqm+yKSSSwrjQC9iHl4vJKk4uVpfJvaRa0 R1twe+tI7oMBehkFFHVW2gFUv9+KZTx7iaSB6Tuiur/9YY/M8XxLj4V5R8zDuPteMZE+e taVAyIk1+qvlys32uU69tSKgGiD/rKY71WDDTWy2LX+Ei5v3PAHRsuNcBxX3LwtNfdw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796274882; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=n+5qaXNKq+KfmJaD/4Hu3IxApe8JTbmFn9Qf3mfNtVQ=; b=uCPYsmBYZqhuMhKqYfIGtNEAT1YToCxq8UQ8q0CMsFF7ebx15ba4Q8f84ygoLPIQ8gU4 MPyq40RZFQTAGEo99w8jWt4gwFnR372J9N7lUiMQRGg+3q02oR9j+0vFYpsa+lbcW3d2q DYZSs+E7FRkbuaF5OgAMvrCWt0XWBS2ze4JOxJVJo9oXP+t2kmTF5fGITbSwRqaR2g1pk Ry/2Xj2uzc/JbB1mEpkA1dKcZCy/YKUF20yzHsTyDdsYkZW3B9h6eEIIinzn57FTeRQIl HMkSgMBc7geOApXi2qPbV4ApSJ4TUCJ6BLmJvF0Nimnr9ERvpMn4dmdqpvAPCr6uhyA== 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="BZuLabZ/"; 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 B5CC1606A322 for ; Thu, 3 Dec 2026 05:14:42 +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=BZuLabZ/ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 430E31F00893; Thu, 3 Dec 2026 05:14:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796274882; bh=n+5qaXNKq+KfmJaD/4Hu3IxApe8JTbmFn9Qf3mfNtVQ=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=BZuLabZ/xmcgM7dCN5QImhANRTCTnAq2iAdsekkrfjlY7fLrDQmyB58KUCxW2S4/H RSFejbkCFKYkT/X3/kA1Ecvpc4iLOEAA1uxJzo02JZoEdmuOijasAGQP7we+mCpd6j 2nyNrfHVHYJeOwWW5bvxcOeLJLPzHCR4XbZYVuzE1s+9c33/y5VBzYRJS0Qsics40d NTKqntNJxdW5kkAmHZSiE1Q0jliuRlx/AmkFtteeNoUQTOpRGPYoEccjPg6f6lFNlU QYyW5WetfgpzMd5o8O9227+U3T5niAUbEPPKnKs8S9v44rUQXgzUM3tKA3iwUXAYF4 28mfk4chZeD7Q== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 3/8] sched_ext: Add 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-4-changwoo@igalia.com> References: <20261203045618.982539-1-changwoo@igalia.com> <20261203045618.982539-4-changwoo@igalia.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 05:14:41 +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 2 potential issues to consider: - [Medium] sched_ext: scx_bpf_task_sched_id() ignores task when CONFIG_EXT_SUB_SCHED=3Dn - [Low] sched_ext: scx_bpf_task_sched_id() omits const on task_struct pointer -- commit d4e2b84786b2aa7b0554a97e35d420c7934a3861 Author: Changwoo Min sched_ext: Add scx_bpf_sched_id() and scx_bpf_task_sched_id() This commit adds the scx_bpf_sched_id() and scx_bpf_task_sched_id() kfuncs and their compat wrappers to let BPF programs query a scheduler's instance id and the id of the scheduler owning a given task. > diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c > index 7e5f58f1d8447..2ebc67916757a 100644 > --- a/kernel/sched/ext/ext.c > +++ b/kernel/sched/ext/ext.c > @@ -11940,6 +11940,39 @@ __bpf_kfunc s32 scx_bpf_task_cpu(const struct ta= sk_struct *p) > return task_cpu(p); > } > =20 [ ... ] > +/** > + * scx_bpf_task_sched_id - Id of the scheduler that owns a task > + * @p: task of interest > + * > + * Return the instance id of the scheduler @p is on, see scx_bpf_sched_i= d(), 0 > + * if @p is not on any. Without the rq lock of @p, @p may move to another > + * scheduler right after. > + */ > +__bpf_kfunc u64 scx_bpf_task_sched_id(struct task_struct *p) [Severity: Low] Should the task_struct pointer parameter here (and in the ksym declaration and wrapper in tools/sched_ext/include/scx/compat.bpf.h) be const? scx_bpf_task_sched_id() only passes p to scx_task_sched_rcu(), and its adjacent read-only task kfuncs (scx_bpf_task_running(), scx_bpf_task_cpu(), scx_bpf_task_cid()) all take const struct task_struct *p. Omitting const forces BPF callers with a const pointer to cast it away. > +{ > + struct scx_sched *sch; > + > + guard(rcu)(); > + sch =3D scx_task_sched_rcu(p); > + return sch ? sch->id : 0; > +} [Severity: Medium] Does scx_bpf_task_sched_id() return 0 for unowned tasks when CONFIG_EXT_SUB_SCHED is disabled? When CONFIG_CGROUPS=3Dn, CONFIG_EXT_SUB_SCHED is disabled and scx_task_sched_rcu(p) in kernel/sched/ext/internal.h ignores p and returns rcu_dereference_all(scx_root) directly. That makes scx_bpf_task_sched_id() return scx_root->id for tasks not on any scheduler, such as idle tasks. In scx_root_disable(), scx_root also stays non-NULL after WRITE_ONCE(sch->dead, true) until RCU_INIT_POINTER(scx_root, NULL), so scx_bpf_task_sched_id() keeps returning the dead scheduler's id even after scx_bpf_sched_id() returns 0. As a result, BPF callers checking scx_bpf_task_sched_id(p) will misclassify unowned tasks. Checking scx_get_task_state(p) and !READ_ONCE(sch->dead) on the !CONFIG_EXT_SUB_SCHED path would preserve the documented contract. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203045618.9825= 39-1-changwoo@igalia.com?part=3D3