From nobody Thu Sep 24 18:38:15 2026 Received: from mta1.migadu.com (out-62.mta1.migadu.com [95.215.58.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 676C14BE447 for ; Mon, 21 Sep 2026 18:59:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.62 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790017195; cv=none; b=e4/IQhQIv4l2Rmdg8cbV/JCi2uyeDmG1P7x8cS1frjcRbtu1mtXmFmE5dpktTuSCIu6s/+4uOPOaimJ6TIomHkD7Oq6VH36oG312pbXJ7NJ/48vnuS3a3x9s0wOqzN0J0yQdQDUt0LvDdyhgqKSg2oXojJGh8kzfCrzPK8PhUxk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790017195; c=relaxed/simple; bh=Pofm77rzod73Bt78uY4E3DD44RNhgOcg2uywXtDlWwI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pvBlPTll/wAxkefIAzGWO2lLUUYGQUHcB5K1qsu44+uz+/TSerGbLCkyeaLDtzD2Rr2i4cJ7JJ9R0D4APJJZk7HkrF81d1Rw+scm/u9wh+SrEwJLhi3/6GGv54kwsa3rmggJS7MvLDkP2V0iCo0akY9RpPG4oLR8uCUrHS9ggi4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Nb8aaqsY; arc=none smtp.client-ip=95.215.58.62 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Nb8aaqsY" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=Pofm77rzod73Bt78uY4E3DD44RNhgOcg2uywXtDlWwI=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1790017190; v=1; x=1790621990; b=Nb8aaqsYC7gc15nF4KAHNxgQHBbHU0FUWw4HuzyQZ5+r4AokV7j4ul92QCgBPz1TsCVuqPnS JYaW8UbwnacPJRaPcPTYwlUf6s4BXIMJhOGE9UFJwCeky/tiP2Q36ZetzIvpTwAyk8yO5sEd3Gh FZFKJQGCJfUa5ngHkfwMysZ0= X-Envelope-To: linux-kernel@vger.kernel.org Received: by mta11.migadu.com with ESMTPS id 3e8edb1392227131; Mon, 21 Sep 2026 18:59:50 +0000 X-Mizu-Trace-ID: 3e8edb1392227131 X-Migadu-Flow: FLOW_OUT From: Usama Arif To: arighi@nvidia.com, bpf@vger.kernel.org, bsegall@google.com, changwoo@igalia.com, dietmar.eggemann@arm.com, etsal@meta.com, juri.lelli@redhat.com, kprateek.nayak@amd.com, linux-kernel@vger.kernel.org, mgorman@suse.de, mingo@redhat.com, peterz@infradead.org, rostedt@goodmis.org, sched-ext@lists.linux.dev, tj@kernel.org, vincent.guittot@linaro.org, void@manifault.com, vschneid@redhat.com, yphbchou0911@gmail.com Cc: Usama Arif Subject: [PATCH 1/2] sched_ext: Specialize the TID hashtable compare Date: Mon, 21 Sep 2026 11:59:11 -0700 Message-ID: <20260921185943.4031480-2-usama.arif@linux.dev> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260921185943.4031480-1-usama.arif@linux.dev> References: <20260921185943.4031480-1-usama.arif@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" scx_tid_hash_params does not provide an object comparison function, so rhashtable falls back to rhashtable_compare(). Although the key is one naturally aligned u64, the generic comparison reads the key offset and length from the table parameters at runtime and emits an out-of-line memcmp() for each element walked. scx_bpf_tid_to_task() can sit on hot scheduling paths. Supply an obj_cmpfn so the const parameters passed into the inlined rhashtable lookup specialize the comparison to a single equality test against scx->tid. The result is only tested against zero, so the ordering provided by memcmp() is not observable. No functional change intended. Suggested-by: Tejun Heo Signed-off-by: Usama Arif --- kernel/sched/ext/ext.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c index 646affba4e3c4..288d6b80bbca0 100644 --- a/kernel/sched/ext/ext.c +++ b/kernel/sched/ext/ext.c @@ -52,10 +52,21 @@ struct rhashtable scx_sched_hash; #endif =20 /* see SCX_OPS_TID_TO_TASK */ +static __always_inline int scx_tid_cmpfn(struct rhashtable_compare_arg *ar= g, + const void *ptr) +{ + const struct sched_ext_entity *scx =3D ptr; + + BUILD_BUG_ON(sizeof_field(struct sched_ext_entity, tid) !=3D sizeof(u64)); + + return scx->tid !=3D *(const u64 *)arg->key; +} + static const struct rhashtable_params scx_tid_hash_params =3D { .key_len =3D sizeof_field(struct sched_ext_entity, tid), .key_offset =3D offsetof(struct sched_ext_entity, tid), .head_offset =3D offsetof(struct sched_ext_entity, tid_hash_node), + .obj_cmpfn =3D scx_tid_cmpfn, .insecure_elasticity =3D true, /* inserted/removed under scx_tasks_lock */ }; static struct rhashtable scx_tid_hash; --=20 2.53.0-Meta From nobody Thu Sep 24 18:38:15 2026 Received: from mta0.migadu.com (out-139.mta0.migadu.com [91.218.175.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6862F47CA65 for ; Mon, 21 Sep 2026 18:59:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.139 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790017196; cv=none; b=Og1sVByDTDhb94QDX0jEVTHXUlJwczfelJ21HHSrw9/TGBphGMse3v4nuPCp3v0N4i1XkaImK9QMJwbj1ylFSOGKe50zw213hO0Oi+t7rWgkE9g3bOgh7z0AiqTLBKzo082mtV4THg5baFWakUZ1ttyow6CUZVJlX3+sIvExcwk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790017196; c=relaxed/simple; bh=owL6q3Fk9/55Zw1NYDaaYKrFvFrDV8FYtck2SkEVXUk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uSN2dlnW+bnaP28ONeRn9VGG5rix6cnbKRK/Q28Eo4gT1nxh0TB24XTvPFEM97onai3YgH7RwOQFlzeO4+1x6l53AuanMZWBQNfrJ9yf8lrqWs+hlstyYJFX1++b2iG8RZ9lMoOfc3hePbUc0iEXzB1l8oSUIM41bSNB6HuGOck= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=vGRQM2Gx; arc=none smtp.client-ip=91.218.175.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="vGRQM2Gx" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=owL6q3Fk9/55Zw1NYDaaYKrFvFrDV8FYtck2SkEVXUk=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1790017192; v=1; x=1790621992; b=vGRQM2GxPtn9yhfYeP2kSB6orQZ641hGUiBhFnYhqS5p7qdGdFaDtTV8j6WKOLHq+0+Q5Y8A xh056bi544xXDJunL9Qe989UPO9HzxXb+6K4EcKZsDwnOdDNjlwCbsFRv3ql1Bx7HoJXlaRJlX6 Uq3pEZcHOENlusOytBwcE8cY= X-Envelope-To: linux-kernel@vger.kernel.org Received: by mta12.migadu.com with ESMTPS id c7c189aa1dad7a7d; Mon, 21 Sep 2026 18:59:52 +0000 X-Mizu-Trace-ID: c7c189aa1dad7a7d X-Migadu-Flow: FLOW_OUT From: Usama Arif To: arighi@nvidia.com, bpf@vger.kernel.org, bsegall@google.com, changwoo@igalia.com, dietmar.eggemann@arm.com, etsal@meta.com, juri.lelli@redhat.com, kprateek.nayak@amd.com, linux-kernel@vger.kernel.org, mgorman@suse.de, mingo@redhat.com, peterz@infradead.org, rostedt@goodmis.org, sched-ext@lists.linux.dev, tj@kernel.org, vincent.guittot@linaro.org, void@manifault.com, vschneid@redhat.com, yphbchou0911@gmail.com Cc: Usama Arif Subject: [PATCH 2/2] sched_ext: Specialize the scheduler hashtable compare Date: Mon, 21 Sep 2026 11:59:12 -0700 Message-ID: <20260921185943.4031480-3-usama.arif@linux.dev> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260921185943.4031480-1-usama.arif@linux.dev> References: <20260921185943.4031480-1-usama.arif@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" scx_sched_hash_params does not provide an object comparison function, so rhashtable falls back to rhashtable_compare(). Although the sub-cgroup ID key is one naturally aligned u64, the generic comparison reads the key offset and length from the table parameters at runtime and emits an out-of-line memcmp() for each element walked. Supply an obj_cmpfn so lookups specialize to a single equality test against ops.sub_cgroup_id. ext.c and sub.c are included in the same build_policy.c translation unit, so the compiler can fold the const callback into scx_find_sub_sched() even though its source is in sub.c. The result is only tested against zero, so the ordering provided by memcmp() is not observable. No functional change intended. Suggested-by: Tejun Heo Signed-off-by: Usama Arif --- kernel/sched/ext/ext.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c index 288d6b80bbca0..87fa09c71eb0f 100644 --- a/kernel/sched/ext/ext.c +++ b/kernel/sched/ext/ext.c @@ -41,10 +41,21 @@ struct scx_sched __rcu *scx_root; LIST_HEAD(scx_sched_all); =20 #ifdef CONFIG_EXT_SUB_SCHED +static __always_inline int scx_sched_cmpfn(struct rhashtable_compare_arg *= arg, + const void *ptr) +{ + const struct scx_sched *sch =3D ptr; + + BUILD_BUG_ON(sizeof_field(struct scx_sched, ops.sub_cgroup_id) !=3D sizeo= f(u64)); + + return sch->ops.sub_cgroup_id !=3D *(const u64 *)arg->key; +} + const struct rhashtable_params scx_sched_hash_params =3D { .key_len =3D sizeof_field(struct scx_sched, ops.sub_cgroup_id), .key_offset =3D offsetof(struct scx_sched, ops.sub_cgroup_id), .head_offset =3D offsetof(struct scx_sched, hash_node), + .obj_cmpfn =3D scx_sched_cmpfn, .insecure_elasticity =3D true, /* inserted under scx_sched_lock */ }; =20 --=20 2.53.0-Meta