mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-08-27 06:50:37 +00:00

One of the most typical use cases of the 'cpupower' utility works as
follows: run 'cpupower' at boot with the desired command-line options
and then forget about it.
Add a systemd service (disabled by default) that automates this use
case (for environments where the initialization system is 'systemd'),
by running 'cpupower' at boot with the settings read from a default
configuration file.
The systemd service, the associated support script and the
corresponding default configuration file are derived from what is
provided by the Arch Linux package (under "GPL-2.0-or-later" terms),
modernized and enhanced in various ways (the script has also been
checked with 'shellcheck').
Link: dd2e2a311e
Signed-off-by: Francesco Poli (wintermute) <invernomuto@paranoici.org>
Reviewed-by: John B. Wyatt IV <jwyatt@redhat.com>
Reviewed-by: John B. Wyatt IV <sageofredondo@gmail.com>
Tested-by: John B. Wyatt IV <jwyatt@redhat.com>
Tested-by: John B. Wyatt IV <sageofredondo@gmail.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
27 lines
651 B
Bash
27 lines
651 B
Bash
#!/bin/sh
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
# Copyright (C) 2012, Sébastien Luttringer
|
|
# Copyright (C) 2024, Francesco Poli <invernomuto@paranoici.org>
|
|
|
|
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
|