Re: [PATCH 0/4] sched_ext: Decompose scx_cid_init()
From: Tejun Heo
Date: Thu Nov 05 2026 - 12:15:57 EST
Hello,
On Thu, Nov 05, 2026 at 02:50:09PM +0800, Zhang Qiao wrote:
> scx_cid_init() grew into a ~230-line monolith interleaving table
> allocation, the node/LLC/cluster/core topology walk, the no-topo tail
> and the shard range finalization.
I don't think the refactoring makes anything better. If anything, the
result seems more complicated than the current code.
A function being long isn't an automatic reason to refactor it.
scx_cid_init() is a linear sequence of steps that each run once:
allocate the tables and masks, walk the online CPUs node by node, assign
cids to the CPUs left without topology, warn about fallbacks, fill the
shard ranges.
The current code reads top to bottom, and splitting it into
single-caller helpers doesn't make any step simpler. It just adds call
boundaries and a builder struct whose only job is to carry the counters
and masks across them, so the reader has to jump around to follow one
sequence.
> No behavior change: WARN checks, error paths, shard policy and
> publication timing are all preserved. This is preparation for
> follow-up fixes to the partial-SMT core counting in
> calc_shard_layout() and the single-core shard hard-cap corner case,
> which are deliberately kept out to keep this series a pure code
> motion.
Can you please send the fixes separately?
Thanks.
--
tejun