-
Notifications
You must be signed in to change notification settings - Fork 193
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
PPD-to-TuneD API translation daemon #579
Conversation
Hi @zacikpa , Thank you for working on this. |
Hi @smallorange, |
a6db80b
to
359053c
Compare
@smallorange This is now in a state where it supports profile switching, but it still has some issues. You can try the following:
So far, I tested this with Once you're done playing with it, don't forget to unmask and enable PPD (if you use it). |
Hi @zacikpa, I've tested it. It works great! I can switch the profile through gnome control center. Thank you :) |
7e30a9a
to
954d3c1
Compare
At this point, the daemon supports all capabilities of PPD except for the "trickle charging" action:
|
2d7e2dc
to
0ebabbc
Compare
In the spec file, I now added the daemon as a subpackage of TuneD called This way, applications that currently use PPD can transition to TuneD seamlessly. An alternative option would be to provide a different object (e.g. |
@zacikpa You may also want this: I can say this is working great in my testing! |
tuned.spec
Outdated
Requires: %{name} = %{version} | ||
# The compatibility daemon conflicts with PPD, | ||
# since it exports the same DBus object. | ||
Conflicts: power-profiles-daemon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine, but we probably want to adjust both power-profiles-daemon
and tuned-ppd
packaging to Provide+Conflicts so that it becomes swappable. Maybe something like:
Provides: ppd-service
Conflicts: ppd-service
And we'll need to get consumers of power-profiles-daemon
to require ppd-service
instead.
@zacikpa, now when the development of the feature is nearly completed, could you please squash the commits? It would be easier to handle/review and possibly backport. |
Thanks for the patch Kyle, now the daemon can be started as a dependency, e.g., by gnome on startup. |
I now squashed the changes into 3 commits for review, I can then squash into a single one when approved. |
I think it's OK now, thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, good job. It mostly LGTM. I have few minor comments inline and one RFE (configuration file).
I also ran simple tests and it seems it works great.
I noticed it returns high-operating-temperature
reason as the degraded perf in case turbo is disabled. In fact turbo can be disabled for various reasons, even manually, i.e. it needn't be due to the high platform temperature. But from the PPD source code, it seems it behaves exactly the same way, i.e. it's probably PPD bug and we should emulate it this (even buggy) way.
tuned/ppd/controller.py
Outdated
LAP_MODE_PATH = "/sys/bus/platform/devices/thinkpad_acpi/dytc_lapmode" | ||
|
||
|
||
class PPDProfile(StrEnum): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use here configuration file with profiles mapping? I think it would be more flexible. The configuration file could be e.g. /etc/tuned/ppd.conf
and could e.g. be the INI with e.g. the following format:
[main]
base=balanced
[hold]
min=power-saver
max=performance
[profiles]
# PPD = TuneD
power-saver = powersave
balanced = balanced
performance = throughput-performance
Then the users could customize it or even add more profiles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I can do that. What exactly do you propose that the hold
section does? Currently, the daemon allows holding only power-saver
and performance
profiles, similar to PPD.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I can do that. What exactly do you propose that the
hold
section does? Currently, the daemon allows holding onlypower-saver
andperformance
profiles, similar to PPD.
I wanted to map min performance and max performance hold profiles to PPD profile names, but because the mapping to TuneD profiles would be already under the [profiles]
section, this is probably redundant abstraction. Let's don't over-engineer it and say power-saver
and performance
profiles mapping have to be always defined in the [profiles]
section.
Otherwise I think it shouldn't be hard change, just one more INI parser and I think it's worth the benefit of greater flexibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I agree, let's keep it simple.
@yarda, I just fixed this using the same method as TuneD does it. Once the profile mapping is moved to a configuration file, I suppose it also makes sense to handle the SIGHUP signal to reload the config. |
Thanks for the heads up. So far I haven't been able to reproduce on my system, but I'd be happy to investigate once you've got the logs. |
SIGHUP would be nice :) but it can be also added later. |
Do not hardcode Polkit namespace into DBusExporter, provide it as a parameter in the constructor.
7a17c71
to
0ddf1eb
Compare
As requested, I changed the implementation to load the profile mapping from a configuration file, which must fulfill three conditions:
|
Let me know if I should add any more checks (i.e., warnings when the config file contains unknown options). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If TuneD is not running it ends with a traceback. I think it could write some legible error message instead:
Traceback (most recent call last):
File "/usr/lib64/python3.12/site-packages/dbus/bus.py", line 173, in activate_name_owner
return self.get_name_owner(bus_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.12/site-packages/dbus/bus.py", line 348, in get_name_owner
return self.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.12/site-packages/dbus/connection.py", line 634, in call_blocking
reply_message = self.send_message_with_reply_and_block(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NameHasNoOwner: The name does not have an owner
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/yarda/tuned-private/./tuned-ppd.py", line 25, in <module>
tuned_object = bus.get_object(consts.DBUS_BUS, consts.DBUS_OBJECT)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.12/site-packages/dbus/bus.py", line 237, in get_object
return self.ProxyObjectClass(self, bus_name, object_path,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.12/site-packages/dbus/proxies.py", line 250, in __init__
self._named_service = conn.activate_name_owner(bus_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.12/site-packages/dbus/bus.py", line 178, in activate_name_owner
self.start_service_by_name(bus_name)
File "/usr/lib64/python3.12/site-packages/dbus/bus.py", line 273, in start_service_by_name
return (True, self.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.12/site-packages/dbus/connection.py", line 634, in call_blocking
reply_message = self.send_message_with_reply_and_block(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name is not activatable
Also I don't see the 'ActiveProfile` property in the introspection. E.g. compare introspections of the tuned-ppd and original ppd:
...
+ ' <property type="s" name="ActiveProfile" access="readwrite">\n'
+ ' </property>\n'
...
tuned/ppd/daemon.conf
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not to name it ppd.conf?
tuned/ppd/tuned-ppd.conf
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be just dbus.conf.
I think the current checks are OK, let's be sane :) |
Good idea, will fix.
Yes, |
OK, thanks for the info. Nobody has complained so far, so let's go without it and we will see. |
LGTM (not counting the unused import found by CodeQL). |
The daemon translates DBus API calls to power-profiles-daemon into TuneD API calls.
This includes the configuration of DBus, systemd, Polkit, and a new TuneD Fedora/RHEL subpackage.
Fixed and squashed. |
Thanks, merged. |
power-profiles-daemon will be replaced by tuned-ppd, see redhat-performance/tuned#579.
power-profiles-daemon will be replaced by tuned-ppd, see redhat-performance/tuned#579.
power-profiles-daemon will be replaced by tuned-ppd, see redhat-performance/tuned#579.
This PR (currently draft) will introduce a PPD-to-TuneD API translation daemon. Feel free to comment on the implementation during the development process.