sched_ext: Specialize TID and scheduler hashtable compares
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest2 patches 1 replyIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | sched_ext: Specialize the TID hashtable comparekernel/ | +11 | 0 replies | |
| 2/2 | sched_ext: Specialize the scheduler hashtable comparekernel/ | +11 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/2] sched_ext: Specialize TID and scheduler hashtable compares
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(+)
Signature · 1 line
2.53.0-Meta