Repository navigation
Description
Hand-off notes for continuing this on another machine. Device: iPad mini 2 (J85, A7, 1 GB), installed Omarchy A, screen 1536x2048 at scale 2.
Code
- Kernel: branch
a7/gpu-evicton this fork (baseOrchardLinux/linux56c992e). Two WIP commits, not for merging as is (thea8_skip_emptyswitch showed no effect and can go):drivers/gpu/drm/imagination/pvr_apple_s8003.c: GPU buffer eviction hook (t7000_vm_evictable), start at 450 MHz (perf_state_max = 3), and thea8_skip_emptytest switch. Alsolocalversion-a7evict(only keeps test modules apart; drop it).drivers/power/supply/: battery "Discharging at once on unplug" change. Untested.
- Omarchy A: PR The battery reading: on a change, not every second OrchardLinux/omarchy-a#294 (battery polling), branch
battery-poll-intervaloncDurham/omarchy-a. An extraonStateChangedrefresh inStatus.qmlis on branchbattery-poll-interval-wipthere, not in the PR, and the PR text wrongly says unplug is instant.
What we measured
Scroll benchmark: a 700-section page that scrolls itself 240 px every 100 ms in Epiphany (WebKitGTK 2.54.4), sampled for 44 s.
| Setting | Lowest free memory | Peak GPU buffers | Note |
|---|---|---|---|
GSK_RENDERER=cairo (old local tweak) |
102 MB | 391 MB | Epiphany ~50% CPU |
GSK_RENDERER=vulkan (Omarchy's default) |
135 MB | 368 MB | Epiphany ~5% CPU, smoothest |
GSK_RENDERER=ngl |
117 MB | 354 MB | |
WEBKIT_SKIA_MSAA_SAMPLE_COUNT=0 |
100 MB | 387 MB | no gain |
WEBKIT_SKIA_ENABLE_CPU_RENDERING=1 |
78 MB | 418 MB | worse |
WEBKIT_DISABLE_COMPOSITING_MODE=1 moved the cost to plain memory and the web process was OOM-killed.
GPU speed, same test:
| 330 MHz (state 1) | 450 MHz (state 3) | |
|---|---|---|
| Average fragment job | 17.4 ms | 14.5 ms |
| Fragment jobs completed | 711 | 824 |
| Faults | 0 | 0 |
450 MHz ran about an hour of desktop and tests without a GPU fault. That is not a soak; the 330 MHz pin was there because speed changes timed out on J85. A fixed start state does not change speed at run time.
GPU time per program (ftrace gpu_scheduler events, which carry client_id), at 450 MHz:
| Program | Heavy jobs per scrolled frame | Each |
|---|---|---|
| WebKit web process | 1 | ~16 ms |
| Epiphany window | 1 | ~3 ms |
| labwc (compositor) | 1 | 35–45 ms |
The compositor's pass is about 70% of each frame, and it is a fixed cost: ~40 ms on the bare desktop, ~35 ms when only a notification popup changes. The test page only scrolls at 10 Hz, so frame rate from this test says nothing; job times do.
Leads, most promising first
- Empty tiles: switch tested, no effect.
t7000_fill_3d()always sets PROCESS_EMPTY_TILES (put32(w + 0x3c8, 0x0001700f | BIT(17))). Mesa already works outskip_empty_tiles(src/imagination/vulkan/pvr_arch_g5p.c, near "Apple's record +0x640"), and notes Apple's driver processes empty tiles only for a resolve, but for A7/A8 (apple_g4p) it sends 0 in ISP_CTL. Thea8_skip_emptyswitch clears bit 17 in that word. Result on a small redraw (notification popup, 5 compositor jobs each): 26.5 ms off, 26.4 ms on. So either that word is not what the firmware acts on (Mesa's comment points at the record's +0x640 as Apple's place for it), or empty tiles are not the cost. Next: try +0x640, and use the pass log (below) to see what the compositor's render actually contains. - Why a full compositor pass is 2–3x a page pass. Not explained. wlroots' GLES2 renderer never clears, so each pass is a LOAD of the old frame plus blended draws, and every client buffer it samples is a LINEAR dma-buf (the A7 driver offers LINEAR only).
PVR_DEBUG=pass_logwithPVR_PASS_LOG=/tmp/passin labwc's environment prints load/store ops, area and texture layout per render (src/imagination/vulkan/pvr_pass_log.h). - Display. The panel runs on
simpledrm, so direct scanout is off (WLR_SCENE_DISABLE_DIRECT_SCANOUT=1inomarchy-a/desktop/configuration/login-session) and every frame goes through the compositor. A real A7 display driver would let a full-screen app skip that pass. labwc's CPU use was only ~3%, so the copy to the panel is not the cost. - Memory. One web page adds ~190–230 MB of GPU buffers on top of ~174 MB for the idle desktop (one full-screen buffer is 12.6 MB). In two of five runs free memory fell to 17–30 MB and
kswapd0took 24–86% of a core. The eviction hook had evicted ~4,300 buffers and restored ~3,700 in an hour: it churns. Untried:WEBKIT_LAYERS_TILE_SIZE,WEBKIT_DISABLE_DMABUF_ATLAS, Mesaheap_memory_percent. - 450 MHz. Needs an hour-long run, then a proper form instead of
perf_state_max = 3(state 2 is 390 MHz if 3 proves unstable).
Other open items
- Battery commit: the one boot with it dropped to emergency mode after a 196 s apple-asp "I/O stuck" stall (the
/bootdevice and/dev/zram0timed out). Not known whether the change or the stall caused it. Retest after a clean shutdown; pass is unplug showing "Discharging" within ~1 s. - apple-asp stalls 3–7 min during ext4 journal recovery after an unclean stop.
- The tablet's USB link to the host dropped twice while the tablet kept running (once after sleep, once after very low memory). Replugging brings it back; the tablet logs
dwc2 ... USB data held off (charger/role)thenreleased: core reset, reconnect. qs(the shell) showed 90–119% CPU in two snapshots under memory pressure and ~1% otherwise. Not chased.- Before any upstream PR: split the WIP commit, drop
localversion-a7evict, updatedevices/j85/device.tomlin orchard.
How to reproduce
Build (from the orchard checkout; never run the kernel make by hand):
bin/orchard build minimal-boot --device j85 --kernel <kernel tree>
The result is under the orchard cache, components/kernel-tree-j85/<hash>/kernel/ (Image.gz, dtbs/s5l8960x-j85.dtb, lib/modules/...).
Boot: this iPad has no iOS, so it only starts Linux when the host launches it from DFU (power + home ~10 s, release power, hold home ~10 s more). The checkm8 step is flaky on A7; a failed try leaves it in recovery and needs a fresh DFU.
bin/orchard run --ibss --device j85 --kernel $K/Image.gz --dtb $K/dtbs/s5l8960x-j85.dtb \
--initramfs <initrd for the same kernel release> \
--bootargs "root=PARTUUID=<root partition> rw rootwait fbcon=map:9 vt.global_cursor_default=0"
Swap only the GPU driver on a running tablet, no DFU (same kernel release required):
systemctl stop greetd; pkill -u tablet -x labwc
rmmod powervr
insmod /tmp/powervr-new.ko apple_perf_state=3 exp_hw_support=1
rm /run/greetd.run; systemctl start greetd
greetd logs tablet in only once per boot; without removing /run/greetd.run it starts the fallback greeter and the screen looks frozen.
Useful readouts:
/sys/kernel/debug/dri/1/apple_jobs: job timings; any write resets them./sys/kernel/debug/dri/1/gem_evict: resident/evicted bytes and counters./proc/PID/fdinfo/*:drm-client-id,drm-total-memoryper GPU client.- Keep the tablet awake during tests:
sudo systemd-inhibit --what=sleep:idle sleep 1500 &. - Start test programs with the desktop's own environment (copy it from
/proc/$(pgrep -x qs)/environ), or they do not use the GPU.
GPU time per program:
T=/sys/kernel/tracing
echo 16384 > $T/buffer_size_kb; echo > $T/trace
echo 1 > $T/events/gpu_scheduler/enable
sleep 20 # the thing being measured runs here
echo 0 > $T/events/gpu_scheduler/enable; cat $T/trace > /tmp/gpu.trace
for p in /proc/[0-9]*; do for f in $p/fdinfo/*; do
id=$(sed -n 's/^drm-client-id:\t//p' $f 2>/dev/null); [ -n "$id" ] && echo "$id $(cat $p/comm)"
done; done | sort -u > /tmp/clients # while the programs still run
awk 'NR==FNR{c[$1]=$2;next}
/drm_sched_job_run/{match($0,/fence=[0-9:]+/);f=substr($0,RSTART+6,RLENGTH-6);match($0,/client_id:[0-9]+/);id=substr($0,RSTART+10);t=$4;sub(":","",t);st[f]=t;cl[f]=id}
/drm_sched_job_done/{match($0,/fence=[0-9:]+/);f=substr($0,RSTART+6,RLENGTH-6);t=$4;sub(":","",t);if(f in st){d=(t-st[f])*1000;p=c[cl[f]];n[p]++;s[p]+=d;if(d>3){nb[p]++;sb[p]+=d};if(d>m[p])m[p]=d;delete st[f]}}
END{for(p in n)printf "%-16s jobs %5d total %7.0f ms big(>3ms) %4d avg %5.1f ms max %5.1f\n",p,n[p],s[p],nb[p],nb[p]?sb[p]/nb[p]:0,m[p]}' /tmp/clients /tmp/gpu.traceSmall-redraw test: run the trace around notify-send -t 1500 test hello; sleep 4.
Scroll test page:
<script>var d=1;setInterval(function(){scrollBy(0,d*240);if(scrollY+innerHeight>=document.body.scrollHeight-5)d=-1;if(scrollY<=0)d=1},100)</script>followed by 700 sections of text, opened with epiphany --private-instance file:///tmp/t.html.
State left on the tablet
/home/tablet/.config/labwc/autostart: theexport GSK_RENDERER=cairoline is removed (keep it removed)./usr/lib/modules/7.3.0-rc1-a7evict-orchard-apple-4k/: test kernel modules from an earlier build (330 MHz, no skip switch)./usr/share/omarchy/shell/plugins/panels/power/Status.qmlreplaced with the PR 294 version; original at/home/tablet/Status.qml.orig.- modprobe options for
powervr:evict_log=1,exp_hw_support=1.
Scroll benchmark script (wk.sh)
Needs /tmp/sess.env (a copy of /proc/$(pgrep -x qs)/environ) and /tmp/t.html. Usage: sh wk.sh "ENV=1 ...".
#!/bin/sh
# usage: wk.sh "ENV=1 ENV2=2" — open a tall self-scrolling page, sample memory for ~45 s
export XDG_RUNTIME_DIR=/run/user/$(id -u) WAYLAND_DISPLAY=wayland-0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus
[ -f /tmp/t.html ] || awk 'BEGIN{print "<html><body style=\"font:16px sans-serif;max-width:960px;margin:auto\"><script>var d=1;setInterval(function(){scrollBy(0,d*240);if(scrollY+innerHeight>=document.body.scrollHeight-5)d=-1;if(scrollY<=0)d=1},100)</script>"; for(i=0;i<700;i++){printf "<h2>Section %d</h2><p>",i; for(j=0;j<60;j++)printf "The quick brown fox %d jumps over the lazy dog %d. ",i,j; print "</p><div style=\"height:60px;background:linear-gradient(90deg,hsl(" i*7 ",70%,60%),#fff)\"></div>"} print "</body></html>"}' > /tmp/t.html
E=""; for kv in $1; do E="$E --setenv=$kv"; done
systemd-run --user --quiet --collect --unit=wktest --setenv=WAYLAND_DISPLAY --setenv=GSK_RENDERER=cairo --setenv=MESA_LOADER_DRIVER_OVERRIDE=zink $E epiphany --private-instance file:///tmp/t.html
minav=9999; maxgpu=0; maxweb=0
for i in $(seq 1 22); do sleep 2
av=$(awk '/MemAvailable/{print int($2/1024)}' /proc/meminfo)
g=$(sudo -n head -1 /sys/kernel/debug/dri/1/gem_evict | awk '{print int((substr($1,10)+substr($2,9))/1048576)}')
w=0; for p in $(pgrep WebKitWeb); do w=$((w + $(awk '/^RssAnon|^RssShmem|^VmSwap/{s+=$2} END{print int(s/1024)}' /proc/$p/status 2>/dev/null || echo 0))); done
[ $av -lt $minav ] && minav=$av; [ $g -gt $maxgpu ] && maxgpu=$g; [ $w -gt $maxweb ] && maxweb=$w
[ $av -lt 45 ] && { echo "ABORT low memory at $((i*2))s"; break; }
done
cpu=$(top -bn1 -o %CPU | sed -n 8,10p | awk '{printf "%s:%s ", $12, $9}')
echo "[$1] min-avail=${minav}MB peak-gpu-total=${maxgpu}MB peak-webproc(anon+shm+swap)=${maxweb}MB cpu: $cpu"
systemctl --user stop wktest 2>/dev/null; sleep 3; kill -9 $(pgrep WebKit) 2>/dev/null; true
Activity