* [PATCH 1/3] initscripts: Automatically enable CPU power saving features
@ 2025-07-17 17:30 Michael Tremer
2025-07-17 17:30 ` [PATCH 2/3] cpufrequtils: Drop package Michael Tremer
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Michael Tremer @ 2025-07-17 17:30 UTC (permalink / raw)
To: development; +Cc: Michael Tremer
This is a cleaned up implementation of the script that was previously
packaged in the cpufrequtils package.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
config/rootfiles/common/aarch64/initscripts | 2 +
config/rootfiles/common/riscv64/initscripts | 2 +
config/rootfiles/common/x86_64/initscripts | 2 +
lfs/initscripts | 1 +
src/initscripts/system/cpupower | 89 +++++++++++++++++++++
5 files changed, 96 insertions(+)
create mode 100644 src/initscripts/system/cpupower
diff --git a/config/rootfiles/common/aarch64/initscripts b/config/rootfiles/common/aarch64/initscripts
index 1fd1f076f..fa43d4fe1 100644
--- a/config/rootfiles/common/aarch64/initscripts
+++ b/config/rootfiles/common/aarch64/initscripts
@@ -18,6 +18,7 @@ etc/rc.d/init.d/collectd
etc/rc.d/init.d/connectd
etc/rc.d/init.d/conntrackd
etc/rc.d/init.d/console
+etc/rc.d/init.d/cpupower
etc/rc.d/init.d/dhcp
etc/rc.d/init.d/dhcrelay
etc/rc.d/init.d/fcron
@@ -183,6 +184,7 @@ etc/rc.d/rcsysinit.d/S42fsresize
etc/rc.d/rcsysinit.d/S43mounttmpfs
etc/rc.d/rcsysinit.d/S44smt
etc/rc.d/rcsysinit.d/S45udev_retry
+etc/rc.d/rcsysinit.d/S46cpupower
etc/rc.d/rcsysinit.d/S50cleanfs
etc/rc.d/rcsysinit.d/S60setclock
etc/rc.d/rcsysinit.d/S70console
diff --git a/config/rootfiles/common/riscv64/initscripts b/config/rootfiles/common/riscv64/initscripts
index 694207257..a31359134 100644
--- a/config/rootfiles/common/riscv64/initscripts
+++ b/config/rootfiles/common/riscv64/initscripts
@@ -18,6 +18,7 @@ etc/rc.d/init.d/collectd
etc/rc.d/init.d/connectd
etc/rc.d/init.d/conntrackd
etc/rc.d/init.d/console
+etc/rc.d/init.d/cpupower
etc/rc.d/init.d/dhcp
etc/rc.d/init.d/dhcrelay
etc/rc.d/init.d/fcron
@@ -182,6 +183,7 @@ etc/rc.d/rcsysinit.d/S42fsresize
etc/rc.d/rcsysinit.d/S43mounttmpfs
etc/rc.d/rcsysinit.d/S44smt
etc/rc.d/rcsysinit.d/S45udev_retry
+etc/rc.d/rcsysinit.d/S46cpupower
etc/rc.d/rcsysinit.d/S50cleanfs
etc/rc.d/rcsysinit.d/S60setclock
etc/rc.d/rcsysinit.d/S70console
diff --git a/config/rootfiles/common/x86_64/initscripts b/config/rootfiles/common/x86_64/initscripts
index 694207257..a31359134 100644
--- a/config/rootfiles/common/x86_64/initscripts
+++ b/config/rootfiles/common/x86_64/initscripts
@@ -18,6 +18,7 @@ etc/rc.d/init.d/collectd
etc/rc.d/init.d/connectd
etc/rc.d/init.d/conntrackd
etc/rc.d/init.d/console
+etc/rc.d/init.d/cpupower
etc/rc.d/init.d/dhcp
etc/rc.d/init.d/dhcrelay
etc/rc.d/init.d/fcron
@@ -182,6 +183,7 @@ etc/rc.d/rcsysinit.d/S42fsresize
etc/rc.d/rcsysinit.d/S43mounttmpfs
etc/rc.d/rcsysinit.d/S44smt
etc/rc.d/rcsysinit.d/S45udev_retry
+etc/rc.d/rcsysinit.d/S46cpupower
etc/rc.d/rcsysinit.d/S50cleanfs
etc/rc.d/rcsysinit.d/S60setclock
etc/rc.d/rcsysinit.d/S70console
diff --git a/lfs/initscripts b/lfs/initscripts
index 99fe2f1be..49215c0ae 100644
--- a/lfs/initscripts
+++ b/lfs/initscripts
@@ -176,6 +176,7 @@ $(TARGET) :
ln -sf ../init.d/mounttmpfs /etc/rc.d/rcsysinit.d/S43mounttmpfs
ln -sf ../init.d/smt /etc/rc.d/rcsysinit.d/S44smt
ln -sf ../init.d/udev_retry /etc/rc.d/rcsysinit.d/S45udev_retry
+ ln -sf ../init.d/cpupower /etc/rc.d/rcsysinit.d/S46cpupower
ln -sf ../init.d/cleanfs /etc/rc.d/rcsysinit.d/S50cleanfs
ln -sf ../init.d/setclock /etc/rc.d/rcsysinit.d/S60setclock
ln -sf ../init.d/console /etc/rc.d/rcsysinit.d/S70console
diff --git a/src/initscripts/system/cpupower b/src/initscripts/system/cpupower
new file mode 100644
index 000000000..82b62a89b
--- /dev/null
+++ b/src/initscripts/system/cpupower
@@ -0,0 +1,89 @@
+#!/bin/sh
+###############################################################################
+# #
+# IPFire.org - A linux based firewall #
+# Copyright (C) 2025 IPFire Team <info@ipfire.org> #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+# #
+###############################################################################
+
+. /etc/sysconfig/rc
+. ${rc_functions}
+
+# Load the configuration if it exists
+if [ -r "/etc/sysconfig/cpupower" ]; then
+ . /etc/sysconfig/cpupower
+fi
+
+# This function returns which governor to use
+find_governor() {
+ local driver
+
+ # If a governor has been configured, we just use that one
+ if [ -n "${GOVERNOR}" ]; then
+ echo "${GOVERNOR}"
+ return 0
+ fi
+
+ # Determine the driver
+ if [ -r "/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver" ]; then
+ driver="$(</sys/devices/system/cpu/cpu0/cpufreq/scaling_driver)"
+ fi
+
+ # Decide which governor to use based on the driver
+ case "${driver}" in
+ # If the driver could not be detected, we won't use anything
+ "")
+ ;;
+
+ # Intel P-State only supports performace and powersave. The latter
+ # is rather implemented like ondemand in other cases.
+ intel_pstate)
+ echo "powersave"
+ ;;
+
+ # For everything else use schedutil
+ *)
+ echo "schedutil"
+ ;;
+ esac
+
+ return 0
+}
+
+set_governor() {
+ # Find the governor to use
+ local governor="$(find_governor)"
+
+ # If we could not detect a governor we don't have anything to do
+ if [ -z "${governor}" ]; then
+ return 0
+ fi
+
+ # Set the governor
+ cpupower frequency-set --governor "${governor}" >/dev/null
+}
+
+case "${1}" in
+ start)
+ boot_mesg "Enabling CPU Power Saving Features..."
+ set_governor
+ evaluate_retval
+ ;;
+ *)
+ echo "Usage: ${0} {start}"
+ exit 1
+ ;;
+esac
--
2.39.5
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/3] cpufrequtils: Drop package
2025-07-17 17:30 [PATCH 1/3] initscripts: Automatically enable CPU power saving features Michael Tremer
@ 2025-07-17 17:30 ` Michael Tremer
2025-07-17 17:30 ` [PATCH 3/3] cpufrequtils: Drop unused patches Michael Tremer
2025-07-20 14:05 ` [PATCH 1/3] initscripts: Automatically enable CPU power saving features Charles Brown
2 siblings, 0 replies; 7+ messages in thread
From: Michael Tremer @ 2025-07-17 17:30 UTC (permalink / raw)
To: development; +Cc: Michael Tremer
This is now implemented in the core distribution.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
config/rootfiles/packages/cpufrequtils | 2 -
lfs/cpufrequtils | 69 --------------------------
make.sh | 1 -
3 files changed, 72 deletions(-)
delete mode 100644 config/rootfiles/packages/cpufrequtils
delete mode 100644 lfs/cpufrequtils
diff --git a/config/rootfiles/packages/cpufrequtils b/config/rootfiles/packages/cpufrequtils
deleted file mode 100644
index a058f370b..000000000
--- a/config/rootfiles/packages/cpufrequtils
+++ /dev/null
@@ -1,2 +0,0 @@
-etc/rc.d/init.d/cpufreq
-etc/rc.d/rc3.d/S18cpufreq
diff --git a/lfs/cpufrequtils b/lfs/cpufrequtils
deleted file mode 100644
index 0383834b6..000000000
--- a/lfs/cpufrequtils
+++ /dev/null
@@ -1,69 +0,0 @@
-###############################################################################
-# #
-# IPFire.org - A linux based firewall #
-# Copyright (C) 2007-2024 IPFire Team <info@ipfire.org> #
-# #
-# This program is free software: you can redistribute it and/or modify #
-# it under the terms of the GNU General Public License as published by #
-# the Free Software Foundation, either version 3 of the License, or #
-# (at your option) any later version. #
-# #
-# This program is distributed in the hope that it will be useful, #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
-# GNU General Public License for more details. #
-# #
-# You should have received a copy of the GNU General Public License #
-# along with this program. If not, see <http://www.gnu.org/licenses/>. #
-# #
-###############################################################################
-
-###############################################################################
-# Definitions
-###############################################################################
-
-include Config
-
-SUMMARY = compatiblity initscript to set ondemand/powersave gov via cpupower
-
-VER = ipfire
-
-THISAPP = cpufrequtils-$(VER)
-#DL_FILE = $(THISAPP).tar.bz2
-#DL_FROM = $(URL_IPFIRE)
-DIR_APP = $(DIR_SRC)/$(THISAPP)
-TARGET = $(DIR_INFO)/$(THISAPP)
-PROG = cpufrequtils
-PAK_VER = 15
-
-DEPS =
-
-SERVICES =
-
-###############################################################################
-# Top-level Rules
-###############################################################################
-
-
-install : $(TARGET)
-
-check :
-
-download :
-
-b2 :
-
-dist:
- @$(PAK)
-
-###############################################################################
-# Installation Details
-###############################################################################
-
-$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
- @$(PREBUILD)
-
- #install initscripts
- $(call INSTALL_INITSCRIPTS,cpufreq)
-
- @$(POSTBUILD)
diff --git a/make.sh b/make.sh
index dc1feb37a..56fd9be22 100755
--- a/make.sh
+++ b/make.sh
@@ -1903,7 +1903,6 @@ build_system() {
lfsmake2 hostapd
lfsmake2 syslinux
lfsmake2 tftpd
- lfsmake2 cpufrequtils
lfsmake2 apcupsd
lfsmake2 fireperf
lfsmake2 iperf
--
2.39.5
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/3] cpufrequtils: Drop unused patches
2025-07-17 17:30 [PATCH 1/3] initscripts: Automatically enable CPU power saving features Michael Tremer
2025-07-17 17:30 ` [PATCH 2/3] cpufrequtils: Drop package Michael Tremer
@ 2025-07-17 17:30 ` Michael Tremer
2025-07-20 14:05 ` [PATCH 1/3] initscripts: Automatically enable CPU power saving features Charles Brown
2 siblings, 0 replies; 7+ messages in thread
From: Michael Tremer @ 2025-07-17 17:30 UTC (permalink / raw)
To: development; +Cc: Michael Tremer
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 7593 bytes --]
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
.../0001-Only-x86-has-cpuid-instruction.patch | 34 --------------
...equtils-aperf-Fix-MSR-read-on-32-bit.patch | 35 --------------
...requtils-sysfs-increase-MAX_LINE_LEN.patch | 29 ------------
...-fix-compilation-on-x86-32-with-fPIC.patch | 46 -------------------
.../0007-po-add-missing-word-in-DE.patch | 28 -----------
5 files changed, 172 deletions(-)
delete mode 100644 src/patches/cpufrequtils/0001-Only-x86-has-cpuid-instruction.patch
delete mode 100644 src/patches/cpufrequtils/0003-cpufrequtils-aperf-Fix-MSR-read-on-32-bit.patch
delete mode 100644 src/patches/cpufrequtils/0005-cpufrequtils-sysfs-increase-MAX_LINE_LEN.patch
delete mode 100644 src/patches/cpufrequtils/0006-aperf-fix-compilation-on-x86-32-with-fPIC.patch
delete mode 100644 src/patches/cpufrequtils/0007-po-add-missing-word-in-DE.patch
diff --git a/src/patches/cpufrequtils/0001-Only-x86-has-cpuid-instruction.patch b/src/patches/cpufrequtils/0001-Only-x86-has-cpuid-instruction.patch
deleted file mode 100644
index d3bc14d51..000000000
--- a/src/patches/cpufrequtils/0001-Only-x86-has-cpuid-instruction.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-From f1b6bccf08f53295b2f7f448f28bbd37533c14a2 Mon Sep 17 00:00:00 2001
-From: Zhang Le <r0bertz@gentoo.org>
-Date: Sun, 18 Jul 2010 02:05:28 +0800
-Subject: [PATCH 1/8] Only x86 has cpuid instruction
-
-Signed-off-by: Zhang Le <r0bertz@gentoo.org>
-Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
----
- utils/aperf.c | 4 ++++
- 1 file changed, 4 insertions(+)
-
-diff --git a/utils/aperf.c b/utils/aperf.c
-index 627fb17..1c64501 100644
---- a/utils/aperf.c
-+++ b/utils/aperf.c
-@@ -68,11 +68,15 @@ struct avg_perf_cpu_info
-
- static int cpu_has_effective_freq()
- {
-+#if defined(__i386__) || defined(__x86_64__)
- /* largest base level */
- if (cpuid_eax(0) < 6)
- return 0;
-
- return cpuid_ecx(6) & 0x1;
-+#else
-+ return 0;
-+#endif
- }
-
- /*
---
-1.7.10
-
diff --git a/src/patches/cpufrequtils/0003-cpufrequtils-aperf-Fix-MSR-read-on-32-bit.patch b/src/patches/cpufrequtils/0003-cpufrequtils-aperf-Fix-MSR-read-on-32-bit.patch
deleted file mode 100644
index 308e73a5b..000000000
--- a/src/patches/cpufrequtils/0003-cpufrequtils-aperf-Fix-MSR-read-on-32-bit.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-From d4490efed068a552e8b67d52a0726458a224c9a0 Mon Sep 17 00:00:00 2001
-From: Frank Arnold <frank.arnold@amd.com>
-Date: Wed, 8 Dec 2010 17:39:14 +0100
-Subject: [PATCH 3/8] cpufrequtils aperf: Fix MSR read on 32-bit
-
-The cpufreq-aperf command does not work on 32-bit systems. The reason
-for that is a wrong count argument passed to the read() call. Instead
-of the buffer size, the size of the pointer to the buffer is used. On
-64-bit systems this just happened to work, because we need to read an
-8 byte value and a pointer has a size of 8 bytes on 64-bit. On 32-bit
-systems only 4 bytes are read, which then triggers the error path.
-
-Signed-off-by: Frank Arnold <frank.arnold@amd.com>
-Reviewed-by: Thomas Renninger <trenn@suse.de>
-Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
----
- utils/aperf.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/utils/aperf.c b/utils/aperf.c
-index 1c64501..6302f5a 100644
---- a/utils/aperf.c
-+++ b/utils/aperf.c
-@@ -100,7 +100,7 @@ static int read_msr(int cpu, unsigned int idx, unsigned long long *val)
- return -1;
- if (lseek(fd, idx, SEEK_CUR) == -1)
- goto err;
-- if (read(fd, val, sizeof val) != sizeof *val)
-+ if (read(fd, val, sizeof *val) != sizeof *val)
- goto err;
- close(fd);
- return 0;
---
-1.7.10
-
diff --git a/src/patches/cpufrequtils/0005-cpufrequtils-sysfs-increase-MAX_LINE_LEN.patch b/src/patches/cpufrequtils/0005-cpufrequtils-sysfs-increase-MAX_LINE_LEN.patch
deleted file mode 100644
index 94088300f..000000000
--- a/src/patches/cpufrequtils/0005-cpufrequtils-sysfs-increase-MAX_LINE_LEN.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From 9f2efa7bc6969c10562ac2c720d50ff77083e5c2 Mon Sep 17 00:00:00 2001
-From: Roman Vasiyarov <rvasiyarov@gmail.com>
-Date: Mon, 25 Apr 2011 21:34:23 +0400
-Subject: [PATCH 5/8] cpufrequtils sysfs: increase MAX_LINE_LEN
-
-larger sysfs data (>255 bytes) was truncated and thus used improperly
-
-Signed-off-by: Roman Vasiyarov <rvasiyarov@gmail.com>
-Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
----
- lib/sysfs.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/lib/sysfs.c b/lib/sysfs.c
-index 4e0edab..24dd563 100644
---- a/lib/sysfs.c
-+++ b/lib/sysfs.c
-@@ -18,7 +18,7 @@
- #include "cpufreq.h"
-
- #define PATH_TO_CPU "/sys/devices/system/cpu/"
--#define MAX_LINE_LEN 255
-+#define MAX_LINE_LEN 4096
- #define SYSFS_PATH_MAX 255
-
- /* helper function to read file from /sys into given buffer */
---
-1.7.10
-
diff --git a/src/patches/cpufrequtils/0006-aperf-fix-compilation-on-x86-32-with-fPIC.patch b/src/patches/cpufrequtils/0006-aperf-fix-compilation-on-x86-32-with-fPIC.patch
deleted file mode 100644
index ee3adff75..000000000
--- a/src/patches/cpufrequtils/0006-aperf-fix-compilation-on-x86-32-with-fPIC.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-From 9085ce6f615d9d2e0182d3ce029b882835bd0a6b Mon Sep 17 00:00:00 2001
-From: Matt Turner <mattst88@gmail.com>
-Date: Tue, 26 Jul 2011 19:28:31 -0400
-Subject: [PATCH 6/8] aperf: fix compilation on x86-32 with -fPIC
-
-ebx is used to store the GOT pointer when compiled with -fPIC, so it's
-not usable by inline assembly.
-
-https://bugs.gentoo.org/375967
-
-Signed-off-by: Matt Turner <mattst88@gmail.com>
-Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
----
- utils/cpuid.h | 14 +++++++++++++-
- 1 file changed, 13 insertions(+), 1 deletion(-)
-
-diff --git a/utils/cpuid.h b/utils/cpuid.h
-index 2bac69a..53da789 100644
---- a/utils/cpuid.h
-+++ b/utils/cpuid.h
-@@ -5,9 +5,21 @@ static inline void __cpuid(unsigned int *eax, unsigned int *ebx,
- unsigned int *ecx, unsigned int *edx)
- {
- /* ecx is often an input as well as an output. */
-- asm volatile("cpuid"
-+ asm volatile(
-+#if defined(__i386__) && defined(__PIC__)
-+ "push %%ebx\n"
-+ "cpuid\n"
-+ "movl %%ebx, %1\n"
-+ "pop %%ebx\n"
-+#else
-+ "cpuid\n"
-+#endif
- : "=a" (*eax),
-+#if defined(__i386__) && defined(__PIC__)
-+ "=r" (*ebx),
-+#else
- "=b" (*ebx),
-+#endif
- "=c" (*ecx),
- "=d" (*edx)
- : "0" (*eax), "2" (*ecx));
---
-1.7.10
-
diff --git a/src/patches/cpufrequtils/0007-po-add-missing-word-in-DE.patch b/src/patches/cpufrequtils/0007-po-add-missing-word-in-DE.patch
deleted file mode 100644
index d116791b1..000000000
--- a/src/patches/cpufrequtils/0007-po-add-missing-word-in-DE.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 26ce99ab92ae9f1f367a58b7858a96f4e1e6814c Mon Sep 17 00:00:00 2001
-From: Dominik Brodowski <linux@dominikbrodowski.net>
-Date: Fri, 29 Jul 2011 19:40:46 +0200
-Subject: [PATCH 7/8] po: add missing word in DE
-
-Reported-by: Michael Basse
-Reported-by: <tkranz@zedat.fu-berlin.de>
-Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
----
- po/de.po | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/po/de.po b/po/de.po
-index 1da1f2b..ee793f5 100644
---- a/po/de.po
-+++ b/po/de.po
-@@ -304,7 +304,7 @@ msgid ""
- "modified\n"
- msgstr ""
- " -c CPU, --cpu CPU Nummer der CPU, deren Taktfrequenz-Einstellung\n"
--" werden soll\n"
-+" verändert werden soll\n"
-
- #: utils/set.c:39
- #, c-format
---
-1.7.10
-
--
2.39.5
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] initscripts: Automatically enable CPU power saving features
2025-07-17 17:30 [PATCH 1/3] initscripts: Automatically enable CPU power saving features Michael Tremer
2025-07-17 17:30 ` [PATCH 2/3] cpufrequtils: Drop package Michael Tremer
2025-07-17 17:30 ` [PATCH 3/3] cpufrequtils: Drop unused patches Michael Tremer
@ 2025-07-20 14:05 ` Charles Brown
2025-07-21 9:10 ` Michael Tremer
2 siblings, 1 reply; 7+ messages in thread
From: Charles Brown @ 2025-07-20 14:05 UTC (permalink / raw)
To: development
Just curious about find_governor() ... how/where would the variable
"GOVERNOR" be getting configured?
On 7/17/2025 12:30 PM, Michael Tremer wrote:
> This is a cleaned up implementation of the script that was previously
> packaged in the cpufrequtils package.
>
> Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
> ---
> config/rootfiles/common/aarch64/initscripts | 2 +
> config/rootfiles/common/riscv64/initscripts | 2 +
> config/rootfiles/common/x86_64/initscripts | 2 +
> lfs/initscripts | 1 +
> src/initscripts/system/cpupower | 89 +++++++++++++++++++++
> 5 files changed, 96 insertions(+)
> create mode 100644 src/initscripts/system/cpupower
>
> diff --git a/config/rootfiles/common/aarch64/initscripts b/config/rootfiles/common/aarch64/initscripts
> index 1fd1f076f..fa43d4fe1 100644
> --- a/config/rootfiles/common/aarch64/initscripts
> +++ b/config/rootfiles/common/aarch64/initscripts
> @@ -18,6 +18,7 @@ etc/rc.d/init.d/collectd
> etc/rc.d/init.d/connectd
> etc/rc.d/init.d/conntrackd
> etc/rc.d/init.d/console
> +etc/rc.d/init.d/cpupower
> etc/rc.d/init.d/dhcp
> etc/rc.d/init.d/dhcrelay
> etc/rc.d/init.d/fcron
> @@ -183,6 +184,7 @@ etc/rc.d/rcsysinit.d/S42fsresize
> etc/rc.d/rcsysinit.d/S43mounttmpfs
> etc/rc.d/rcsysinit.d/S44smt
> etc/rc.d/rcsysinit.d/S45udev_retry
> +etc/rc.d/rcsysinit.d/S46cpupower
> etc/rc.d/rcsysinit.d/S50cleanfs
> etc/rc.d/rcsysinit.d/S60setclock
> etc/rc.d/rcsysinit.d/S70console
> diff --git a/config/rootfiles/common/riscv64/initscripts b/config/rootfiles/common/riscv64/initscripts
> index 694207257..a31359134 100644
> --- a/config/rootfiles/common/riscv64/initscripts
> +++ b/config/rootfiles/common/riscv64/initscripts
> @@ -18,6 +18,7 @@ etc/rc.d/init.d/collectd
> etc/rc.d/init.d/connectd
> etc/rc.d/init.d/conntrackd
> etc/rc.d/init.d/console
> +etc/rc.d/init.d/cpupower
> etc/rc.d/init.d/dhcp
> etc/rc.d/init.d/dhcrelay
> etc/rc.d/init.d/fcron
> @@ -182,6 +183,7 @@ etc/rc.d/rcsysinit.d/S42fsresize
> etc/rc.d/rcsysinit.d/S43mounttmpfs
> etc/rc.d/rcsysinit.d/S44smt
> etc/rc.d/rcsysinit.d/S45udev_retry
> +etc/rc.d/rcsysinit.d/S46cpupower
> etc/rc.d/rcsysinit.d/S50cleanfs
> etc/rc.d/rcsysinit.d/S60setclock
> etc/rc.d/rcsysinit.d/S70console
> diff --git a/config/rootfiles/common/x86_64/initscripts b/config/rootfiles/common/x86_64/initscripts
> index 694207257..a31359134 100644
> --- a/config/rootfiles/common/x86_64/initscripts
> +++ b/config/rootfiles/common/x86_64/initscripts
> @@ -18,6 +18,7 @@ etc/rc.d/init.d/collectd
> etc/rc.d/init.d/connectd
> etc/rc.d/init.d/conntrackd
> etc/rc.d/init.d/console
> +etc/rc.d/init.d/cpupower
> etc/rc.d/init.d/dhcp
> etc/rc.d/init.d/dhcrelay
> etc/rc.d/init.d/fcron
> @@ -182,6 +183,7 @@ etc/rc.d/rcsysinit.d/S42fsresize
> etc/rc.d/rcsysinit.d/S43mounttmpfs
> etc/rc.d/rcsysinit.d/S44smt
> etc/rc.d/rcsysinit.d/S45udev_retry
> +etc/rc.d/rcsysinit.d/S46cpupower
> etc/rc.d/rcsysinit.d/S50cleanfs
> etc/rc.d/rcsysinit.d/S60setclock
> etc/rc.d/rcsysinit.d/S70console
> diff --git a/lfs/initscripts b/lfs/initscripts
> index 99fe2f1be..49215c0ae 100644
> --- a/lfs/initscripts
> +++ b/lfs/initscripts
> @@ -176,6 +176,7 @@ $(TARGET) :
> ln -sf ../init.d/mounttmpfs /etc/rc.d/rcsysinit.d/S43mounttmpfs
> ln -sf ../init.d/smt /etc/rc.d/rcsysinit.d/S44smt
> ln -sf ../init.d/udev_retry /etc/rc.d/rcsysinit.d/S45udev_retry
> + ln -sf ../init.d/cpupower /etc/rc.d/rcsysinit.d/S46cpupower
> ln -sf ../init.d/cleanfs /etc/rc.d/rcsysinit.d/S50cleanfs
> ln -sf ../init.d/setclock /etc/rc.d/rcsysinit.d/S60setclock
> ln -sf ../init.d/console /etc/rc.d/rcsysinit.d/S70console
> diff --git a/src/initscripts/system/cpupower b/src/initscripts/system/cpupower
> new file mode 100644
> index 000000000..82b62a89b
> --- /dev/null
> +++ b/src/initscripts/system/cpupower
> @@ -0,0 +1,89 @@
> +#!/bin/sh
> +###############################################################################
> +# #
> +# IPFire.org - A linux based firewall #
> +# Copyright (C) 2025 IPFire Team <info@ipfire.org> #
> +# #
> +# This program is free software: you can redistribute it and/or modify #
> +# it under the terms of the GNU General Public License as published by #
> +# the Free Software Foundation, either version 3 of the License, or #
> +# (at your option) any later version. #
> +# #
> +# This program is distributed in the hope that it will be useful, #
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of #
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
> +# GNU General Public License for more details. #
> +# #
> +# You should have received a copy of the GNU General Public License #
> +# along with this program. If not, see <http://www.gnu.org/licenses/>. #
> +# #
> +###############################################################################
> +
> +. /etc/sysconfig/rc
> +. ${rc_functions}
> +
> +# Load the configuration if it exists
> +if [ -r "/etc/sysconfig/cpupower" ]; then
> + . /etc/sysconfig/cpupower
> +fi
> +
> +# This function returns which governor to use
> +find_governor() {
> + local driver
> +
> + # If a governor has been configured, we just use that one
> + if [ -n "${GOVERNOR}" ]; then
> + echo "${GOVERNOR}"
> + return 0
> + fi
> +
> + # Determine the driver
> + if [ -r "/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver" ]; then
> + driver="$(</sys/devices/system/cpu/cpu0/cpufreq/scaling_driver)"
> + fi
> +
> + # Decide which governor to use based on the driver
> + case "${driver}" in
> + # If the driver could not be detected, we won't use anything
> + "")
> + ;;
> +
> + # Intel P-State only supports performace and powersave. The latter
> + # is rather implemented like ondemand in other cases.
> + intel_pstate)
> + echo "powersave"
> + ;;
> +
> + # For everything else use schedutil
> + *)
> + echo "schedutil"
> + ;;
> + esac
> +
> + return 0
> +}
> +
> +set_governor() {
> + # Find the governor to use
> + local governor="$(find_governor)"
> +
> + # If we could not detect a governor we don't have anything to do
> + if [ -z "${governor}" ]; then
> + return 0
> + fi
> +
> + # Set the governor
> + cpupower frequency-set --governor "${governor}" >/dev/null
> +}
> +
> +case "${1}" in
> + start)
> + boot_mesg "Enabling CPU Power Saving Features..."
> + set_governor
> + evaluate_retval
> + ;;
> + *)
> + echo "Usage: ${0} {start}"
> + exit 1
> + ;;
> +esac
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] initscripts: Automatically enable CPU power saving features
2025-07-20 14:05 ` [PATCH 1/3] initscripts: Automatically enable CPU power saving features Charles Brown
@ 2025-07-21 9:10 ` Michael Tremer
2025-07-21 19:17 ` Re[2]: " Jon Murphy
[not found] ` <E24211ED-C10E-4AAD-A8F0-BC61DF59FD29@me.com>
0 siblings, 2 replies; 7+ messages in thread
From: Michael Tremer @ 2025-07-21 9:10 UTC (permalink / raw)
To: Charles Brown; +Cc: development
Hello Charles,
Thanks for your question.
The variable is by default not set. But at the top of the file, we optionally load a configuration file. So if someone wants to hard-code a custom governor (even if it is just for testing), they can set the variable in /etc/sysconfig/cpupower.
-Michael
> On 20 Jul 2025, at 15:05, Charles Brown <cab_77573@yahoo.com> wrote:
>
> Just curious about find_governor() ... how/where would the variable "GOVERNOR" be getting configured?
>
> On 7/17/2025 12:30 PM, Michael Tremer wrote:
>> This is a cleaned up implementation of the script that was previously
>> packaged in the cpufrequtils package.
>>
>> Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
>> ---
>> config/rootfiles/common/aarch64/initscripts | 2 +
>> config/rootfiles/common/riscv64/initscripts | 2 +
>> config/rootfiles/common/x86_64/initscripts | 2 +
>> lfs/initscripts | 1 +
>> src/initscripts/system/cpupower | 89 +++++++++++++++++++++
>> 5 files changed, 96 insertions(+)
>> create mode 100644 src/initscripts/system/cpupower
>>
>> diff --git a/config/rootfiles/common/aarch64/initscripts b/config/rootfiles/common/aarch64/initscripts
>> index 1fd1f076f..fa43d4fe1 100644
>> --- a/config/rootfiles/common/aarch64/initscripts
>> +++ b/config/rootfiles/common/aarch64/initscripts
>> @@ -18,6 +18,7 @@ etc/rc.d/init.d/collectd
>> etc/rc.d/init.d/connectd
>> etc/rc.d/init.d/conntrackd
>> etc/rc.d/init.d/console
>> +etc/rc.d/init.d/cpupower
>> etc/rc.d/init.d/dhcp
>> etc/rc.d/init.d/dhcrelay
>> etc/rc.d/init.d/fcron
>> @@ -183,6 +184,7 @@ etc/rc.d/rcsysinit.d/S42fsresize
>> etc/rc.d/rcsysinit.d/S43mounttmpfs
>> etc/rc.d/rcsysinit.d/S44smt
>> etc/rc.d/rcsysinit.d/S45udev_retry
>> +etc/rc.d/rcsysinit.d/S46cpupower
>> etc/rc.d/rcsysinit.d/S50cleanfs
>> etc/rc.d/rcsysinit.d/S60setclock
>> etc/rc.d/rcsysinit.d/S70console
>> diff --git a/config/rootfiles/common/riscv64/initscripts b/config/rootfiles/common/riscv64/initscripts
>> index 694207257..a31359134 100644
>> --- a/config/rootfiles/common/riscv64/initscripts
>> +++ b/config/rootfiles/common/riscv64/initscripts
>> @@ -18,6 +18,7 @@ etc/rc.d/init.d/collectd
>> etc/rc.d/init.d/connectd
>> etc/rc.d/init.d/conntrackd
>> etc/rc.d/init.d/console
>> +etc/rc.d/init.d/cpupower
>> etc/rc.d/init.d/dhcp
>> etc/rc.d/init.d/dhcrelay
>> etc/rc.d/init.d/fcron
>> @@ -182,6 +183,7 @@ etc/rc.d/rcsysinit.d/S42fsresize
>> etc/rc.d/rcsysinit.d/S43mounttmpfs
>> etc/rc.d/rcsysinit.d/S44smt
>> etc/rc.d/rcsysinit.d/S45udev_retry
>> +etc/rc.d/rcsysinit.d/S46cpupower
>> etc/rc.d/rcsysinit.d/S50cleanfs
>> etc/rc.d/rcsysinit.d/S60setclock
>> etc/rc.d/rcsysinit.d/S70console
>> diff --git a/config/rootfiles/common/x86_64/initscripts b/config/rootfiles/common/x86_64/initscripts
>> index 694207257..a31359134 100644
>> --- a/config/rootfiles/common/x86_64/initscripts
>> +++ b/config/rootfiles/common/x86_64/initscripts
>> @@ -18,6 +18,7 @@ etc/rc.d/init.d/collectd
>> etc/rc.d/init.d/connectd
>> etc/rc.d/init.d/conntrackd
>> etc/rc.d/init.d/console
>> +etc/rc.d/init.d/cpupower
>> etc/rc.d/init.d/dhcp
>> etc/rc.d/init.d/dhcrelay
>> etc/rc.d/init.d/fcron
>> @@ -182,6 +183,7 @@ etc/rc.d/rcsysinit.d/S42fsresize
>> etc/rc.d/rcsysinit.d/S43mounttmpfs
>> etc/rc.d/rcsysinit.d/S44smt
>> etc/rc.d/rcsysinit.d/S45udev_retry
>> +etc/rc.d/rcsysinit.d/S46cpupower
>> etc/rc.d/rcsysinit.d/S50cleanfs
>> etc/rc.d/rcsysinit.d/S60setclock
>> etc/rc.d/rcsysinit.d/S70console
>> diff --git a/lfs/initscripts b/lfs/initscripts
>> index 99fe2f1be..49215c0ae 100644
>> --- a/lfs/initscripts
>> +++ b/lfs/initscripts
>> @@ -176,6 +176,7 @@ $(TARGET) :
>> ln -sf ../init.d/mounttmpfs /etc/rc.d/rcsysinit.d/S43mounttmpfs
>> ln -sf ../init.d/smt /etc/rc.d/rcsysinit.d/S44smt
>> ln -sf ../init.d/udev_retry /etc/rc.d/rcsysinit.d/S45udev_retry
>> + ln -sf ../init.d/cpupower /etc/rc.d/rcsysinit.d/S46cpupower
>> ln -sf ../init.d/cleanfs /etc/rc.d/rcsysinit.d/S50cleanfs
>> ln -sf ../init.d/setclock /etc/rc.d/rcsysinit.d/S60setclock
>> ln -sf ../init.d/console /etc/rc.d/rcsysinit.d/S70console
>> diff --git a/src/initscripts/system/cpupower b/src/initscripts/system/cpupower
>> new file mode 100644
>> index 000000000..82b62a89b
>> --- /dev/null
>> +++ b/src/initscripts/system/cpupower
>> @@ -0,0 +1,89 @@
>> +#!/bin/sh
>> +###############################################################################
>> +# #
>> +# IPFire.org - A linux based firewall #
>> +# Copyright (C) 2025 IPFire Team <info@ipfire.org> #
>> +# #
>> +# This program is free software: you can redistribute it and/or modify #
>> +# it under the terms of the GNU General Public License as published by #
>> +# the Free Software Foundation, either version 3 of the License, or #
>> +# (at your option) any later version. #
>> +# #
>> +# This program is distributed in the hope that it will be useful, #
>> +# but WITHOUT ANY WARRANTY; without even the implied warranty of #
>> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
>> +# GNU General Public License for more details. #
>> +# #
>> +# You should have received a copy of the GNU General Public License #
>> +# along with this program. If not, see <http://www.gnu.org/licenses/>. #
>> +# #
>> +###############################################################################
>> +
>> +. /etc/sysconfig/rc
>> +. ${rc_functions}
>> +
>> +# Load the configuration if it exists
>> +if [ -r "/etc/sysconfig/cpupower" ]; then
>> + . /etc/sysconfig/cpupower
>> +fi
>> +
>> +# This function returns which governor to use
>> +find_governor() {
>> + local driver
>> +
>> + # If a governor has been configured, we just use that one
>> + if [ -n "${GOVERNOR}" ]; then
>> + echo "${GOVERNOR}"
>> + return 0
>> + fi
>> +
>> + # Determine the driver
>> + if [ -r "/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver" ]; then
>> + driver="$(</sys/devices/system/cpu/cpu0/cpufreq/scaling_driver)"
>> + fi
>> +
>> + # Decide which governor to use based on the driver
>> + case "${driver}" in
>> + # If the driver could not be detected, we won't use anything
>> + "")
>> + ;;
>> +
>> + # Intel P-State only supports performace and powersave. The latter
>> + # is rather implemented like ondemand in other cases.
>> + intel_pstate)
>> + echo "powersave"
>> + ;;
>> +
>> + # For everything else use schedutil
>> + *)
>> + echo "schedutil"
>> + ;;
>> + esac
>> +
>> + return 0
>> +}
>> +
>> +set_governor() {
>> + # Find the governor to use
>> + local governor="$(find_governor)"
>> +
>> + # If we could not detect a governor we don't have anything to do
>> + if [ -z "${governor}" ]; then
>> + return 0
>> + fi
>> +
>> + # Set the governor
>> + cpupower frequency-set --governor "${governor}" >/dev/null
>> +}
>> +
>> +case "${1}" in
>> + start)
>> + boot_mesg "Enabling CPU Power Saving Features..."
>> + set_governor
>> + evaluate_retval
>> + ;;
>> + *)
>> + echo "Usage: ${0} {start}"
>> + exit 1
>> + ;;
>> +esac
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re[2]: [PATCH 1/3] initscripts: Automatically enable CPU power saving features
2025-07-21 9:10 ` Michael Tremer
@ 2025-07-21 19:17 ` Jon Murphy
[not found] ` <E24211ED-C10E-4AAD-A8F0-BC61DF59FD29@me.com>
1 sibling, 0 replies; 7+ messages in thread
From: Jon Murphy @ 2025-07-21 19:17 UTC (permalink / raw)
To: Charles Brown; +Cc: IPFire: Development-List, Michael Tremer
I added a wiki page: <https://www.ipfire.org/docs/pkgs/cpupower>
Just curious about find_governor() ... how/where would the variable
"GOVERNOR" be getting configured?
Charles - If/when you make a change, please add your changes to the
above Wiki page as an example.
Jon
------ Original Message ------
From "Michael Tremer" <michael.tremer@ipfire.org>
To "Charles Brown" <cab_77573@yahoo.com>
Cc development@lists.ipfire.org
Date 7/21/2025 4:10:56 AM
Subject Re: [PATCH 1/3] initscripts: Automatically enable CPU power
saving features
>Hello Charles,
>
>Thanks for your question.
>
>The variable is by default not set. But at the top of the file, we optionally load a configuration file. So if someone wants to hard-code a custom governor (even if it is just for testing), they can set the variable in /etc/sysconfig/cpupower.
>
>-Michael
>
>> On 20 Jul 2025, at 15:05, Charles Brown <cab_77573@yahoo.com> wrote:
>>
>> Just curious about find_governor() ... how/where would the variable "GOVERNOR" be getting configured?
>>
>> On 7/17/2025 12:30 PM, Michael Tremer wrote:
>>> This is a cleaned up implementation of the script that was previously
>>> packaged in the cpufrequtils package.
>>>
>>> Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
>>> ---
>>> config/rootfiles/common/aarch64/initscripts | 2 +
>>> config/rootfiles/common/riscv64/initscripts | 2 +
>>> config/rootfiles/common/x86_64/initscripts | 2 +
>>> lfs/initscripts | 1 +
>>> src/initscripts/system/cpupower | 89 +++++++++++++++++++++
>>> 5 files changed, 96 insertions(+)
>>> create mode 100644 src/initscripts/system/cpupower
>>>
>>> diff --git a/config/rootfiles/common/aarch64/initscripts b/config/rootfiles/common/aarch64/initscripts
>>> index 1fd1f076f..fa43d4fe1 100644
>>> --- a/config/rootfiles/common/aarch64/initscripts
>>> +++ b/config/rootfiles/common/aarch64/initscripts
>>> @@ -18,6 +18,7 @@ etc/rc.d/init.d/collectd
>>> etc/rc.d/init.d/connectd
>>> etc/rc.d/init.d/conntrackd
>>> etc/rc.d/init.d/console
>>> +etc/rc.d/init.d/cpupower
>>> etc/rc.d/init.d/dhcp
>>> etc/rc.d/init.d/dhcrelay
>>> etc/rc.d/init.d/fcron
>>> @@ -183,6 +184,7 @@ etc/rc.d/rcsysinit.d/S42fsresize
>>> etc/rc.d/rcsysinit.d/S43mounttmpfs
>>> etc/rc.d/rcsysinit.d/S44smt
>>> etc/rc.d/rcsysinit.d/S45udev_retry
>>> +etc/rc.d/rcsysinit.d/S46cpupower
>>> etc/rc.d/rcsysinit.d/S50cleanfs
>>> etc/rc.d/rcsysinit.d/S60setclock
>>> etc/rc.d/rcsysinit.d/S70console
>>> diff --git a/config/rootfiles/common/riscv64/initscripts b/config/rootfiles/common/riscv64/initscripts
>>> index 694207257..a31359134 100644
>>> --- a/config/rootfiles/common/riscv64/initscripts
>>> +++ b/config/rootfiles/common/riscv64/initscripts
>>> @@ -18,6 +18,7 @@ etc/rc.d/init.d/collectd
>>> etc/rc.d/init.d/connectd
>>> etc/rc.d/init.d/conntrackd
>>> etc/rc.d/init.d/console
>>> +etc/rc.d/init.d/cpupower
>>> etc/rc.d/init.d/dhcp
>>> etc/rc.d/init.d/dhcrelay
>>> etc/rc.d/init.d/fcron
>>> @@ -182,6 +183,7 @@ etc/rc.d/rcsysinit.d/S42fsresize
>>> etc/rc.d/rcsysinit.d/S43mounttmpfs
>>> etc/rc.d/rcsysinit.d/S44smt
>>> etc/rc.d/rcsysinit.d/S45udev_retry
>>> +etc/rc.d/rcsysinit.d/S46cpupower
>>> etc/rc.d/rcsysinit.d/S50cleanfs
>>> etc/rc.d/rcsysinit.d/S60setclock
>>> etc/rc.d/rcsysinit.d/S70console
>>> diff --git a/config/rootfiles/common/x86_64/initscripts b/config/rootfiles/common/x86_64/initscripts
>>> index 694207257..a31359134 100644
>>> --- a/config/rootfiles/common/x86_64/initscripts
>>> +++ b/config/rootfiles/common/x86_64/initscripts
>>> @@ -18,6 +18,7 @@ etc/rc.d/init.d/collectd
>>> etc/rc.d/init.d/connectd
>>> etc/rc.d/init.d/conntrackd
>>> etc/rc.d/init.d/console
>>> +etc/rc.d/init.d/cpupower
>>> etc/rc.d/init.d/dhcp
>>> etc/rc.d/init.d/dhcrelay
>>> etc/rc.d/init.d/fcron
>>> @@ -182,6 +183,7 @@ etc/rc.d/rcsysinit.d/S42fsresize
>>> etc/rc.d/rcsysinit.d/S43mounttmpfs
>>> etc/rc.d/rcsysinit.d/S44smt
>>> etc/rc.d/rcsysinit.d/S45udev_retry
>>> +etc/rc.d/rcsysinit.d/S46cpupower
>>> etc/rc.d/rcsysinit.d/S50cleanfs
>>> etc/rc.d/rcsysinit.d/S60setclock
>>> etc/rc.d/rcsysinit.d/S70console
>>> diff --git a/lfs/initscripts b/lfs/initscripts
>>> index 99fe2f1be..49215c0ae 100644
>>> --- a/lfs/initscripts
>>> +++ b/lfs/initscripts
>>> @@ -176,6 +176,7 @@ $(TARGET) :
>>> ln -sf ../init.d/mounttmpfs /etc/rc.d/rcsysinit.d/S43mounttmpfs
>>> ln -sf ../init.d/smt /etc/rc.d/rcsysinit.d/S44smt
>>> ln -sf ../init.d/udev_retry /etc/rc.d/rcsysinit.d/S45udev_retry
>>> + ln -sf ../init.d/cpupower /etc/rc.d/rcsysinit.d/S46cpupower
>>> ln -sf ../init.d/cleanfs /etc/rc.d/rcsysinit.d/S50cleanfs
>>> ln -sf ../init.d/setclock /etc/rc.d/rcsysinit.d/S60setclock
>>> ln -sf ../init.d/console /etc/rc.d/rcsysinit.d/S70console
>>> diff --git a/src/initscripts/system/cpupower b/src/initscripts/system/cpupower
>>> new file mode 100644
>>> index 000000000..82b62a89b
>>> --- /dev/null
>>> +++ b/src/initscripts/system/cpupower
>>> @@ -0,0 +1,89 @@
>>> +#!/bin/sh
>>> +###############################################################################
>>> +# #
>>> +# IPFire.org - A linux based firewall #
>>> +# Copyright (C) 2025 IPFire Team <info@ipfire.org> #
>>> +# #
>>> +# This program is free software: you can redistribute it and/or modify #
>>> +# it under the terms of the GNU General Public License as published by #
>>> +# the Free Software Foundation, either version 3 of the License, or #
>>> +# (at your option) any later version. #
>>> +# #
>>> +# This program is distributed in the hope that it will be useful, #
>>> +# but WITHOUT ANY WARRANTY; without even the implied warranty of #
>>> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
>>> +# GNU General Public License for more details. #
>>> +# #
>>> +# You should have received a copy of the GNU General Public License #
>>> +# along with this program. If not, see <http://www.gnu.org/licenses/>. #
>>> +# #
>>> +###############################################################################
>>> +
>>> +. /etc/sysconfig/rc
>>> +. ${rc_functions}
>>> +
>>> +# Load the configuration if it exists
>>> +if [ -r "/etc/sysconfig/cpupower" ]; then
>>> + . /etc/sysconfig/cpupower
>>> +fi
>>> +
>>> +# This function returns which governor to use
>>> +find_governor() {
>>> + local driver
>>> +
>>> + # If a governor has been configured, we just use that one
>>> + if [ -n "${GOVERNOR}" ]; then
>>> + echo "${GOVERNOR}"
>>> + return 0
>>> + fi
>>> +
>>> + # Determine the driver
>>> + if [ -r "/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver" ]; then
>>> + driver="$(</sys/devices/system/cpu/cpu0/cpufreq/scaling_driver)"
>>> + fi
>>> +
>>> + # Decide which governor to use based on the driver
>>> + case "${driver}" in
>>> + # If the driver could not be detected, we won't use anything
>>> + "")
>>> + ;;
>>> +
>>> + # Intel P-State only supports performace and powersave. The latter
>>> + # is rather implemented like ondemand in other cases.
>>> + intel_pstate)
>>> + echo "powersave"
>>> + ;;
>>> +
>>> + # For everything else use schedutil
>>> + *)
>>> + echo "schedutil"
>>> + ;;
>>> + esac
>>> +
>>> + return 0
>>> +}
>>> +
>>> +set_governor() {
>>> + # Find the governor to use
>>> + local governor="$(find_governor)"
>>> +
>>> + # If we could not detect a governor we don't have anything to do
>>> + if [ -z "${governor}" ]; then
>>> + return 0
>>> + fi
>>> +
>>> + # Set the governor
>>> + cpupower frequency-set --governor "${governor}" >/dev/null
>>> +}
>>> +
>>> +case "${1}" in
>>> + start)
>>> + boot_mesg "Enabling CPU Power Saving Features..."
>>> + set_governor
>>> + evaluate_retval
>>> + ;;
>>> + *)
>>> + echo "Usage: ${0} {start}"
>>> + exit 1
>>> + ;;
>>> +esac
>>
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] initscripts: Automatically enable CPU power saving features
[not found] ` <E24211ED-C10E-4AAD-A8F0-BC61DF59FD29@me.com>
@ 2025-07-21 20:31 ` Charles Brown
0 siblings, 0 replies; 7+ messages in thread
From: Charles Brown @ 2025-07-21 20:31 UTC (permalink / raw)
To: murphy.jon; +Cc: development, Michael Tremer
Hi Jon, I am perfectly satisfied with Michael's default implementation
in src/initscripts/system/cpupower.
I see no personal need to override that in |/etc/sysconfig/cpupower.|
-cab
On 7/21/2025 2:15 PM, murphy.jon@me.com wrote:
> I added a wiki page: <https://www.ipfire.org/docs/pkgs/cpupower>
>
>>> Just curious about find_governor() ... how/where would the variable
>>> "GOVERNOR" be getting configured?
>
> Charles - If/when you make a change, please add your changes to the
> above Wiki page as an example.
>
>
> Jon
>
>
>> On Jul 21, 2025, at 4:10 AM, Michael Tremer
>> <michael.tremer@ipfire.org> wrote:
>>
>> Hello Charles,
>>
>> Thanks for your question.
>>
>> The variable is by default not set. But at the top of the file, we
>> optionally load a configuration file. So if someone wants to
>> hard-code a custom governor (even if it is just for testing), they
>> can set the variable in /etc/sysconfig/cpupower.
>>
>> -Michael
>>
>>> On 20 Jul 2025, at 15:05, Charles Brown <cab_77573@yahoo.com> wrote:
>>>
>>> Just curious about find_governor() ... how/where would the variable
>>> "GOVERNOR" be getting configured?
>>>
>>> On 7/17/2025 12:30 PM, Michael Tremer wrote:
>>>> This is a cleaned up implementation of the script that was previously
>>>> packaged in the cpufrequtils package.
>>>>
>>>> Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
>>>> ---
>>>> config/rootfiles/common/aarch64/initscripts | 2 +
>>>> config/rootfiles/common/riscv64/initscripts | 2 +
>>>> config/rootfiles/common/x86_64/initscripts | 2 +
>>>> lfs/initscripts | 1 +
>>>> src/initscripts/system/cpupower | 89 +++++++++++++++++++++
>>>> 5 files changed, 96 insertions(+)
>>>> create mode 100644 src/initscripts/system/cpupower
>>>>
>>>> diff --git a/config/rootfiles/common/aarch64/initscripts
>>>> b/config/rootfiles/common/aarch64/initscripts
>>>> index 1fd1f076f..fa43d4fe1 100644
>>>> --- a/config/rootfiles/common/aarch64/initscripts
>>>> +++ b/config/rootfiles/common/aarch64/initscripts
>>>> @@ -18,6 +18,7 @@ etc/rc.d/init.d/collectd
>>>> etc/rc.d/init.d/connectd
>>>> etc/rc.d/init.d/conntrackd
>>>> etc/rc.d/init.d/console
>>>> +etc/rc.d/init.d/cpupower
>>>> etc/rc.d/init.d/dhcp
>>>> etc/rc.d/init.d/dhcrelay
>>>> etc/rc.d/init.d/fcron
>>>> @@ -183,6 +184,7 @@ etc/rc.d/rcsysinit.d/S42fsresize
>>>> etc/rc.d/rcsysinit.d/S43mounttmpfs
>>>> etc/rc.d/rcsysinit.d/S44smt
>>>> etc/rc.d/rcsysinit.d/S45udev_retry
>>>> +etc/rc.d/rcsysinit.d/S46cpupower
>>>> etc/rc.d/rcsysinit.d/S50cleanfs
>>>> etc/rc.d/rcsysinit.d/S60setclock
>>>> etc/rc.d/rcsysinit.d/S70console
>>>> diff --git a/config/rootfiles/common/riscv64/initscripts
>>>> b/config/rootfiles/common/riscv64/initscripts
>>>> index 694207257..a31359134 100644
>>>> --- a/config/rootfiles/common/riscv64/initscripts
>>>> +++ b/config/rootfiles/common/riscv64/initscripts
>>>> @@ -18,6 +18,7 @@ etc/rc.d/init.d/collectd
>>>> etc/rc.d/init.d/connectd
>>>> etc/rc.d/init.d/conntrackd
>>>> etc/rc.d/init.d/console
>>>> +etc/rc.d/init.d/cpupower
>>>> etc/rc.d/init.d/dhcp
>>>> etc/rc.d/init.d/dhcrelay
>>>> etc/rc.d/init.d/fcron
>>>> @@ -182,6 +183,7 @@ etc/rc.d/rcsysinit.d/S42fsresize
>>>> etc/rc.d/rcsysinit.d/S43mounttmpfs
>>>> etc/rc.d/rcsysinit.d/S44smt
>>>> etc/rc.d/rcsysinit.d/S45udev_retry
>>>> +etc/rc.d/rcsysinit.d/S46cpupower
>>>> etc/rc.d/rcsysinit.d/S50cleanfs
>>>> etc/rc.d/rcsysinit.d/S60setclock
>>>> etc/rc.d/rcsysinit.d/S70console
>>>> diff --git a/config/rootfiles/common/x86_64/initscripts
>>>> b/config/rootfiles/common/x86_64/initscripts
>>>> index 694207257..a31359134 100644
>>>> --- a/config/rootfiles/common/x86_64/initscripts
>>>> +++ b/config/rootfiles/common/x86_64/initscripts
>>>> @@ -18,6 +18,7 @@ etc/rc.d/init.d/collectd
>>>> etc/rc.d/init.d/connectd
>>>> etc/rc.d/init.d/conntrackd
>>>> etc/rc.d/init.d/console
>>>> +etc/rc.d/init.d/cpupower
>>>> etc/rc.d/init.d/dhcp
>>>> etc/rc.d/init.d/dhcrelay
>>>> etc/rc.d/init.d/fcron
>>>> @@ -182,6 +183,7 @@ etc/rc.d/rcsysinit.d/S42fsresize
>>>> etc/rc.d/rcsysinit.d/S43mounttmpfs
>>>> etc/rc.d/rcsysinit.d/S44smt
>>>> etc/rc.d/rcsysinit.d/S45udev_retry
>>>> +etc/rc.d/rcsysinit.d/S46cpupower
>>>> etc/rc.d/rcsysinit.d/S50cleanfs
>>>> etc/rc.d/rcsysinit.d/S60setclock
>>>> etc/rc.d/rcsysinit.d/S70console
>>>> diff --git a/lfs/initscripts b/lfs/initscripts
>>>> index 99fe2f1be..49215c0ae 100644
>>>> --- a/lfs/initscripts
>>>> +++ b/lfs/initscripts
>>>> @@ -176,6 +176,7 @@ $(TARGET) :
>>>> ln -sf ../init.d/mounttmpfs /etc/rc.d/rcsysinit.d/S43mounttmpfs
>>>> ln -sf ../init.d/smt /etc/rc.d/rcsysinit.d/S44smt
>>>> ln -sf ../init.d/udev_retry /etc/rc.d/rcsysinit.d/S45udev_retry
>>>> + ln -sf ../init.d/cpupower /etc/rc.d/rcsysinit.d/S46cpupower
>>>> ln -sf ../init.d/cleanfs /etc/rc.d/rcsysinit.d/S50cleanfs
>>>> ln -sf ../init.d/setclock /etc/rc.d/rcsysinit.d/S60setclock
>>>> ln -sf ../init.d/console /etc/rc.d/rcsysinit.d/S70console
>>>> diff --git a/src/initscripts/system/cpupower
>>>> b/src/initscripts/system/cpupower
>>>> new file mode 100644
>>>> index 000000000..82b62a89b
>>>> --- /dev/null
>>>> +++ b/src/initscripts/system/cpupower
>>>> @@ -0,0 +1,89 @@
>>>> +#!/bin/sh
>>>> +###############################################################################
>>>> +#
>>>> #
>>>> +# IPFire.org - A linux based firewall
>>>> #
>>>> +# Copyright (C) 2025 IPFire Team <info@ipfire.org>
>>>> #
>>>> +#
>>>> #
>>>> +# This program is free software: you can redistribute it and/or
>>>> modify #
>>>> +# it under the terms of the GNU General Public License as
>>>> published by #
>>>> +# the Free Software Foundation, either version 3 of the License,
>>>> or #
>>>> +# (at your option) any later version.
>>>> #
>>>> +#
>>>> #
>>>> +# This program is distributed in the hope that it will be useful,
>>>> #
>>>> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
>>>> #
>>>> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>>>> #
>>>> +# GNU General Public License for more details.
>>>> #
>>>> +#
>>>> #
>>>> +# You should have received a copy of the GNU General Public
>>>> License #
>>>> +# along with this program. If not, see
>>>> <http://www.gnu.org/licenses/>. #
>>>> +#
>>>> #
>>>> +###############################################################################
>>>> +
>>>> +. /etc/sysconfig/rc
>>>> +. ${rc_functions}
>>>> +
>>>> +# Load the configuration if it exists
>>>> +if [ -r "/etc/sysconfig/cpupower" ]; then
>>>> + . /etc/sysconfig/cpupower
>>>> +fi
>>>> +
>>>> +# This function returns which governor to use
>>>> +find_governor() {
>>>> + local driver
>>>> +
>>>> + # If a governor has been configured, we just use that one
>>>> + if [ -n "${GOVERNOR}" ]; then
>>>> + echo "${GOVERNOR}"
>>>> + return 0
>>>> + fi
>>>> +
>>>> + # Determine the driver
>>>> + if [ -r "/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver" ]; then
>>>> + driver="$(</sys/devices/system/cpu/cpu0/cpufreq/scaling_driver)"
>>>> + fi
>>>> +
>>>> + # Decide which governor to use based on the driver
>>>> + case "${driver}" in
>>>> + # If the driver could not be detected, we won't use anything
>>>> + "")
>>>> + ;;
>>>> +
>>>> + # Intel P-State only supports performace and powersave. The latter
>>>> + # is rather implemented like ondemand in other cases.
>>>> + intel_pstate)
>>>> + echo "powersave"
>>>> + ;;
>>>> +
>>>> + # For everything else use schedutil
>>>> + *)
>>>> + echo "schedutil"
>>>> + ;;
>>>> + esac
>>>> +
>>>> + return 0
>>>> +}
>>>> +
>>>> +set_governor() {
>>>> + # Find the governor to use
>>>> + local governor="$(find_governor)"
>>>> +
>>>> + # If we could not detect a governor we don't have anything to do
>>>> + if [ -z "${governor}" ]; then
>>>> + return 0
>>>> + fi
>>>> +
>>>> + # Set the governor
>>>> + cpupower frequency-set --governor "${governor}" >/dev/null
>>>> +}
>>>> +
>>>> +case "${1}" in
>>>> + start)
>>>> + boot_mesg "Enabling CPU Power Saving Features..."
>>>> + set_governor
>>>> + evaluate_retval
>>>> + ;;
>>>> + *)
>>>> + echo "Usage: ${0} {start}"
>>>> + exit 1
>>>> + ;;
>>>> +esac
>>>
>>
>>
>
> Jon
>
>
> --
> Jon Murphy
> murphy.jon@me.com
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-07-21 20:32 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-17 17:30 [PATCH 1/3] initscripts: Automatically enable CPU power saving features Michael Tremer
2025-07-17 17:30 ` [PATCH 2/3] cpufrequtils: Drop package Michael Tremer
2025-07-17 17:30 ` [PATCH 3/3] cpufrequtils: Drop unused patches Michael Tremer
2025-07-20 14:05 ` [PATCH 1/3] initscripts: Automatically enable CPU power saving features Charles Brown
2025-07-21 9:10 ` Michael Tremer
2025-07-21 19:17 ` Re[2]: " Jon Murphy
[not found] ` <E24211ED-C10E-4AAD-A8F0-BC61DF59FD29@me.com>
2025-07-21 20:31 ` Charles Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox