ppd: ask tuned recommend for base profile
TuneD has a great mechanism for profile recommendation that can be easily configured without modifying the source code. However, when used together with tuned-ppd, the daemon initially selects the default profile, ignoring potentially better recommendations. These changes add a request for TuneD’s recommended profile when no base_profile has been set previously. Signed-off-by: Aleksandr Denisov <den225900@gmail.com>
This commit is contained in:
parent
66df3aa122
commit
e3bcb62341
1 changed files with 14 additions and 1 deletions
|
|
@ -344,6 +344,18 @@ class Controller(exports.interfaces.ExportableInterface):
|
|||
"""
|
||||
return self._cmd.read_file(PPD_BASE_PROFILE_FILE, no_error=True).strip() or None
|
||||
|
||||
def _get_recommend_profile(self):
|
||||
"""
|
||||
Get TuneD recommended profile.
|
||||
"""
|
||||
tuned_profile = self._tuned_interface.recommend_profile()
|
||||
try:
|
||||
ppd_profile = self._config.tuned_to_ppd.get(tuned_profile, self._on_battery)
|
||||
except KeyError:
|
||||
log.warning("TuneD recommends profile unknown to PPD: %s", tuned_profile)
|
||||
return None
|
||||
return ppd_profile
|
||||
|
||||
def _save_base_profile(self, profile):
|
||||
"""
|
||||
Saves the given PPD profile into the base profile file.
|
||||
|
|
@ -373,7 +385,8 @@ class Controller(exports.interfaces.ExportableInterface):
|
|||
self.check_performance_degraded()
|
||||
self._config = PPDConfig(PPD_CONFIG_FILE, self._tuned_interface)
|
||||
self._setup_battery_signaling()
|
||||
self._base_profile = self._load_base_profile() or self._config.default_profile
|
||||
self._base_profile = self._load_base_profile() or self._get_recommend_profile() or \
|
||||
self._config.default_profile
|
||||
self.switch_profile(self._base_profile)
|
||||
self._save_base_profile(self._base_profile)
|
||||
self._setup_inotify()
|
||||
|
|
|
|||
Loading…
Reference in a new issue