Repository navigation
Conversation
CPU PD's target residency is 10 ms and its exit latency 10 us, on every
Apple SoC this driver binds to. On a J514S (MacBook Pro 14", M3 Pro), a
running desktop rarely predicts 10 ms of idle: with the usual applications
open and the display off, the cores spent only 62-76% of their idle time
in CPU PD under menu, and menu counted two thirds of its CPU PD entries
"too deep". Those short CPU PD periods save power all the same: teo, which
avoids them, kept the cores in CPU PD 9% of the time and drew 0.9 W more.
On the J514S, set the target residency to 500 us and the exit latency to
20 us. The values were switched at runtime on this commit, alternating
with the old ones, two rounds each; power is the SMC's total system power:
display off, usual applications open, an audio stream active (medians):
10 ms / 10 us 4.78, 4.77 W (CPU PD 62-63% of idle time)
500 us / 20 us 3.88, 3.86 W (CPU PD 94%)
1080p60 software-decoded video, 55 s (mean), no dropped frames in any:
10 ms 14.09, 13.61 W; 500 us 12.71, 12.73 W; 100 us 12.39, 12.31 W
A quiet desktop with the display off saved less: about 0.1-0.2 W at
500 us (with a 10 us exit latency) and 0.24 W at 100 us.
100 us was evaluated as well and saved slightly more power, but costs
more where a wakeup from CPU PD sits on the critical path. Averages of
two rounds, 10 ms / 500 us / 100 us:
fio 4k random read, QD1, O_DIRECT 10344 / 9709 / 9018 IOPS
pgbench TPC-B, 1 client (fsync) 1341 / 1369 / 1256 tps
pgbench select-only, 1 client 16525 / 16875 / 15927 tps
500 us is the balanced choice: about 75% of the saving at half the QD1
cost and none to single-client database throughput. With 8 pgbench
clients, redis-benchmark at one client, a three-pass kernel build,
hackbench and Wi-Fi ping, results matched within run-to-run noise, and
a PipeWire stream with a 64-frame quantum saw 0-1 xruns in 30 s either
way.
A 1 ms timer woke 57 -> 68 us late (p50) and a pipe round trip to an
idle core took 10-20 us longer once CPU PD was used; the p99 and maximum
varied as much between runs of one setting as between settings. A PM
QoS request below 20 us keeps the cores in WFI. suspend-to-idle picks
the deepest state regardless of these values. Other Apple SoCs keep the
defaults: only this machine was measured.
Assisted-by: Claude:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Ilyas Akin <ashnwor@gmail.com>
|
Tested on a second J514S. Not tested: power on its own, and battery runtime. Test setup
Testing and write-up assisted by Claude Code. |
|
Hi! Same finding on an M1 Pro, with numbers in case they are useful. On my J314s (t6000) the 10 ms target residency keeps the cores in WFI a lot on a quiet desktop (cpu0 about 20 % of the time, around 160 entries a second). I lowered it to 200 us on a local 7.3 kernel, with a small out-of-tree module that changes the registered state's target residency, and compared 10 ms against 200 us in ten alternating 45 s windows on battery with the screen off: 1.14 → 1.00 W, so 0.13 ± 0.03 W. Forcing CPU PD by disabling state 0 in sysfs gave the same power (0.996 against 0.986 W), but a pipe ping-pong between two processes then took 31–38 us per round trip instead of 3.8 us. With the lower residency and state 0 left enabled it stayed around 5 us. It has been loaded at every boot since the 18th. I didn't touch the exit latency and I haven't run workloads like yours, so I can't say whether 200 or 500 us is the better value here. I haven't run your commit either. I'd be happy to test it with a J314s entry, or to send one as a follow-up after this is in. |
What this changes and why
cpuidle-applegives CPU PD a 10 ms target residency and a 10 us exit latency on every Apple SoC it binds to. On the J514S (MacBook Pro 14", M3 Pro, T6030), a running desktop rarely predicts 10 ms of idle:above).This sets CPU PD's target residency to 500 us and its exit latency to 20 us on the J514S only. Every other Apple SoC keeps the defaults.
Why 500 us (balanced), and what 100 us did
I swept 10 ms / 2 ms / 500 us / 100 us / 20 us and then compared 10 ms, 500 us and 100 us under real workloads. 100 us saved slightly more power, but costs more where a wakeup from CPU PD sits on the critical path:
500 us keeps about 75% of the saving, at half the QD1 cost and with no measurable cost to single-client database throughput. If someone wants the extra power, a power-saver profile could lower it further, but that's a separate change.
What was tested
macsmc_hwmon"Total System Power"), on AC at 100%.A quieter desktop saved less: about 0.1-0.2 W at 500 us and 0.24 W at 100 us. The more short idle periods the system has, the larger the saving.
Unchanged within run-to-run noise:
perf bench sched messaging(hackbench, 0.25 s);Wakeup latency (a 1 ms
clock_nanosleeploop and a pipe ping-pong between two cores, 3000 iterations, p50):The p99 and maximum varied as much between two runs of one setting as between the settings. That 10-20 us is why the exit latency is now 20 us: a PM QoS request below 20 us keeps the cores in WFI.
Host test:
tools/testing/selftests/drivers/gpu/apple-dcp/run.shcompiles this driver into itscpuidle-s2idlereplay. Its results match the base's. Locally that stage fails at the base too, on a newer clang's-Wunused-but-set-globalin the harness. With only that warning off, the replay passes at the base and at this head.Build:
make W=1 drivers/cpuidle/cpuidle-apple.o(clang) is clean. checkpatch is clean apart from the trailers.What was NOT tested
Risk
AI assistance
🤖 Generated with Claude Code