diff --git a/README.md b/README.md index b23f50f..c011ffb 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # linux-tools +Tools provided with the Linux Kernel. + diff --git a/cpupower.default b/cpupower.default new file mode 100644 index 0000000..b5c522e --- /dev/null +++ b/cpupower.default @@ -0,0 +1,29 @@ +# Define CPUs governor +# valid governors: ondemand, performance, powersave, conservative, userspace. +#governor='ondemand' + +# Limit frequency range +# Valid suffixes: Hz, kHz (default), MHz, GHz, THz +#min_freq="2.25GHz" +#max_freq="3GHz" + +# Specific frequency to be set. +# Requires userspace governor to be available. +# Do not set governor field if you use this one. +#freq= + +# Utilizes cores in one processor package/socket first before processes are +# scheduled to other processor packages/sockets. +# See man (1) CPUPOWER-SET for additional details. +#mc_scheduler= + +# Utilizes thread siblings of one processor core first before processes are +# scheduled to other cores. See man (1) CPUPOWER-SET for additional details. +#smp_scheduler= + +# Sets a register on supported Intel processore which allows software to convey +# its policy for the relative importance of performance versus energy savings to +# the processor. See man (1) CPUPOWER-SET for additional details. +#perf_bias= + +# vim:set ts=2 sw=2 ft=sh et: diff --git a/cpupower.service b/cpupower.service new file mode 100644 index 0000000..dd432da --- /dev/null +++ b/cpupower.service @@ -0,0 +1,12 @@ +[Unit] +Description=Apply cpupower configuration +ConditionVirtualization=!container + +[Service] +Type=oneshot +EnvironmentFile=/etc/default/cpupower +ExecStart=/usr/lib/systemd/scripts/cpupower +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target diff --git a/cpupower.systemd b/cpupower.systemd new file mode 100644 index 0000000..c7266f0 --- /dev/null +++ b/cpupower.systemd @@ -0,0 +1,32 @@ +#!/bin/bash +# Copyright © 2012, Sébastien Luttringer +# SPDX-License-Identifier: GPL-2.0-or-later + +declare -i fail=0 + +# parse frequency options +declare -a params=() +params+=(${governor:+-g $governor}) +params+=(${min_freq:+-d $min_freq}) +params+=(${max_freq:+-u $max_freq}) +params+=(${freq:+-f $freq}) + +# apply frequency options +if ((${#params[@]} > 0)); then + cpupower frequency-set "${params[@]}" >/dev/null || fail=1 +fi + +# parse cpu options +declare -a params=() +params+=(${mc_scheduler:+-m $mc_scheduler}) +params+=(${smp_scheduler:+-s $smp_scheduler}) +params+=(${perf_bias:+-b $perf_bias}) + +# apply cpu options +if ((${#params[@]} > 0)); then + cpupower set "${params[@]}" >/dev/null || fail=1 +fi + +exit $fail + +# vim:set ts=2 sw=2 ft=sh et: diff --git a/linux-tools.spec b/linux-tools.spec new file mode 100644 index 0000000..d085902 --- /dev/null +++ b/linux-tools.spec @@ -0,0 +1,287 @@ +%define MAJver %(echo %version | cut -d. -f1) +Name: linux-tools +Version: 6.1 +Release: 1mamba +Summary: Tools provided with the Linux Kernel +Group: System/Kernel and Hardware +Vendor: openmamba +Distribution: openmamba +Packager: Silvan Calarco +URL: https://www.kernel.org/ +Source0: https://cdn.kernel.org/pub/linux/kernel/v%{MAJver}.x/linux-%{version}.tar.xz +Source1: cpupower.service +Source2: cpupower.default +Source3: cpupower.systemd +License: GPL +## AUTOBUILDREQ-BEGIN +BuildRequires: glibc-devel +BuildRequires: libcap-devel +BuildRequires: libdw-devel +BuildRequires: libelf-devel +BuildRequires: liblzma-devel +BuildRequires: libncurses-devel +BuildRequires: libnuma-devel +BuildRequires: libopenssl-devel +BuildRequires: libpci-devel +BuildRequires: libpython27-devel +BuildRequires: libpython310-devel +BuildRequires: libslang-devel +BuildRequires: libudev-devel +BuildRequires: libunwind-devel +BuildRequires: libwrap-devel +BuildRequires: libz-devel +BuildRequires: libzstd-devel +## AUTOBUILDREQ-END + +%description +Tools provided with the Linux Kernel. + +%package -n cpupower +Summary: Linux kernel tool to examine and tune power saving related features of your processor +Group: System/Kernel and Hardware +Requires: libcpupower = %{?epoch:%epoch:}%{version}-%{release} + +%description -n cpupower +Linux kernel tool to examine and tune power saving related features of your processor. + +%package -n libcpupower +Summary: Shared library of cpupower tool +Group: System/Libraries + +%description -n libcpupower +Shared library of cpupower tool. + +%package -n libcpupower-devel +Summary: Development header files and static library for libcpupower +Group: Development/Libraries +Requires: libcpupower = %{?epoch:%epoch:}%{version}-%{release} + +%description -n libcpupower-devel +Development header files and static library for libcpupower. + +%package -n usbip +Summary: Linux kernel tool to sharing USB devices over IP network +Group: System/Kernel and Hardware +Requires: libusbip = %{?epoch:%epoch:}%{version}-%{release} + +%description -n usbip +Linux kernel tool to sharing USB devices over IP network. + +%package -n libusbip +Summary: Shared library of usbip tool +Group: System/Libraries + +%description -n libusbip +Shared library of usbip tool. + +%package -n libusbip-devel +Summary: Development header files and static library for libusbip +Group: Development/Libraries +Requires: libusbip = %{?epoch:%epoch:}%{version}-%{release} + +%description -n libusbip-devel +Development header files and static library for libusbip. + +%prep +%setup -q -n linux-%{version} + +%build +cd tools/perf +%make -f Makefile.perf +cd .. + +cd power/cpupower +%make VERSION=%{version}-%{release} +cd ../.. + +%ifarch x86_64 %{ix86} +cd power/x86/x86_energy_perf_policy +%make + +cd ../turbostat +%make + +cd ../../.. +%endif + +cd usb/usbip +# Fix gcc compilation +sed -i 's,-Wall -Werror -Wextra,-fcommon,' configure.ac +./autogen.sh +./configure --prefix=%{_prefix} --sbindir=%{_sbindir} +%make +cd ../.. + +cd thermal/tmon +%make +cd ../.. + +cd cgroup +%make +cd .. + +cd hv +CFLAGS+=' -DKVP_SCRIPTS_PATH=\"/usr/lib/hyperv/kvp_scripts/\"' make +cd .. + +#cd bpf +## doesn't compile when we don't first compile bpftool in its own directory and +## man pages require to be also launch from the subdirectory +#% make -C bpftool all doc +## runqslower, require kernel binary path to build, skip it +#% make -W runqslower +#cd .. + +cd bootconfig +%make +cd ../.. + +%install +[ "%{buildroot}" != / ] && rm -rf "%{buildroot}" + +cd tools/perf +%makeinstall -f Makefile.perf \ + prefix=%{_prefix} \ + lib=lib/perf \ + perfexecdir=lib/perf \ + EXTRA_CFLAGS=' -Wno-error=bad-function-cast -Wno-error=declaration-after-statement -Wno-error=switch-enum' \ + NO_SDT=1 \ + PYTHON=python \ + PYTHON_CONFIG=python-config \ + install-python_ext + +cd .. + +cd power/cpupower +%makeinstall \ + sbindir=%{_bindir} \ + libdir=%{_libdir} \ + mandir=%{_mandir} \ + docdir=%{_docdir}/cpupower \ + install-man + +# install startup scripts +install -D -m0644 %{SOURCE1} %{buildroot}%{_unitdir}/cpupower.service +install -D -m0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/default/cpupower +install -D -m0755 %{SOURCE3} %{buildroot}%{_systemd_util_dir}/scripts/cpupower + +cd ../.. + +%ifarch x86_64 %{ix86} +cd power/x86/x86_energy_perf_policy +install -D -m0755 x86_energy_perf_policy %{buildroot}%{_bindir}/x86_energy_perf_policy +install -D -m0644 x86_energy_perf_policy.8 %{buildroot}%{_mandir}/man8/x86_energy_perf_policy.8 + +cd ../turbostat +%makeinstall + +cd ../../.. +%endif + +cd usb/usbip +%makeinstall \ + libdir=%{_libdir} \ + +cd ../.. + +cd thermal/tmon +%makeinstall INSTALL_ROOT=%{buildroot} +cd ../.. + + +cd cgroup +install -Dm755 cgroup_event_listener %{buildroot}%{_bindir}/cgroup_event_listener +cd ../.. + +%find_lang cpupower + +# Fix brp-strip +strip %{buildroot}%{_bindir}/trace + +%clean +[ "%{buildroot}" != / ] && rm -rf "%{buildroot}" + +%preun -n cpupower +%systemd_preun cpupower +: + +%postun -n cpupower +%systemd_postun cpupower +: + +%post -n cpupower +%systemd_post cpupower +: + +%files +%defattr (-, root, root) +%{_sysconfdir}/bash_completion.d/perf +%{_bindir}/perf +%ifarch %{ix86} x86_64 +%{_bindir}/perf-read-vdso32 +%{_bindir}/x86_energy_perf_policy +%{_mandir}/man8/x86_energy_perf_policy.8* +%endif +%{_bindir}/trace +%{_includedir}/perf/perf_dlfilter.h +%dir %{_prefix}/lib/perf +%{_prefix}/lib/perf/* +%dir %{python310_sitearch}/perf-*-py%{python310_version}.egg-info +%{python310_sitearch}/perf-*-py%{python310_version}.egg-info/* +%{python310_sitearch}/perf.cpython-*.so +%{_mandir}/man1/perf*.1* +%{_datadir}/perf-core/strace/groups/file +%{_datadir}/perf-core/strace/groups/string +%{_bindir}/cgroup_event_listener +%{_bindir}/tmon +%ifarch %{ix86} x86_64 +%{_bindir}/turbostat +%{_mandir}/man8/turbostat.8* +%endif +%{_datadir}/doc/perf-tip/tips.txt + +%files -n cpupower -f cpupower.lang +%defattr (-, root, root) +%config(noreplace) %{_sysconfdir}/default/cpupower +%{_sysconfdir}/cpufreq-bench.conf +%{_bindir}/cpufreq-bench +%{_bindir}/cpufreq-bench_plot.sh +%{_bindir}/cpupower +%{_unitdir}/cpupower.service +%{_prefix}/lib/systemd/scripts/cpupower +%{_datadir}/bash-completion/completions/cpupower +%{_mandir}/man1/cpupower*.1* +%dir %{_docdir}/cpupower +%{_docdir}/cpupower/* + +%files -n libcpupower +%defattr (-, root, root) +%{_libdir}/libcpupower.so.* + +%files -n libcpupower-devel +%defattr (-, root, root) +%{_includedir}/cpufreq.h +%{_includedir}/cpuidle.h +%{_libdir}/libcpupower.so + +%files -n usbip +%defattr (-, root, root) +%{_sbindir}/usbip +%{_sbindir}/usbipd +%{_mandir}/man8/usbip.8* +%{_mandir}/man8/usbipd.8* + +%files -n libusbip +%defattr (-, root, root) +%{_libdir}/libusbip.so.* + +%files -n libusbip-devel +%defattr (-, root, root) +%dir %{_includedir}/usbip +%{_includedir}/usbip/*.h +%{_libdir}/libusbip.a +%{_libdir}/libusbip.so + +%changelog +* Mon Aug 07 2023 Silvan Calarco 6.1-1mamba +- package created