Skip to content

omamobile-omarchy 0.1.52, omamobile-shell 0.2.162: the power card's three profiles set the CPU limits - #1045

Open
W4HO-ham wants to merge 9 commits into
derekross:mainfrom
W4HO-ham:power-profile-cpufreq
Open

W4HO-ham wants to merge 9 commits into
derekross:mainfrom
W4HO-ham:power-profile-cpufreq

Conversation

@W4HO-ham

Copy link
Copy Markdown
Contributor

Fixes #1027 the way the issue's option list didn't have: keep Omarchy's power-profiles-daemon and its card, and make the profiles real on a phone.

What changes

  • A drop-in starts power-profiles-daemon with POWER_PROFILE_DAEMON_FAKE_DRIVER=1. The fake driver is part of the daemon (0.30 here): it offers Power-saver, Balanced and Performance and, like the placeholder it replaces, changes nothing itself. It only reads keys when its output is a terminal, which under systemd it never is. powerprofilesctl list names the driver fake.
  • omamobile-power-profile.service follows the daemon's ActiveProfile (gdbus monitor, no polling) and sets each cpufreq policy's limits:
    • Power-saver: ceiling at the highest step at or below 60 % of the cluster's top
    • Balanced: the full range
    • Performance: floor at the highest step at or below 50 % of the top, ceiling at the top
      schedutil still picks the speed in between, and thermal limits still win. Both percentages can be changed in /etc/omamobile/power-profile.conf. When the service stops, or the daemon leaves the bus, every cluster gets its full range back.

Nothing in Omarchy's card or scripts changes, so omarchy-powerprofiles-set, its per-source memory and the card work as on a laptop.

On my palmtop (Pixel 9a, by hand from this branch, switched with omarchy-powerprofiles-set ac <profile>):

profile little middle big
power-saver 324-1098 MHz 357-1418 MHz 700-1557 MHz
balanced 324-1950 MHz 357-2367 MHz 700-2687 MHz
performance 955-1950 MHz 1065-2367 MHz 1164-2687 MHz

A fixed job on a big core (head -c 400M /dev/zero | sha256sum, pinned to CPU 7): 637 ms in Power-saver, 398 ms in Balanced, 375 ms in Performance.

Tests: test/power-profile.sh (from test/all) runs the script against a cpufreq tree shaped like the 9a's three clusters and its watch loop against stub busctl and gdbus. tools/pr-check origin/main passes. test/all has one failure that main has too on my laptop (qmlformat on two patched QML files in the real-package check), unrelated to this.

Draft until it has run a day on my palmtop.

… limits

On a phone power-profiles-daemon falls back to its placeholder, which offers only Power-saver and Balanced and changes nothing (derekross#1027). A drop-in starts it with its fake driver, which offers all three, and omamobile-power-profile follows the active profile: Power-saver caps each cluster near 60 % of its top speed, Balanced gives the full range, Performance raises each floor to about half the top. Both percentages can be set in /etc/omamobile/power-profile.conf.
…daemon

power-profiles-daemon's own unit is ordered after multi-user.target, so a follower wanted by multi-user.target and ordered after the daemon was a cycle: at the palmtop's first boot with it, systemd deleted the follower's start job to break it, and the profiles changed nothing until it was started by hand. The follower is now wanted by the daemon and bound to it.
@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Ready. The palmtop has run this since 2026-11-24 08:34, through two kernels, with the card's three buttons each setting the limits as described and nothing logged as failing to set.

One fix since the draft (a2a328f): the first boot with the package's unit showed multi-user.target: Found ordering cycle: omamobile-power-profile.service/start after power-profiles-daemon.service/start after multi-user.target/start, because power-profiles-daemon's own unit is ordered after multi-user.target. systemd dropped the follower's start, so the buttons changed nothing until I started it by hand. The follower is now wanted by the daemon (power-profiles-daemon.service.wants/) and bound to it. After a reboot of the palmtop with that unit, no cycle was logged, and the follower started with the daemon and applied balanced.

@W4HO-ham
W4HO-ham marked this pull request as ready for review November 25, 2026 05:21

@derekross derekross left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, this is a neat answer to #1027: keeping Omarchy's daemon and card as they are, and making the three profiles mean something on a phone, with the limits taken from each cluster's own steps. The ordering-cycle fix and the day of use on the palmtop are good to have, and the test reads clearly.

One thing has to change before I can take it. Omarchy's omarchy-powerprofiles-set, which its autostart runs at every session start, picks performance on AC whenever the daemon offers it and the owner hasn't chosen anything for that source. Today the placeholder doesn't offer it, so phones land on balanced; with the fake driver, every phone that starts its session on the charger would sit at a 50 % floor on all clusters, while charging, which is when heat matters most. Could the phone start on balanced for both sources unless the owner picks otherwise, for example a once-only step in omamobile-setup-user that writes balanced into Omarchy's per-source state files where none exist, with a test that starts on AC with no state?

After that, two things are mine: whether phones should have CPU profiles now and with which numbers (this is also what the bar's power card in #1024 is waiting for), and a run on my Pixel 7 Pro, since it changes the CPU limits on every phone. I'll also want it to stay out of the way of #946 on the 8 Pro, which caps the same files from its thermal guard; a line in the README about the two writers would help.

…Balanced on the charger too

Omarchy's omarchy-powerprofiles-set, which its autostart runs at every session start, picks Performance on AC whenever the daemon offers it and nothing is saved for that source. With the fake driver it is offered, so a phone that starts its session on the charger would hold every cluster's floor at half its top while charging. omamobile-setup-user now saves Balanced for both sources once, where nothing is saved; a profile the owner picks later is saved over it. The test runs Omarchy's own script on AC with a daemon offering all three: Performance with no state, Balanced after the step. omamobile-omarchy conflicts with an older omamobile-shell so the step comes with the driver, and lib/power-profile says how it shares the cpufreq files with a thermal guard such as the Pixel 8 Pro's (derekross#946).
@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Done in 35fe9f1. omamobile-setup-user saves balanced for both sources once, where nothing is saved, in the same place Omarchy reads it (OMARCHY_POWERPROFILES_STATE_DIR, else ~/.local/state/omarchy/powerprofiles/). A profile picked later in the power card is saved over it and stays. The unit runs before the compositor, so the state is there before Omarchy's autostart reads it.

The new case in test/setup-user.sh runs Omarchy's own omarchy-powerprofiles-set autodetect from the cached package, on AC, with a daemon offering all three. With no state it sets performance, and after the step it sets balanced. With the step taken out, the case fails. It also checks that an owner's saved performance for AC is kept.

That puts a step in omamobile-shell (0.2.154 here), so omamobile-omarchy now conflicts with an older shell, after the precedent of device-cheetah 0.1.60. Both numbers are yours at merge. A phone that updates in the middle of a session runs the step at its next login. Until then, plugging in could still pick Performance.

For #946 I put the two writers in lib/power-profile's header; the package has no README. On the 8 Pro the guard writes its own cap at every tick whenever scaling_max_freq differs from it. There, Power-saver's ceiling lasts only until the guard's next tick, and a switch to Balanced can lift the guard's cap for up to one tick. Performance's floor never goes above the guard's cap, because the kernel keeps the minimum at or under the maximum. If you'd rather the follower kept off a device with a thermal guard altogether, a device-package flag that the follower checks would do it. Tell me which you prefer.

@Somnius

Somnius commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Thanks @W4HO-ham, also for putting the two writers in the header. Yes please, a device-package flag that keeps the follower off devices with a thermal cap like the 8 Pro's guard in #946 would be great. The guard starts capping the CPU clocks at 58 C and holds them at the lowest step by 60 C, and lifting that cap even for one tick on a hot phone is what I want to avoid.

…he power-profile follower off

Somnius on derekross#1045: the Pixel 8 Pro's guard (derekross#946) caps the CPU from 58 C and holds the lowest step by 60 C, and a profile change lifting that cap for even one tick on a hot phone is what it must not do. A device package that ships /usr/share/omamobile/power-profile-off now keeps the follower out: the unit has a ConditionPathExists on it, and lib/power-profile writes nothing there, restore included.
@W4HO-ham

W4HO-ham commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

@Somnius Done in 0496090. A device package that ships /usr/share/omamobile/power-profile-off keeps the follower out:

  • The unit has ConditionPathExists=!/usr/share/omamobile/power-profile-off, so it doesn't start there.
  • If it's started anyway, lib/power-profile's watch, apply and restore write nothing and exit 0. restore is included, because giving the full range back would lift your guard's cap too.

test/power-profile.sh has a case that puts a cap in place, runs apply power-saver, apply balanced and restore with the flag present, and checks the cap is unchanged. With restore left out of the check, the case fails. test/all checks the unit's condition.

For #946, the device-husky side is one empty file, /usr/share/omamobile/power-profile-off, installed by its PKGBUILD. With the file in place, the 8 Pro's power card still offers three profiles, and none of them changes anything there, as today. Without it, the follower runs on the 8 Pro as on any other phone.

Somnius added a commit to Somnius/omarchy-mobile that referenced this pull request Nov 25, 2026
…s#1045 follower stays off

The guard owns the CPU caps on husky when it is on; the generic follower
must not write or restore them. One empty flag file, installed always, and
a test that install stages it. Version 0.1.22, since main has 0.1.21.

Signed-off-by: Lef <me@lefteros.com>
@Somnius

Somnius commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@W4HO-ham thanks, that works for us. The husky side is in #946 now (0eda614): the package installs the empty /usr/share/omamobile/power-profile-off, and test/all checks it gets staged. Since main already has 0.1.21, #946 is 0.1.22 now (merged main in, no force-push).

@derekross

Copy link
Copy Markdown
Owner

Decision: yes to CPU power profiles on phones, but the phone must never move to performance by itself. Please offer balanced and power-saver, with performance available only when the owner picks it, and make sure Omarchy's omarchy-powerprofiles-set at session start can't select it on the charger (the 50 % CPU floor costs heat and battery for nothing). Please also square it with #946's scaling_max_freq cap on husky. Then a 7 Pro run.

…saved at every login, not once

Derek's decision on derekross#1045: the phone must never move to Performance by itself. Saving Balanced only once left a gap: a state file removed later meant Omarchy's default, Performance on AC, at the next session start. The step now runs at every login, before the session starts, and only where nothing is saved, so an owner's choice is still never overwritten.
@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Thanks. Here's how the branch meets each point, with one change in e4e803b:

  • Never Performance by itself: the card still lists all three profiles, but Performance only takes effect when the owner picks it. omamobile-setup-user saves balanced for any source with nothing saved. It runs before the session starts, so Omarchy's autostart omarchy-powerprofiles-set autodetect and its battery service's switches between AC and battery always find a saved choice, and never fall back to their Performance-on-AC default.
  • The change: this used to be a once-only step. A state file removed later would then have meant Performance on the charger at the next login. Now it runs at every login, still only where nothing is saved, so an owner's choice is never overwritten. The test removes the AC file and checks that the next login brings Balanced back. It also checks, against Omarchy's own omarchy-powerprofiles-set on AC with all three profiles offered, that the result is balanced, and performance without the step.
  • omamobile-device-husky 0.1.21: thermal guard caps the CPU clocks, floor at 60 C #946: with Somnius's 0eda614, device-husky ships /usr/share/omamobile/power-profile-off. The follower then never starts on the 8 Pro and writes nothing there, restore included (0496090).

All three packages' tests and tools/pr-check pass. Over to your 7 Pro run.

@W4HO-ham W4HO-ham changed the title omamobile-omarchy 0.1.52: the power card's three profiles set the CPU limits omamobile-omarchy 0.1.52, omamobile-shell 0.2.162: the power card's three profiles set the CPU limits Nov 25, 2026
@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Merged main (7d15883): omamobile-shell 0.2.162, and omamobile-omarchy's conflicts=('omamobile-shell<0.2.162') and the comment follow. Both packages' tests pass, apart from two omamobile-omarchy cases (qmlformat on two patched QML files, the re-patch tool) that fail the same way on main in my setup.

@W4HO-ham

Copy link
Copy Markdown
Contributor Author

The README line about the two writers is in (ac690bd, in the shell's plugins README beside the Battery saver tile, where the profiles are described): the follower writes each cluster's limits, and a device with its own thermal guard ships /usr/share/omamobile/power-profile-off so only one of them writes. With e4e803b (Balanced saved at every login for a source with nothing saved) and 0496090 (the off switch), that's everything on my side. Whether phones get CPU profiles now, and your 7 Pro run, are yours, as you said.

# Conflicts:
#	packages/omamobile-shell/version

@derekross derekross left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, this now does what I asked for. I ran Omarchy's own omarchy-powerprofiles-set autodetect from the 4.5.0-3 package on AC with all three profiles offered: with nothing saved it picks Performance, after your login step it picks Balanced, which is the point of the decision. Running the step at every login rather than once is the right call, and the off switch for a device with its own thermal guard, restore included, is exactly what #946 needs; thanks to Somnius for confirming it from that side.

What's left is mine: a run on my Pixel 7 Pro, on and off the charger, with each of the card's three profiles and the limits read back, and then the numbers at merge. Several open pull requests claim the same shell and omamobile-omarchy versions, so I'll set both when it lands and keep the conflicts= line and the header comment in step with the shell's number.

Two small things, neither a condition. The step keeps any non-empty state file, and Omarchy falls back to Performance on AC for a value that isn't a profile name, so checking for one of the three names rather than -s would close that. And a phone without the shell profile marker never runs omamobile-setup-user, so a sentence in lib/power-profile's header saying the seed depends on it would help the next person.

One thing I'll decide rather than ask you to change: once an owner picks Performance while charging, Omarchy remembers it for the charger, so the phone goes back to Performance at every later plug-in. I read that as the owner's choice and I'm fine with it for now.

derekross pushed a commit that referenced this pull request Nov 27, 2026
…or at 60 C (#946)

* omamobile-device-husky 0.1.21: thermal guard caps the CPU clocks, floor at 60 C

A loop (every 2 s) reads the big/mid/little/gpu zones and caps each CPU
cluster's scaling_max_freq and the GPU's devfreq max_freq from the
hottest, on temperature only: one level down per tick from 58 C, the
lowest level at 60 C, one level up per tick below 56 C. The DT trips
(80/95/105 C) are never written. The caps and CPU list found at start
are saved in /run and restored on stop. The unit is enabled by a wants
link.

At the floor and still at 60 C, user.slice is squeezed onto fewer CPUs
(0-7, 0-5, 0-3) through systemd AllowedCPUs, since this kernel has no
cpu.max and refuses hotplug, and let out one level per tick below 56 C.
A refused squeeze never holds back a release, and a cap that cannot be
written or read counts as not at the floor, so it blocks the squeeze.

The squeeze only happens while the CPUs are busy, measured per CPU from
/proc/stat over the CPUs user.slice may use now (iowait as idle): in at
>= 50 %, let out at once below 35 %, and going a level deeper always
needs >= 50 %. It stops at 0-5 unless those CPUs are >= 90 % busy, back
to 0-5 below 75 %. A tick with no busy reading holds the squeeze only
while >= 56 C, and if no zone reads at all the caps hold and the squeeze
is let out.

The busy check came from the phone: on the charger the SoC sat at
61-62 C at the floor with load ~0.5, and squeezing to 0-3 put the UI on
4 little cores and froze it without cooling anything.

* omamobile-device-husky: an idle phone at 56-57 C climbs back to the max

On the phone the guard started over the old stopgap's caps at 56 C, load
0.4, and the caps went to the minimum and stayed there. A 58 C reading
steps every cap down, and 56-57 C only held, so the odd 58 C tick on an
idle phone ratcheted it to the floor with no way back up.

In the 56-57 C band the caps now step up while the CPUs are idle (below
squeeze_release_busy), step_down never reaches the lowest level (only
floor does), and every cap starts from the hardware max instead of the
cap found at start (stop still puts that one back). A test replays the
phone: its OPP lists, the stopgap's caps, 300 ticks at 56-57 C with a
58 C reading every 20 ticks; it ends at the max.

* omamobile-device-husky: README says what the 56-57 C band does now

The README still said 56-57 C only holds, which was the rule before the
ratchet fix.

* omamobile-device-husky: test a missing user.slice cpuset.cpus

With user.slice/cpuset.cpus missing the caps still work and the squeeze
stays off.

* omamobile-device-husky: thermal guard opt-in, no squeeze, numbers in NOTES

The package no longer enables the guard: an owner turns it on with
systemctl enable --now. The user.slice squeeze is gone, so a hot phone
keeps its CPUs for the screen and call audio. The hold band's idle climb
keeps its 35 % threshold as idle_busy.

The test now holds 58-59 C for more ticks than there are levels, so
stepping down to the lowest level below 60 C fails it.

device/husky/NOTES.md has the measurements behind the defaults: idle,
on the charger, the trips experiment, the floor under load, 120 vs 60 Hz,
C2, Google's trips, and what is not measured yet.

* omamobile-device-husky: NOTES, say what the thermal sources show

* omamobile-device-husky: SPDX line in thermal.conf, the charger in the README

thermal.conf gets the SPDX line the package's other files have. The
README row says that on the charger the SoC sits above the 60 C floor,
so the guard holds the lowest clocks while plugged in. NOTES no longer
names a log that isn't in the repository.

Signed-off-by: Lef <me@lefteros.com>

* omamobile-device-husky: the charger sentence says it is one phone

Signed-off-by: Lef <me@lefteros.com>

* omamobile-device-husky 0.1.22: ship power-profile-off so the #1045 follower stays off

The guard owns the CPU caps on husky when it is on; the generic follower
must not write or restore them. One empty flag file, installed always, and
a test that install stages it. Version 0.1.22, since main has 0.1.21.

Signed-off-by: Lef <me@lefteros.com>

---------

Signed-off-by: Lef <me@lefteros.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Power profiles: Performance is missing on phones, and the other two do nothing yet (power-profiles-daemon's placeholder)

3 participants