Make sure cpupower starts after the list of governors is available

On EeePC 1015 PED (in Live mode), cpupower.service seemed to start too
early, before /sys/devices/.../scaling_available_governors was there,
and failed as a result. There were no such problems on faster machines,
but still.

Now cpupower.service will start only when 'scaling_available_governors'
file is available. cpupower.path unit handles this. If CPU frequency
scaling is not supported the file will never appear and cpupower.service
will not start at all, which is natural.
This commit is contained in:
Eugene Shatokhin 2015-03-17 20:53:12 +03:00
parent e8480bfda5
commit e6f2856989
3 changed files with 22 additions and 6 deletions

9
cpupower.path Normal file
View file

@ -0,0 +1,9 @@
[Unit]
Description=cpupower - wait for the list of frequency governors
After=syslog.target
[Path]
PathExists=/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
[Install]
WantedBy=multi-user.target

View file

@ -1,6 +1,7 @@
[Unit] [Unit]
Description=Configure CPU frequency settings Description=Configure CPU frequency settings
After=syslog.target After=syslog.target
ConditionPathExists=/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
[Service] [Service]
Type=oneshot Type=oneshot
@ -10,3 +11,4 @@ ExecStart=/usr/bin/cpupower-start.sh
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
Also=cpupower.path

View file

@ -29,7 +29,7 @@
%define rpmrel %mkrel 0.%{kpatch}.%{mibrel} %define rpmrel %mkrel 0.%{kpatch}.%{mibrel}
%endif %endif
%else %else
%define rpmrel 3 %define rpmrel 4
%endif %endif
# fakerel and fakever never change, they are used to fool # fakerel and fakever never change, they are used to fool
@ -349,10 +349,11 @@ Source2: disable-mrproper-prepare-scripts-configs-in-devel-rpms.patch
Source4: README.kernel-sources Source4: README.kernel-sources
Source5: kernel.rpmlintrc Source5: kernel.rpmlintrc
# Cpupower: the service, the config and the wrapper script # Cpupower: the service, the config, etc.
Source50: cpupower.service Source50: cpupower.service
Source51: cpupower.config Source51: cpupower.config
Source52: cpupower-start.sh Source52: cpupower-start.sh
Source53: cpupower.path
# Our patch tarball, # Our patch tarball,
# see https://abf.rosalinux.ru/soft/kernel-patches-and-configs/ # see https://abf.rosalinux.ru/soft/kernel-patches-and-configs/
@ -1038,14 +1039,16 @@ The cpupower tools.
%post -n cpupower %post -n cpupower
if [ $1 -ge 0 ]; then if [ $1 -ge 0 ]; then
/bin/systemctl enable cpupower >/dev/null 2>&1 || : # Do not enable/disable cpupower.service directly, because it should start
/bin/systemctl start cpupower >/dev/null 2>&1 || : # when cpupower.path triggers it.
/bin/systemctl enable cpupower.path >/dev/null 2>&1 || :
/bin/systemctl start cpupower.path >/dev/null 2>&1 || :
fi fi
%preun -n cpupower %preun -n cpupower
if [ $1 -eq 0 ]; then if [ $1 -eq 0 ]; then
/bin/systemctl --no-reload disable cpupower > /dev/null 2>&1 || : /bin/systemctl --no-reload disable cpupower.path > /dev/null 2>&1 || :
/bin/systemctl stop cpupower > /dev/null 2>&1 || : /bin/systemctl stop cpupower.path > /dev/null 2>&1 || :
fi fi
%package -n cpupower-devel %package -n cpupower-devel
@ -1836,6 +1839,7 @@ mv cpupower.lang ../
chmod 0755 %{buildroot}%{_libdir}/libcpupower.so* chmod 0755 %{buildroot}%{_libdir}/libcpupower.so*
mkdir -p %{buildroot}%{_unitdir} %{buildroot}%{_sysconfdir}/sysconfig mkdir -p %{buildroot}%{_unitdir} %{buildroot}%{_sysconfdir}/sysconfig
install -m644 %{SOURCE50} %{buildroot}%{_unitdir}/cpupower.service install -m644 %{SOURCE50} %{buildroot}%{_unitdir}/cpupower.service
install -m644 %{SOURCE53} %{buildroot}%{_unitdir}/cpupower.path
install -m644 %{SOURCE51} %{buildroot}%{_sysconfdir}/sysconfig/cpupower install -m644 %{SOURCE51} %{buildroot}%{_sysconfdir}/sysconfig/cpupower
install -m755 %{SOURCE52} %{buildroot}%{_bindir}/cpupower-start.sh install -m755 %{SOURCE52} %{buildroot}%{_bindir}/cpupower-start.sh
%endif %endif
@ -1953,6 +1957,7 @@ rm -rf %{buildroot}
%{_libdir}/libcpupower.so.0 %{_libdir}/libcpupower.so.0
%{_libdir}/libcpupower.so.0.0.0 %{_libdir}/libcpupower.so.0.0.0
%{_unitdir}/cpupower.service %{_unitdir}/cpupower.service
%{_unitdir}/cpupower.path
%{_mandir}/man[1-8]/cpupower* %{_mandir}/man[1-8]/cpupower*
%config(noreplace) %{_sysconfdir}/sysconfig/cpupower %config(noreplace) %{_sysconfdir}/sysconfig/cpupower