* cpupower: systemd unit to run cpupower at boot
@ 2025-03-22 17:03 Francesco Poli
2025-03-24 12:32 ` John B. Wyatt IV
0 siblings, 1 reply; 5+ messages in thread
From: Francesco Poli @ 2025-03-22 17:03 UTC (permalink / raw)
To: linux-pm list; +Cc: Thomas Renninger, Shuah Khan, John B. Wyatt IV, John Kacur
[-- Attachment #1.1: Type: text/plain, Size: 2589 bytes --]
Dear Linux CPU power monitoring subsystem maintainers,
the 'cpupower' program is a very convenient tool to manage
cpufreq/cpuidle tunables. Thanks for maintaining it!
The typical use case requires to run 'cpupower' at boot, in order to
set the desired values (governor and/or min and max frequencies, and so
forth). It may be run in other situations, but, in my experience,
'cpupower' is usually run at boot and then forgotten.
However, there is no convenient way to automatically run 'cpupower' at
boot with the desired options. Unless the GNU/Linux distribution you
are using provides one, I mean...
I've seen people who put some commands into the deprecated 'rc.local'
file and all other sorts of do-it-yourself strategies to run 'cpupower'
at boot.
It would be nice, if 'cpupower' came with some upstream-maintained
mechanism to run it at boot.
I use Debian GNU/Linux, which provides no such mechanism. So I thought
I could build one.
I took a look at how this is done in the [Arch Linux package] and I
enhanced/modernized the systemd unit (the three files in Arch Linux are
released under "GPL-2.0-or-later" terms).
[Arch Linux package]: <https://gitlab.archlinux.org/archlinux/packaging/packages/linux-tools>
The attached files are tested on Debian GNU/Linux trixie (current
Debian testing, which will be released as stable Debian 13 in some
months, possibly on next summer) and work fine for me and for some
other people.
The 'cpupower.sh' script has been further improved, after analyzing it
with 'shellcheck'.
I hereby release the files under the terms of the GNU GPL license,
version 2 or later.
Could you please ship the three files with the official 'cpupower'
tool?
Thanks for reading so far and for considering my little contribution.
Please let me know, thanks for your time!
N.B.:
As I am sure you know, if a user wants to manually install the
three files, the commands are:
# install -m 644 cpupower.default /etc/default/cpupower
# install -m 755 cpupower.sh /usr/libexec/cpupower
# install -m 644 cpupower.service /usr/lib/systemd/system/
# systemctl daemon-reload
After this manual installation, the '/etc/default/cpupower' file can be
edited as appropriate and then the following command can be issued:
# systemctl enable --now cpupower.service
--
http://www.inventati.org/frx/
There's not a second to spare! To the laboratory!
..................................................... Francesco Poli .
GnuPG key fpr == CA01 1147 9CD2 EFDF FB82 3925 3E1C 27E1 1F69 BFFE
[-- Attachment #1.2: cpupower.default --]
[-- Type: application/octet-stream, Size: 723 bytes --]
# defaults file for linux-cpupower
# --- CPU clock frequency ---
# Define CPU 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.
# If this option is set, all the previous frequency options are ignored
#FREQ=
# --- CPU policy ---
# 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=
[-- Attachment #1.3: cpupower.service --]
[-- Type: application/octet-stream, Size: 236 bytes --]
[Unit]
Description=Apply cpupower configuration
ConditionVirtualization=!container
[Service]
Type=oneshot
EnvironmentFile=-/etc/default/cpupower
ExecStart=/usr/libexec/cpupower
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.4: cpupower.sh --]
[-- Type: text/x-sh; name="cpupower.sh", Size: 677 bytes --]
#!/bin/sh
# Copyright (C) 2012, Sébastien Luttringer
# Copyright (C) 2024, Francesco Poli <invernomuto@paranoici.org>
# SPDX-License-Identifier: GPL-2.0-or-later
ESTATUS=0
# apply CPU clock frequency options
if test -n "$FREQ"
then
cpupower frequency-set -f "$FREQ" > /dev/null || ESTATUS=1
elif test -n "${GOVERNOR}${MIN_FREQ}${MAX_FREQ}"
then
cpupower frequency-set \
${GOVERNOR:+ -g "$GOVERNOR"} \
${MIN_FREQ:+ -d "$MIN_FREQ"} ${MAX_FREQ:+ -u "$MAX_FREQ"} \
> /dev/null || ESTATUS=1
fi
# apply CPU policy options
if test -n "$PERF_BIAS"
then
cpupower set -b "$PERF_BIAS" > /dev/null || ESTATUS=1
fi
exit $ESTATUS
[-- Attachment #2: Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: cpupower: systemd unit to run cpupower at boot
2025-03-22 17:03 cpupower: systemd unit to run cpupower at boot Francesco Poli
@ 2025-03-24 12:32 ` John B. Wyatt IV
2025-03-24 14:42 ` Francesco Poli
2025-03-28 22:22 ` Shuah Khan
0 siblings, 2 replies; 5+ messages in thread
From: John B. Wyatt IV @ 2025-03-24 12:32 UTC (permalink / raw)
To: Francesco Poli; +Cc: linux-pm list, Thomas Renninger, Shuah Khan, John Kacur
On Sat, Mar 22, 2025 at 06:03:57PM +0100, Francesco Poli wrote:
> The attached files are tested on Debian GNU/Linux trixie (current
Would you please submit this in the form of a patch that we can apply
to the tree?
Please read (note the no attachments):
https://www.kernel.org/doc/html/latest/process/submitting-patches.html
We do this to easily be able to comment in the mailing list and make it
easy for others to review.
> I took a look at how this is done in the [Arch Linux package] and I
> enhanced/modernized the systemd unit (the three files in Arch Linux are
> released under "GPL-2.0-or-later" terms).
Is this an issue Shuah?
--
Sincerely,
John Wyatt
Software Engineer, Core Kernel
Red Hat
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: cpupower: systemd unit to run cpupower at boot
2025-03-24 12:32 ` John B. Wyatt IV
@ 2025-03-24 14:42 ` Francesco Poli
2025-03-24 15:55 ` John B. Wyatt IV
2025-03-28 22:22 ` Shuah Khan
1 sibling, 1 reply; 5+ messages in thread
From: Francesco Poli @ 2025-03-24 14:42 UTC (permalink / raw)
To: John B. Wyatt IV; +Cc: linux-pm list, Thomas Renninger, Shuah Khan, John Kacur
[-- Attachment #1: Type: text/plain, Size: 1376 bytes --]
On Mon, 24 Mar 2025 08:32:00 -0400 John B. Wyatt IV wrote:
> On Sat, Mar 22, 2025 at 06:03:57PM +0100, Francesco Poli wrote:
> > The attached files are tested on Debian GNU/Linux trixie (current
>
> Would you please submit this in the form of a patch that we can apply
> to the tree?
Thanks for your reply.
I can try to submit in the form of a patch.
>
> Please read (note the no attachments):
> https://www.kernel.org/doc/html/latest/process/submitting-patches.html
Wow, long document!
I am beginning to read it.
A question: should I base the patch on the mainline tree
<git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git>
or should I clone another, more specific tree?
>
> We do this to easily be able to comment in the mailing list and make it
> easy for others to review.
>
> > I took a look at how this is done in the [Arch Linux package] and I
> > enhanced/modernized the systemd unit (the three files in Arch Linux are
> > released under "GPL-2.0-or-later" terms).
> Is this an issue Shuah?
I hope that's not an issue.
Please let me know as soon as possible, if it is! ;-)
--
http://www.inventati.org/frx/
There's not a second to spare! To the laboratory!
..................................................... Francesco Poli .
GnuPG key fpr == CA01 1147 9CD2 EFDF FB82 3925 3E1C 27E1 1F69 BFFE
[-- Attachment #2: Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: cpupower: systemd unit to run cpupower at boot
2025-03-24 14:42 ` Francesco Poli
@ 2025-03-24 15:55 ` John B. Wyatt IV
0 siblings, 0 replies; 5+ messages in thread
From: John B. Wyatt IV @ 2025-03-24 15:55 UTC (permalink / raw)
To: Francesco Poli; +Cc: linux-pm list, Thomas Renninger, Shuah Khan, John Kacur
On Mon, Mar 24, 2025 at 03:42:47PM +0100, Francesco Poli wrote:
> On Mon, 24 Mar 2025 08:32:00 -0400 John B. Wyatt IV wrote:
>
> > On Sat, Mar 22, 2025 at 06:03:57PM +0100, Francesco Poli wrote:
> > > The attached files are tested on Debian GNU/Linux trixie (current
> >
> > Would you please submit this in the form of a patch that we can apply
> > to the tree?
>
> Thanks for your reply.
You are welcome.
> I can try to submit in the form of a patch.
Looking for to it. I have not read your patch so far; this will be the
first step towards review.
>
> >
> > Please read (note the no attachments):
> > https://www.kernel.org/doc/html/latest/process/submitting-patches.html
>
> Wow, long document!
> I am beginning to read it.
>
> A question: should I base the patch on the mainline tree
> <git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git>
> or should I clone another, more specific tree?
That is a good question. You can use Shuah's cpupower branch for this.
If you have already cloned the Linux kernel you can simply add the
remote into your local clone of the repo:
cd into your local clone of the kernel
git remote add shuah-cpupower https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux.git
git fetch shuah-cpupower && git switch cpupower
Otherwise you can git clone that url.
--
Sincerely,
John Wyatt
Software Engineer, Core Kernel
Red Hat
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: cpupower: systemd unit to run cpupower at boot
2025-03-24 12:32 ` John B. Wyatt IV
2025-03-24 14:42 ` Francesco Poli
@ 2025-03-28 22:22 ` Shuah Khan
1 sibling, 0 replies; 5+ messages in thread
From: Shuah Khan @ 2025-03-28 22:22 UTC (permalink / raw)
To: John B. Wyatt IV, Francesco Poli
Cc: linux-pm list, Thomas Renninger, Shuah Khan, John Kacur,
Shuah Khan
On 3/24/25 06:32, John B. Wyatt IV wrote:
> On Sat, Mar 22, 2025 at 06:03:57PM +0100, Francesco Poli wrote:
>> The attached files are tested on Debian GNU/Linux trixie (current
>
> Would you please submit this in the form of a patch that we can apply
> to the tree?
>
> Please read (note the no attachments):
> https://www.kernel.org/doc/html/latest/process/submitting-patches.html
>
> We do this to easily be able to comment in the mailing list and make it
> easy for others to review.
+1 send patches we can review.
>
>> I took a look at how this is done in the [Arch Linux package] and I
>> enhanced/modernized the systemd unit (the three files in Arch Linux are
>> released under "GPL-2.0-or-later" terms).
> Is this an issue Shuah?
>
git grep "GPL-2.0-or-later" shows several instances. This won't be
a problem.
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-03-28 22:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-22 17:03 cpupower: systemd unit to run cpupower at boot Francesco Poli
2025-03-24 12:32 ` John B. Wyatt IV
2025-03-24 14:42 ` Francesco Poli
2025-03-24 15:55 ` John B. Wyatt IV
2025-03-28 22:22 ` Shuah Khan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox