[arch] fix -> not restoring the CPUs to previous scaling governors after the package is built when optimizations are on

This commit is contained in:
Vinicius Moreira
2021-04-04 10:27:35 -03:00
parent 6685e0b6c3
commit e67e5bc0a9
4 changed files with 65 additions and 27 deletions

View File

@@ -1944,13 +1944,12 @@ class ArchManager(SoftwareManager):
# building main package
context.watcher.change_substatus(self.i18n['arch.building.package'].format(bold(context.name)))
optimize = bool(context.config['optimize']) and cpu_manager.supports_performance_mode() and not cpu_manager.all_in_performance()
optimize = bool(context.config['optimize']) and cpu_manager.supports_performance_mode()
cpus_changed, cpu_prev_governors = False, None
cpu_optimized = False
if optimize:
self.logger.info("Setting cpus to performance mode")
cpu_manager.set_mode('performance', context.root_password)
cpu_optimized = True
cpus_changed, cpu_prev_governors = cpu_manager.set_all_cpus_to('performance', context.root_password, self.logger)
try:
pkgbuilt, output = makepkg.make(pkgdir=context.project_dir,
@@ -1958,9 +1957,9 @@ class ArchManager(SoftwareManager):
handler=context.handler,
custom_pkgbuild=context.custom_pkgbuild_path)
finally:
if cpu_optimized:
self.logger.info("Setting cpus to powersave mode")
cpu_manager.set_mode('powersave', context.root_password)
if cpus_changed and cpu_prev_governors:
self.logger.info("Restoring CPU governors")
cpu_manager.set_cpus(cpu_prev_governors, context.root_password, {'performance'}, self.logger)
self._update_progress(context, 65)