On Wed, 12 Jun 2024 22:09:10 +0200 Francesco Poli wrote:

[...]
> Is there room for improvement?
> Yes, I think there is.
> For instance, the script /usr/libexec/cpupower could be translated to
> POSIX shell, getting rid of its bashisms.

Here we go, I modified the script by translating it to POSIX shell,
dropping a couple of options that seem to no longer exist in cpupower,
and by making ignore all other frequency options, if FREQ is set.

I correspondingly modified the defaults file.

Please find attached the three updated files.

Tested on one of my systems, where I purged cpufrequtils and installed
linux-cpupower and then I issued the following commands:

  # 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
  # systemctl enable cpupower.service

The systemd service runs at boot and sets everything needed with
cpupower (as configured in /etc/default/cpupower ).

Once again, please accept the "patch" and incorporate the files (or
further enhanced versions of them) into linux-cpupower.

Thanks for your time and dedication!
Bye.


-- 
 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: cpupower.default
Description: Binary data

Attachment: cpupower.service
Description: Binary data

#!/bin/sh
# Copyright © 2012, Sébastien Luttringer
# Copyright © 2024, Francesco Poli
# SPDX-License-Identifier: GPL-2.0-or-later

ESTATUS=0

# parse CPU clock frequency options
if test "$FREQ" != ""
then
    PARS="${FREQ:+ -f $FREQ}"
else
    PARS="${GOVERNOR:+ -g $GOVERNOR}"
    PARS="${PARS}${MIN_FREQ:+ -d $MIN_FREQ}${MAX_FREQ:+ -u $MAX_FREQ}"
fi

# apply CPU clock frequency options
if test "$PARS" != ""
then
    cpupower frequency-set$PARS > /dev/null || ESTATUS=1
fi

# parse CPU policy options
PARS="${PERF_BIAS:+ -b $PERF_BIAS}"

# apply CPU policy options
if test "$PARS" != ""
then
    cpupower set$PARS > /dev/null || ESTATUS=1
fi

exit $ESTATUS

Attachment: pgpuwxVni_2d0.pgp
Description: PGP signature

Reply via email to