From 745f1b62b5d244c0f65bea7c526aea212a475a738d3731ae470496292af51de4 Mon Sep 17 00:00:00 2001 From: Thomas Renninger Date: Tue, 1 Apr 2014 10:55:46 +0000 Subject: [PATCH] Accepting request 228419 from home:trenn:branches:Base:System - Use cpupower {info,set} -b to set Intel perf bias value instead of x86_energy_perf_policy we do not ship. Add use_cpupower_for_intel_perf_bias - Add rctuned service link in /usr/sbin - Mark pm-profiler obsoleted by this package OBS-URL: https://build.opensuse.org/request/show/228419 OBS-URL: https://build.opensuse.org/package/show/Base:System/tuned?expand=0&rev=19 --- tuned.changes | 9 +++++ tuned.spec | 12 +++++-- use_cpupower_for_intel_perf_bias | 62 ++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 use_cpupower_for_intel_perf_bias diff --git a/tuned.changes b/tuned.changes index 3ba6205..87d772f 100644 --- a/tuned.changes +++ b/tuned.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Mon Mar 31 18:44:58 UTC 2014 - trenn@suse.de + +- Use cpupower {info,set} -b to set Intel perf bias value instead of + x86_energy_perf_policy we do not ship. + Add use_cpupower_for_intel_perf_bias +- Add rctuned service link in /usr/sbin +- Mark pm-profiler obsoleted by this package + ------------------------------------------------------------------- Fri Feb 21 15:54:28 UTC 2014 - p.drouand@gmail.com diff --git a/tuned.spec b/tuned.spec index 2cf27f3..95cce13 100644 --- a/tuned.spec +++ b/tuned.spec @@ -1,7 +1,7 @@ # # spec file for package tuned # -# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,6 +16,7 @@ # + Name: tuned Version: 2.3.0 Release: 0 @@ -29,7 +30,8 @@ Source: https://fedorahosted.org/releases/t/u/tuned/tuned-%{version}.tar Patch0: fix-allow-receive_sender-default.patch # PATCH-FIX-OPENSUSE fix-new-systemd-tmpfiles.d-path.patch Fix tmpfiles.d systemd path from /etc/tmpdfiles.d to /usr/lib/tmpfiles.d to be # compatible with new systemd -- -Patch1: fix-new-systemd-tmpfiles.d-path.patch +Patch1: fix-new-systemd-tmpfiles.d-path.patch +Patch2: use_cpupower_for_intel_perf_bias BuildRequires: python BuildRequires: systemd Requires: /usr/bin/cpupower @@ -42,6 +44,7 @@ Requires: python-pyudev Requires: python-gobject %{?systemd_requires} BuildArch: noarch +Obsoletes: pm-profiler %description The tuned package contains a daemon that tunes system settings dynamically. @@ -77,6 +80,7 @@ instead of fewer large ones). %setup -q %patch0 -p1 %patch1 -p1 +%patch2 -p1 %build #The tuned daemon is written in pure Python. Nothing requires to be built. @@ -89,6 +93,7 @@ make install DESTDIR=%{buildroot} rm -rf %{buildroot}/%{_datadir}/doc # Remove unwanted stuffs instead of exclude them in files list rm -rf %{buildroot}%{_libexecdir}/%{name}/{default,desktop-powersave,laptop-ac-powersave,server-powersave,laptop-battery-powersave,enterprise-storage,spindown-disk} +ln -sf service $RPM_BUILD_ROOT/usr/sbin/rctuned %post %service_add_post %{name}.service @@ -116,7 +121,10 @@ sed -i 's|.*/\([^/]\+\)/[^\.]\+\.conf|\1|' /etc/tuned/active_profile %{python_sitelib}/tuned %{_sbindir}/tuned %{_sbindir}/tuned-adm +%{_sbindir}/rctuned %{_libexecdir}/tuned +# active_profile might be empty when built via build service, but typically +# not on a real install -> better do not mark it %ghost %config(noreplace) %{_sysconfdir}/tuned/active_profile %config(noreplace) %{_sysconfdir}/tuned/tuned-main.conf %{_libexecdir}/tmpfiles.d diff --git a/use_cpupower_for_intel_perf_bias b/use_cpupower_for_intel_perf_bias new file mode 100644 index 0000000..f860fdd --- /dev/null +++ b/use_cpupower_for_intel_perf_bias @@ -0,0 +1,62 @@ +Index: tuned-2.3.0/tuned/plugins/plugin_cpu.py +=================================================================== +--- tuned-2.3.0.orig/tuned/plugins/plugin_cpu.py ++++ tuned-2.3.0/tuned/plugins/plugin_cpu.py +@@ -90,7 +90,8 @@ class CPULatencyPlugin(base.Plugin): + # Check for cpupower, use workaround if not available + self._check_cpupower() + # Check for x86_energy_perf_policy, ignore if not available / supported +- self._check_energy_perf_bias() ++ if self._has_cpupower is False: ++ self._check_energy_perf_bias() + # Check for intel_pstate + self._check_intel_pstate() + else: +@@ -206,7 +207,17 @@ class CPULatencyPlugin(base.Plugin): + + @command_set("energy_perf_bias", per_device=True) + def _set_energy_perf_bias(self, energy_perf_bias, device): +- if self._has_energy_perf_bias: ++ if self._has_cpupower is True: ++ bias_str = str(energy_perf_bias) ++ if bias_str == "performance": ++ bias_str = "0" ++ elif bias_str == "powersave": ++ bias_str = "15" ++ elif bias_str == "normal": ++ bias_str = "6" ++ cpu_id = device.lstrip("cpu") ++ tuned.utils.commands.execute(["cpupower", "-c", cpu_id, "set", "-b", bias_str]) ++ elif self._has_energy_perf_bias: + log.info("setting energy_perf_bias '%s' on cpu '%s'" % (energy_perf_bias, device)) + cpu_id = device.lstrip("cpu") + tuned.utils.commands.execute(["x86_energy_perf_policy", "-c", cpu_id, str(energy_perf_bias)]) +@@ -214,14 +225,21 @@ class CPULatencyPlugin(base.Plugin): + @command_get("energy_perf_bias") + def _get_energy_perf_bias(self, device): + energy_perf_bias = None +- if self._has_energy_perf_bias: ++ if self._has_cpupower is True: ++ cpu_id = device.lstrip("cpu") ++ retcode, lines = tuned.utils.commands.execute(["cpupower", "-c", cpu_id, "info", "-b"]) ++ elif self._has_energy_perf_bias: + cpu_id = device.lstrip("cpu") + retcode, lines = tuned.utils.commands.execute(["x86_energy_perf_policy", "-c", cpu_id, "-r"]) +- if retcode == 0: +- for line in lines.splitlines(): +- l = line.split() +- if len(l) == 2: +- energy_perf_bias = l[1] +- break ++ else: ++ return None ++ if retcode == 0: ++ for line in lines.splitlines(): ++ if line.startswith("analyzing CPU"): ++ continue ++ l = line.split() ++ if len(l) == 2: ++ energy_perf_bias = l[1] ++ break + + return energy_perf_bias