Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Hold power profile through power-profiles-daemon - #573

Draft
caniko wants to merge 2 commits into
FeralInteractive:masterfrom
caniko:hold-power-profile
Draft

caniko wants to merge 2 commits into
FeralInteractive:masterfrom
caniko:hold-power-profile

Conversation

@caniko

@caniko caniko commented Aug 13, 2026 •

Copy link
Copy Markdown

Summary

Use the power-profiles-daemon HoldProfile API while GameMode is active.

The first registered client requests the configured performance profile, and the final client releases it. The system D-Bus connection remains open for the lifetime of the hold, so daemon exit also releases it.

Behavior

  • Prefer org.freedesktop.UPower.PowerProfiles.
  • Fall back to the legacy net.hadess.PowerProfiles API used by older PPD versions and compatible implementations such as tuned-ppd.
  • Preserve direct platform_profile handling when neither API exists, desiredprof cannot be represented by a PPD hold, or defaultprof requests exact restoration semantics.
  • Do not bypass a present policy daemon after authorization or operational errors.
  • Let PPD restore the user-selected base profile when the hold ends.

No new dependency or configuration option is added; the implementation uses the existing sd-bus dependency.

Testing

  • scripts/format-check.sh
  • Meson build with -Dwith-examples=true
  • meson test -C builddir --print-errorlogs
  • Live PPD 0.30 modern endpoint: hold appears with the expected application ID, profile, and reason, then disappears on release
  • Two concurrent clients: one hold remains until the final client exits
  • Forced GameMode daemon exit: D-Bus disconnect removes the hold
  • clang-tidy on the changed daemon sources (only existing project-wide logging warnings)

Full gamemoded -t hardware validation is pending the local removal of competing ASUS profile writers, hence this is submitted as a draft.

Fixes #333
Fixes #462

Current qualification — 8 October 2026

Head 627aac2f605824d6ba71c73a6c2f7cbd197d661c rejects empty HoldProfile replies instead of accepting cookie zero. The regression failed before the fix. Native Meson build with examples and all 18 Meson tests pass, including a new host-independent test of modern/legacy endpoints, unavailable services, denied requests, empty/malformed replies and bus failure. Scoped clang-format checks pass.

The new test uses a fake system bus. Full hardware/PPD qualification, current Codex review and hosted upstream CI remain outstanding.

Current upstream CI — 8 October 2026

Run 37754242744 is completed/action_required at signed head 627aac2f605824d6ba71c73a6c2f7cbd197d661c. Maintainers must approve the fork workflow and obtain passing current-head CI. Native build and all 18 Meson tests pass; hardware/PPD qualification and the existing complete-candidate Codex review remain open.

@caniko

caniko commented Oct 4, 2026

Copy link
Copy Markdown
Author

The retained Build and test run reports failure at the current head, but GitHub now returns zero jobs/check runs, so there is no diagnostic evidence available to identify a code failure. My rerun request returned HTTP 403 (Must have admin rights to Repository). Could a maintainer rerun it? The draft's hardware/PPD acceptance requirement is still outstanding. No local tests or evaluations were run during this maintenance pass.

Treat an empty HoldProfile reply as a failed hold instead of retaining cookie zero. Exercise the real hold lifecycle against a fake bus so modern and legacy endpoints, missing services, denied requests and malformed replies are checked without changing the host power profile.
@caniko

caniko commented Oct 8, 2026

Copy link
Copy Markdown
Author

The signed empty-cookie repair at 627aac2f605824d6ba71c73a6c2f7cbd197d661c passes the native build and all 18 Meson tests. The current upstream Build and test run 37754242744 is waiting for fork-workflow approval (action_required). Maintainers: please approve that current run, then carry the candidate through the existing full-code-review and hardware/PPD gates before native merge.

@Grinv Grinv left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Tested on Fedora 44 KDE, kernel 7.2.13, Ryzen 7 5700X3D (amd-pstate-epp) with tuned-ppd. I built 627aac2 in a container (meson test 2/2 OK) and ran it in place of the system gamemoded, default config, clients via gamemoded -r.

  • From balanced: performance with 1 hold during, balanced and EPP balance_performance after.
  • From power-saver: back to power-saver and EPP power after.
  • Two overlapping clients: one hold, released when the last one exits.

On 1.8.2 this setup leaves EPP at performance after a game (#419). With this PR, tuned re-applies the profile when the hold is released, so EPP comes back.

Comment thread daemon/gamemode-context.c
self->current_profile = prof;
return 0;
}
if (result == GAME_MODE_POWER_PROFILE_FAILED)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If the hold fails with an error not covered by power_profiles_api_unavailable(), this returns -1 and the platprofctl fallback from master never runs. A masked PPD is covered (dbus-broker answers NameHasNoOwner); a timeout or AccessDenied is not.

Comment thread daemon/gamemode-context.c
char default_profile[CONFIG_VALUE_MAX] = { 0 };
config_get_default_profile(self->config, default_profile);
if (default_profile[0] == '\0' &&
(strcmp(prof_str, "performance") == 0 || strcmp(prof_str, "power-saver") == 0)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Without PPD, power-saver is passed to platprofctl, and the write fails because the kernel name is low-power. The example config now suggests power-saver.

Comment thread daemon/gamemode-context.c
char prof_config_str[CONFIG_VALUE_MAX] = { 0 };
switch (prof) {
case GAME_MODE_PROFILE_DEFAULT:
if (self->profile_hold) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A manual profile change drops the hold (tuned-ppd emits ProfileReleased). GameMode doesn't track that, so ReleaseProfile on leave fails with "No active hold for cookie".

Comment thread daemon/meson.build
sources: ['gamemode-dbus.c', 'gamemode-power-profile-tests.c'],
c_args: sd_bus_args + ['-ffunction-sections', '-fdata-sections', '-UNDEBUG'],
link_args: [
'-Wl,--gc-sections',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

With GCC, meson setup -Db_lto=true fails to link this test: undefined game_mode_context_register and others from gamemode-dbus.c. Master links fine with the same option. clang+lld with LTO, coverage builds and CFLAGS=-flto=auto all work.

This branch has not been deployed

No deployments
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.

Try to use power-profiles-daemon API to hold performance profile if available Support for power profiles daemon

2 participants