Repository navigation
clpc/g17: busy-share memory floor from the DT + light effort on every G17 - #1369
AxxzyWasTaken wants to merge 8 commits into
Conversation
1257b68 to
37559c1
Compare
RyanTheTide
left a comment
There was a problem hiding this comment.
@AxxzyWasTaken thanks for the rebase and the power numbers. Three things before this can go in:
- apple_clpc_hw_t6040 is also the M4 Pro's table. The CPU map change (DCS 1,1,3,4 and fabric 0,0,0,0 at the top, and level_khz for the E cluster) lowers the memory floor a busy CPU gets on the M4 Pro, where the comment above the table measures 237-242 GB/s at DCS 5 / fabric 2. Please give T6041 its own table and leave T6040 as it is, or add M4 Pro measurements. We can run the M4 Pro side if you split it.
- The light-effort governor is in the shared G17 code and on by default, so it also changes the A18 Pro and M4 Pro. A 120 fps game reads about a third busy, under the 350 entry point, and stays under the 750 exit point once it runs at half effort. Please scope it per SoC (match data, T6041 first) until it has frame-time results on games, not only power.
- Please replace the five g17_light_* module parameters with per-SoC values, as was done for the CLPC thresholds.
|
Thanks. All three are in 33db416, on top of a merge of the current integration/aurora (e6588ee, clean).
Tested: Image and modules build at |
RyanTheTide
left a comment
There was a problem hiding this comment.
@AxxzyWasTaken thanks, this addresses all three points. The T6040 table matches the base again, the T6041 table is picked by machine compatible, and light effort is off everywhere except T6041 with no module parameters. Two things before merge:
- Please boot this head (33db416) on the M4 Max and post the scrolling power and a GPU smoke result. The light-effort and table code moved since your last numbers.
- Small race in report_busy(): two submitters that both see elapsed >= BUSY_WINDOW_NS each swap BUSY_WINDOW_TOTAL, and the second one reports about 0 permille for the same window, which on T6041 also counts as a quiet window. A compare_exchange on BUSY_WINDOW_START (only the winner reports) closes it. Optional: clearing busy_valid when the GPU goes inactive, so a new burst does not start from the share it had before a long idle.
We will run the M4 Pro and A18 Pro side to confirm nothing changes there.
|
Thanks. The race is fixed in 2a87da9: Boot of this head on the M4 Max (J616c), release
|
|
Merged the current integration/aurora (677be39) in 08860ee, so this merges again. The only conflict was the Built with Still open from your 13 Nov review: the scrolling power on the M4 Max. I'll post it from a boot that has the backlight. |
On T6040 and T6041 any reported GPU work holds the top memory and fabric floor. At 120 Hz a scrolling browser keeps the GPU reported busy most of the time for a few percent of real execution, so light desktop use pays for the top DCS state. Let the GPU driver report its busy share per window with apple_clpc_gpu_set_busy() and pick the floor from a per-SoC table in struct apple_clpc_hw: on T6040/T6041 DCS 1, 2, 4 or 5 and fabric 0, 0, 0 or 2, split at gpu_busy_mid (160), gpu_busy_high (500) and gpu_busy_top (800) permille. A higher level applies at once. A lower one applies at the first CLPC sample at least 400 ms after the last sample that asked for the current level or a higher one, so the down-step happens at least 400 ms after the last change, later if the sampler runs late. A GPU that reports no share, and every SoC without the table, keeps the top of the map. The debugfs status shows the reported share and the current level without moving it. The CPU side had the same problem: a cluster at its own top speed asked for DCS 5 and fabric 2 even when that was the E cluster. Take the map quarters from 4.512 GHz for both clusters, and lower the T6040 map to DCS 1, 1, 3, 4 with fabric 0. On the M4 Max on AC, compared with the old table: scrolling 24.9 W to 22.1 W at 120 fps with no long frames, a page workload 23.84 W to 22.73 W for 0.9 % less score. The CLPC host demand test now covers the busy-share table, a GPU that reports no share and the down-step hold. Assisted-by: LLM Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
Sum the engine time every client is charged and report its share of a 200 ms window to CLPC, which then keeps the top memory and fabric floor for GPU work that really is busy. The same windows drive a light effort governor. Four quiet windows in a row (under 35 % busy, no job of 3 ms or more) drop the firmware to half effort, and 75 % busy or a 7 ms job goes back to full. Light effort runs the same work about twice as long, so the way out sits at about twice the way in, or work that fits light effort sticks at full. The share sent to CLPC is doubled at full effort so one floor table fits both. note_submission() returned effort_full, so the lockless path skipped the governor. It now takes the slow path when the governor wants light. g17_light_effort (65536 is full, 0 turns this off), g17_light_enter, g17_light_exit, g17_light_job_enter_us and g17_light_job_exit_us are runtime parameters. Effort sweep on the M4 Max with a 1080p30 clip: full 14.0 W, 32768 10.4 W, and below 50 % gained nothing. Assisted-by: LLM Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
…t effort to T6041 The M4 Pro shares the CLPC compatible and the G17 code with the M4 Max, so both changes reached it unmeasured. Give T6041 its own CLPC table, picked on an "apple,t6041" machine, and leave apple_clpc_hw_t6040 as integration/aurora has it. Move the light effort thresholds from five module parameters into the per-SoC G17 Config, set only for T6041; other SoCs run every submission at full effort and report the busy share unscaled. Assisted-by: LLM Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
Two submitters that both saw the window end each swapped the busy total, and the second reported about 0 permille for the same window, which on T6041 also counted as a quiet window. Only the submitter that moves the window start reports it now. Forget the reported share when the GPU goes idle, so that a new burst starts at the top of the ladder instead of from the share before a long idle. Assisted-by: LLM Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
08860ee to
38e1273
Compare
|
Rebased without the two merge commits: the four commits now sit directly on Disclosure: prepared with an AI tool (the commits carry Assisted-by: LLM); tested on my M4 Max as described. |
|
Tested on the J614c (16-core CPU / 40-core GPU M4 Max), at 38e1273, with #2173 for the GPU link, on top of #1664. It boots, the GPU registers with the CLPC, and there are no new warnings. The GNOME desktop and YouTube in Firefox (software decode, about 10 W for the whole machine at brightness 54) work as before. I don't have a GPU-heavy workload, so I didn't do an A/B power test and can't confirm the savings. It conflicts with my #1796 (the J614c's own Low Power ceiling, 2616 MHz instead of 2808). #1796 replaces 🤖 Generated with Claude Code |
|
Thanks for this, and for the careful power measurements on the M4 Max. One structural point before it can go in. We select behaviour by a hardware property, not by the machine it was measured on, and improvements that come from how the GPU works should apply to every chip with that GPU:
If you make the light effort the default, we can supply A/B rows on our M1 Pro, M2, M4 Pro and A18 Pro. |
The CLPC driver's per-SoC table says which DCS and fabric state a busy CPU cluster and reported GPU work get. Those states come from measurements of a SoC's memory: latency and power at each state. The M4 Pro and the M4 Max share the CLPC compatible but not the measurements, so the driver picked the M4 Max's table by machine compatible. Describe the measured states on the performance-controller node instead: the CPU states by quarter of a reference frequency, and the GPU states by the busy share the GPU driver reports. All four properties are optional; without them the compatible's own table applies, as before. Assisted-by: LLM Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
Give the M4 Max's CLPC node the states measured on the J616c, the ones the driver's T6041 table has: CPU DCS 1, 1, 3, 4 and fabric 0 by quarters of 4512 MHz, and GPU DCS 1, 2, 4, 5 and fabric 0, 0, 0, 2 split at 160, 500 and 800 permille of reported busy share. The measurements move from the driver's table comment to the node. The driver reads them from the next commit on; until then its T6041 table holds the same values. Assisted-by: LLM Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
apple_clpc_machine_hw() picked apple_clpc_hw_t6041 on an "apple,t6041" machine. Read the states from the node instead (apple,pmc.yaml): the compatible's table, with apple,cpu-memory-states, apple,cpu-level-mhz, apple,gpu-busy-memory-states and apple,gpu-busy-permille in place of its own where the node has them. A node with cells that don't fit fails the probe. The T6041 table goes. Its states are in t6041.dtsi, and the rest of it was the T6040 table's: the same rails, sustain, GPU input, ANE states and low-power profile. The ANE cluster floor, which it left out, stays M4 Pro only through the T6040 table's ane_cluster_machine. So T6041 gets the same floors as before, and the M4 Pro, whose node has none of the properties, keeps its own. Any SoC can now take its measured states from its device tree without a driver change. tools/asahi/clpc-gpu-demand-tests.py builds the T6041 table from the t6041.dtsi values through the driver's parsers, checks they are the J616c measurements, and runs the busy-share test on it, with negative controls for unchecked cells. Assisted-by: LLM Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
Nothing in the quiet-window logic is specific to the M4 Max: it reads the share of each window the GPU spends executing and the longest job, on every G17. Give every G17 configuration the same light effort, power::LIGHT_DEFAULT, with the values T6041 had. A SoC that must run at full effort can still set None, with the hardware reason at its entry. T6041 is unchanged. The values were measured on the M4 Max only, and there are no frame-time results from games yet. On M5 (T6050, T8142) the firmware's effort word gets the value only for submissions the host waits on, as before (InitData::submission_effort()). The busy share the CLPC gets is now reported in light effort's terms everywhere; only a CLPC node with GPU busy states (T6041 today) uses it. Assisted-by: LLM Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
|
Thanks. Both points are addressed in four new commits on top.
The @joske, about the order with #1796: now that #1369 has no T6041 table, there is nothing to convert to your per-machine low-power table. I test-merged #1796's head (25ab204) onto this one. The only conflict is in Tested:
Disclosure: prepared with an AI tool (the commits carry Assisted-by: LLM); tested as described. |
|
Thanks for the rework: the light effort is now the default on every G17 configuration and the CLPC memory states come from the DT instead of the machine compatible, which is exactly the shape we were after. We will run the A/B rows on our M4 Pro and A18 Pro against this head. |
Replaces #1089, rebased onto
integration/auroraas requested there.This lowers power on the M4 Max in everyday use. Before it, any reported GPU work held the top memory and fabric floor, and the GPU ran even quiet work at full effort.
CLPC busy share: the GPU driver reports its busy share, and reported GPU work gets the memory states for that share. On the M4 Max that's DCS 1, 2, 4 or 5 and fabric 0, 0, 0 or 2, split at 160, 500 and 800 permille. A lower state applies at the first sample at least 400 ms after the last one that asked for the current state or a higher one. A busy CPU cluster asks for DCS 1, 1, 3 or 4 and fabric 0, by quarters of 4512 MHz.
States from the device tree: these states are measurements of a SoC's memory, so they are optional properties of the CLPC node (
apple,pmc.yaml):apple,cpu-memory-statesapple,cpu-level-mhzapple,gpu-busy-memory-statesapple,gpu-busy-permillet6041.dtsisets them from the J616c measurements. The driver takes its compatible's table and puts the node's states in its place. The M4 Pro shares the compatible, has none of the properties, and keeps its table. No machine compatible is checked.G17 light effort: a governor that goes to half effort after four quiet windows, with separate entry and exit points, on every G17 (
power::LIGHT_DEFAULT). A SoC can opt out withNone, with the hardware reason at its entry. None does.Effort sweep on a 1080p30 clip: full effort 14.0 W, half effort 10.4 W.
Review history:
compare_exchange.t6041.dtsi, and the rest of it was the T6040 table's, so T6041's floors are unchanged.Tested:
dcs map 1,1,3,4,soc map 0,0,0,0), and light effort engages at idle. The GPU smoke tests pass (vulkan-msaa-mrt,vulkan-msaa-xfer,aurora-tile-visit), with no G17 errors or recoveries. This logic has been my daily setup since 5 Nov.clpc.oandg17/clpc.obuild with LLVM=1 W=1 with no warnings, andaurora.kobuilds with no warnings in the touched files.tools/asahi/clpc-gpu-demand-tests.pybuilds the T6041 table fromt6041.dtsithrough the driver's parsers and runs the busy-share test on it, with all negative controls passing.tools/asahi/run-host-tests.pypasses, 383/383.dt_binding_checkpasses.Not done / please check:
apple,pmc.yamlandclpc.cnext to this. A test merge of its head (25ab204) conflicts only in the binding, where both add properties at the same spot.clpc.cmerges cleanly, and the mergedclpc.obuilds.