Commit a6d1ca0
committed
sched: switch to BESTWAIT hardware interrupt steering, retire software lowprio
Replace the software reschedule-interrupt steering with the hardware
BESTWAIT/SCHEDCFG comparator (V85 spec Rev AB, section 6.5). The hardware
raises RESCHED_INT whenever any HW thread's STID.PRIO is strictly worse than
the armed BESTWAIT value and then resets BESTWAIT to 0x1FF, so the kernel no
longer needs to designate a victim thread in software.
TARGET=ref passes on archs 68/73/81. TARGET=opt is intentionally NOT converted
yet -- the opt *.Svariants still implement the old software model and will be
rewritten in a follow-up after this ref change is reviewed.
Enable hardware steering
-------------------------
* boot.ref.S: set imask = 0 on all threads so every HW thread is a qualified
RESCHED target. Previously imask was closed (-1) and software opened exactly
one victim's RESCHED bit via lowprio_imask().
* setup.ref.c: SCHEDCFG.EN | INTNO(RESCHED_INT) arms the feature at boot.
BESTWAIT arming moved into the readylist API
---------------------------------------------
Arming the comparator is now the readylist's job. New *_arm variants
(H2K_ready_append_arm / _insert_arm / _remove_arm) call H2K_set_bestwait(
H2K_ready_best_prio()); the plain variants do not touch BESTWAIT. Callsites
choose based on whether they are a wake/sleep transition or a mid-reschedule
step:
arm : intpool, popup, futex_common (wakes that go straight to H2K_switch),
create, vmop kill paths, vmint deliver, resched, and getbest.
noarm: yield and futex_pi raise -- these are immediately followed by
H2K_dosched on the same HW thread, which re-arms via getbest.
resched() must arm: the hardware fire that delivered the interrupt already
reset BESTWAIT to 0x1FF, so re-arming immediately closes the disarmed window
before dosched's getbest/cluster-search runs. Voluntary paths (yield/hwconfig)
did not fire and still hold a valid armed value, so they can defer to dosched.
Delete the software steering subsystem
---------------------------------------
* Removed sched/lowprio/ entirely (lowprio_imask/highprio_imask/priomask
designated-victim machinery and H2K_lowprio_notify).
* Removed the priomask block from dosched.ref.c and the H2K_lowprio_notify
call site; deleted check_sanity.ref.c (H2K_check_sanity / _unlock). Callers
now BKL_UNLOCK and return directly (futex_classic, futex_pi, create).
* switch.ref.S: sleep path no longer writes priomask; opens imask fully;
switch-in path returns via k0unlock/jumpr r31 instead of jumping to the
deleted check_sanity_unlock.
Retire the software runlist mirror
-----------------------------------
* Removed data/runlist/ and checkers/checker_runlist/. The runlist[]/
runlist_prios[] mirror and the wip_dummy_runlist* timing shim only fed
H2K_runlist_worst_prio() for software steering; nothing reads it once
steering is in hardware.
* Every H2K_runlist_push/_remove replaced by a direct
status = H2K_STATUS_RUNNING (dosched, intpool, popup, setup boot path).
futex_pi priority sync
----------------------
PI boost/restore now writes dest->prio and set_thread_stid_prio() directly
(no runlist mirror). unlock_pi restores me->base_prio in software and hardware
STID up front, before releasing, so the BESTWAIT comparator reads the correct
priority and cannot hide the unblocked holder behind a stale boosted value.
Spec-mandated synchronization
-----------------------------
switch.ref.S adds isync after STID writes (V85 spec: "After updating the STID,
an isync instruction must be executed to ensure that the new STID value is
fully observed"). This is a correctness requirement, not removable overhead --
and the change is still faster overall (see below).
CLUSTER_SCHED guards
--------------------
Convert every `#ifdef CLUSTER_SCHED` to `#if CLUSTER_SCHED` so the single
`#define CLUSTER_SCHED 0/1` in h2_common_defs.h actually gates the cluster/coproc
code. Behavior is identical to the previously-tested build: the cluster paths
were already runtime-gated by `cluster`sched == 0`, so compiling them out
changes nothing observable. H2K_ready_head reduces to returning the ready-list
head; getbest's sleep branch reduces to `return NULL`.
Performance (futex/pi TOTAL TEST TIME, pcycles)
-----------------------------------------------
ARCHV before (SW) after (HW) delta
68 1,813,302 1,731,697 -81,605 (-4.5%)
73 1,833,006 1,765,404 -67,602 (-3.7%)
81 1,968,943 1,889,073 -79,870 (-4.1%)
Faster on every arch despite the added spec-mandated isyncs, from removing
per-schedule software work: the runlist_worst_prio() walk, priomask
bookkeeping, H2K_lowprio_notify, and the mirror writes.
Follow-ups (not in this change)
-------------------------------
* Rewrite the opt *.Svariants to the pure-BESTWAIT model; TARGET=opt failures
are expected until then.
* Research whether wait_mask is still needed for cluster scheduling; if not,
drop it and its write sites in resched/intpool/popup/switch.ref.S/setup.
Signed-off-by: Zeev Belinsky <zbelinsk@qti.qualcomm.com>1 parent 5a88e2c commit a6d1ca0
99 files changed
Lines changed: 280 additions & 1523 deletions
File tree
- kernel
- build/offsets
- checkers/checker_runlist
- data
- globals
- readylist
- test
- runlist
- test
- error/fatal/test
- event
- intpool
- test
- passthru/test
- popup
- test
- futex
- futex_classic
- futex_common
- futex_pi
- futex/test/tests
- multi_wake
- pi
- init
- boot
- setup
- test
- sched
- check_sanity
- test/tests
- H2K_bestwait
- H2K_check_sanity
- scenarios
- dosched
- test/test
- lowprio
- test
- resched
- test
- switch
- yield
- test
- thread
- create
- test
- stop
- test
- traps
- config
- hwconfig
- info
- prio
- test
- util
- hw
- max
- stmode/test
- vm
- vmcache
- vmfuncs
- vmint
- test
- vmmap
- vmop
- test
- vmwork
- libs/h2
- common
- config
- scripts
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
| 122 | + | |
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| |||
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | | - | |
150 | | - | |
151 | 149 | | |
152 | 150 | | |
153 | 151 | | |
| |||
218 | 216 | | |
219 | 217 | | |
220 | 218 | | |
221 | | - | |
| 219 | + | |
222 | 220 | | |
223 | 221 | | |
224 | 222 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
147 | | - | |
| 147 | + | |
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
233 | | - | |
| 233 | + | |
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| |||
86 | 85 | | |
87 | 86 | | |
88 | 87 | | |
89 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
90 | 111 | | |
91 | 112 | | |
92 | 113 | | |
| |||
123 | 144 | | |
124 | 145 | | |
125 | 146 | | |
126 | | - | |
| 147 | + | |
127 | 148 | | |
128 | 149 | | |
129 | 150 | | |
| |||
223 | 244 | | |
224 | 245 | | |
225 | 246 | | |
226 | | - | |
| 247 | + | |
227 | 248 | | |
228 | 249 | | |
229 | 250 | | |
| |||
246 | 267 | | |
247 | 268 | | |
248 | 269 | | |
249 | | - | |
| 270 | + | |
250 | 271 | | |
251 | 272 | | |
252 | 273 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
233 | | - | |
| 233 | + | |
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
| |||
0 commit comments