Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tuned-ppd: Detect battery change events #616

Merged
merged 1 commit into from
May 23, 2024

Conversation

superm1
Copy link
Contributor

@superm1 superm1 commented Apr 2, 2024

power-profiles-daemon has the ability to detect battery change events using upower and to apply different tuned settings based upon whether plugged into power or not.

In PPD this is used specifically to set the energy performance preference differently in the 'balanced' profile, but there is no reason that this concept can't actually apply to all profiles.

Add support for detecting battery change events and apply a profile specified in ppd.conf for battery in the different PPD states.

CC @smallorange

Copy link
Contributor

@zacikpa zacikpa left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, @superm1.

I'm a bit confused about the motivation behind this update. As I understand it, it's currently the users of ppd who choose to switch the ppd profile if the system changes from battery to AC or vice versa. For instance, gnome switches to the power-saving profile (using a hold) when below a certain battery level and the system is unplugged from AC. Can we be sure that this new extension won't cause any conflicts with the existing behavior of ppd/tuned-ppd users?

@superm1
Copy link
Contributor Author

superm1 commented Apr 2, 2024

Sure let me explain the background of it. The PPD daemon does use upower to monitor for battery changes and some "PPD drivers" will react to this and make changes "within" their given profile. GNOME and KDE aren't notified over D-Bus when this happens. It's all internal to PPD.

The reason for bringing this functionality to tuned-ppd is so that when a distro changes to tuned and tuned-ppd the power consumption on battery doesn't go up.

@superm1
Copy link
Contributor Author

superm1 commented Apr 2, 2024

Sorry I realized I didn't answer your question. In terms of what GNOME does at low power (at least with PPD) it's tangential.

I think it's best to think of it as a "subprofile" for a given profile.

tuned/ppd/ppd.conf Outdated Show resolved Hide resolved
tuned/ppd/controller.py Outdated Show resolved Hide resolved
@zacikpa
Copy link
Contributor

zacikpa commented Apr 2, 2024

Sorry I realized I didn't answer your question. In terms of what GNOME does at low power (at least with PPD) it's tangential.

I think it's best to think of it as a "subprofile" for a given profile.

Thanks for the explanation. I'm also wondering whether the dynamic part of #601 shouldn't also be moved here, as part of the "subprofiles".

@superm1
Copy link
Contributor Author

superm1 commented Apr 2, 2024

Sorry I realized I didn't answer your question. In terms of what GNOME does at low power (at least with PPD) it's tangential.
I think it's best to think of it as a "subprofile" for a given profile.

Thanks for the explanation. I'm also wondering whether the dynamic part of #601 shouldn't also be moved here, as part of the "subprofiles".

Yup; that was already on my mind. If this one gets accepted first I'll modify that one. If that one gets accepted first I'll modify this one.

Copy link
Contributor

@zacikpa zacikpa left a comment

Choose a reason for hiding this comment

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

Thanks for the update. Do I understand it correctly that power-profiles-daemon does not change its profile set when on battery? If so, I'd enforce that here as well, as suggested in one of the comments.

tuned/ppd/controller.py Outdated Show resolved Hide resolved
tuned/ppd/controller.py Outdated Show resolved Hide resolved
tuned/ppd/config.py Outdated Show resolved Hide resolved
tuned/ppd/controller.py Outdated Show resolved Hide resolved
tuned/ppd/controller.py Outdated Show resolved Hide resolved
@superm1
Copy link
Contributor Author

superm1 commented Apr 3, 2024

Thanks for the update.

👍

Do I understand it correctly that power-profiles-daemon does not change its profile set when on battery? If so, I'd enforce that here as well, as suggested in one of the comments.

Sounds good. I've made that change and your other suggested ones.

@superm1 superm1 requested a review from zacikpa April 3, 2024 14:03
@superm1
Copy link
Contributor Author

superm1 commented Apr 3, 2024

Yup; that was already on my mind. If this one gets accepted first I'll modify that one. If that one gets accepted first I'll modify this one.

I've made the changes to plugin_video on another branch that has both PRs merged to stop using upower and to instead have the separate profiles for balanced vs balanced-battery. It works well. Here is what that diff looks like: 30dc23a

Copy link
Contributor

@zacikpa zacikpa left a comment

Choose a reason for hiding this comment

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

Thanks, looks good. Just two more nits.

tuned/ppd/controller.py Outdated Show resolved Hide resolved
tuned/ppd/config.py Outdated Show resolved Hide resolved
power-profiles-daemon has the ability to detect battery change events
using upower and to apply different tuned settings based upon whether
plugged into power or not.

In PPD this is used specifically to set the energy performance preference
differently in the 'balanced' profile, but there is no reason that this
concept can't actually apply to all profiles.

Add support for detecting battery change events and apply a profile
specified in ppd.conf for battery in the different PPD states.
@superm1 superm1 requested a review from zacikpa April 4, 2024 12:21
@zacikpa
Copy link
Contributor

zacikpa commented Apr 4, 2024

Perfect, LGTM.

I think the cleanest solution now would be to adjust #601 (keeping just the new video plugin option), and split this PR into two commits, one adding the battery functionality, the other updating ppd.conf with the new battery profiles.

Btw, is panel_power_savings=0 the default value? If yes, I think we don't need to add it to existing profiles at all.

@superm1
Copy link
Contributor Author

superm1 commented Apr 4, 2024

Btw, is panel_power_savings=0 the default value? If yes, I think we don't need to add it to existing profiles at all.

What does default mean? I want to make sure that no matter what value it is set before starting tuned that it gets corrected to 0 if balanced.

@zacikpa
Copy link
Contributor

zacikpa commented Apr 4, 2024

Btw, is panel_power_savings=0 the default value? If yes, I think we don't need to add it to existing profiles at all.

What does default mean? I want to make sure that no matter what value it is set before starting tuned that it gets corrected to 0 if balanced.

Oh, right, that makes sense.

Copy link
Contributor

@zacikpa zacikpa left a comment

Choose a reason for hiding this comment

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

LGTM.

Copy link
Contributor

@yarda yarda left a comment

Choose a reason for hiding this comment

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

LGTM, thanks.

@yarda yarda merged commit d4399b8 into redhat-performance:master May 23, 2024
14 checks passed
@superm1 superm1 deleted the superm1/battery-detection branch May 23, 2024 15:29
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.

None yet

3 participants