From: Usama Arif <usama.arif@linux.dev>
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 <usama.arif@linux.dev>
Subject: [PATCH 0/2] sched_ext: Specialize TID and scheduler hashtable compares
Date: Mon, 21 Sep 2026 11:59:10 -0700 [thread overview]
Message-ID: <20260921185943.4031480-1-usama.arif@linux.dev> (raw)
scx_tid_hash and scx_sched_hash both use naturally aligned u64 keys but
do not provide obj_cmpfn callbacks. As a result, rhashtable falls back
to rhashtable_compare() for each object visited during a lookup:
memcmp(ptr + ht->p.key_offset, arg->key, ht->p.key_len)
Although only eight bytes are compared, the generic path loads the key
offset and length at runtime and emits an out-of-line memcmp() call.
The first patch adds a specialized comparison for scx_tid_hash. This
turns comparisons in scx_bpf_tid_to_task() into direct equality tests
against scx->tid. The kfunc can be used from hot scheduling paths, so
avoiding the generic comparison is particularly useful there. The
specialized comparison also covers duplicate checks during insertion.
The second patch specializes scx_sched_hash by comparing keys directly
against ops.sub_cgroup_id. This removes the generic comparison from
scx_find_sub_sched(), which is used when dispatching child schedulers
and by the sub-scheduler capability and management kfuncs.
In both cases, the const rhashtable parameters allow the compiler to
inline the callback and reduce each object comparison to a single u64
compare. Disassembly confirms that the lookup loops no longer call
memcmp() or an out-of-line comparator.
No functional change intended.
Usama Arif (2):
sched_ext: Specialize the TID hashtable compare
sched_ext: Specialize the scheduler hashtable compare
kernel/sched/ext/ext.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
--
2.53.0-Meta
next reply other threads:[~2026-09-21 18:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 18:59 Usama Arif [this message]
2026-09-21 18:59 ` [PATCH 1/2] sched_ext: Specialize the TID hashtable compare Usama Arif
2026-09-21 18:59 ` [PATCH 2/2] sched_ext: Specialize the scheduler " Usama Arif
2026-09-22 2:15 ` bot+bpf-ci
2026-09-21 19:15 ` [PATCH 0/2] sched_ext: Specialize TID and scheduler hashtable compares Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260921185943.4031480-1-usama.arif@linux.dev \
--to=usama.arif@linux.dev \
--cc=arighi@nvidia.com \
--cc=bpf@vger.kernel.org \
--cc=bsegall@google.com \
--cc=changwoo@igalia.com \
--cc=dietmar.eggemann@arm.com \
--cc=etsal@meta.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sched-ext@lists.linux.dev \
--cc=tj@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=void@manifault.com \
--cc=vschneid@redhat.com \
--cc=yphbchou0911@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®