The officially official Devuan Forum!

You are not logged in.

#1 2026-01-30 12:02:56

unixuser
Member
Registered: 2024-09-13
Posts: 40  

struggling starting auto-cpufreq --daemon

Hi there,

I'm trying to start auto-cpufeq at startup with init.d, but the --daemon option makes it harder than expected. Here is the script (copied from cron startup) :

#!/bin/bash
# Start/stop auto-cpufreq daemon.
#
### BEGIN INIT INFO
# Provides:          auto-cpufreq
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Should-Start:    
# Should-Stop:      
# Default-Start:     2 3 4 5
# Default-Stop:
# Short-Description: Regular background program processing daemon
### END INIT INFO

PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
DESC="auto-cpufreq daemon"
NAME=auto-cpufreqd
DAEMON=/usr/local/bin/auto-cpufreq --daemon
PIDFILE=/var/run/auto-cpufreq.pid
SCRIPTNAME=/etc/init.d/"$NAME"

test -f "$DAEMON" || exit 0 && echo "exit 0"

. /lib/lsb/init-functions

case "$1" in
start)	log_daemon_msg "Starting auto-cpufreq daemon"
        start_daemon -p $PIDFILE $DAEMON
        log_end_msg $?
	;;
stop)	log_daemon_msg "Stopping auto-cpufreq daemon"
        killproc -p $PIDFILE $DAEMON
        RETVAL=$?
        [ $RETVAL -eq 0 ] && [ -e "$PIDFILE" ] && rm -f $PIDFILE
        log_end_msg $RETVAL
        ;;
status)
        status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $?
        ;;
*)	log_action_msg "Usage: /etc/init.d/auto-cpufreq {start|stop|status}"
        exit 2
        ;;
esac
exit 0

auto-cpufreq is is executable and at /usr/local/bin/
Looks like it would start without --daemon option. Sorry for infamous mistakes that mustbe in this script big_smile

Last edited by unixuser (2026-01-30 12:04:00)

Offline

#2 2026-01-30 12:29:11

EDX-0
Member
Registered: 2020-12-12
Posts: 197  

Re: struggling starting auto-cpufreq --daemon

yeh auto-cpufreq has one of the designs of all time... that and it requiring python for doing something so simple as it is to just write to a handful of locations inside the kernel sysfs among other reasons got me to write an alternative, it is tried and tested in devuan under sysvinit and elogind, have not tried on even more minimal setups like ones lacking elogind so cannot comment there, also i know it isn't what you want but just putting it out here since i was also unable to get the auto-cpufreq daemon properly running on devuan

https://github.com/eylles/afreq.sh

Offline

#3 2026-01-30 12:52:35

unixuser
Member
Registered: 2024-09-13
Posts: 40  

Re: struggling starting auto-cpufreq --daemon

Thanks EDX, I didn't know afreq, it looks lighter, you did a good work. I think I'll use it instead... I'm still using elogind by default anyway.

If anyone was able to start auto-cpufreq I'd like to know.

Offline

#4 2026-01-30 17:05:16

fanderal
Member
Registered: 2017-01-14
Posts: 127  

Re: struggling starting auto-cpufreq --daemon

unixuser wrote:

auto-cpufeq at startup

Have you tried linux-cpupower from the repo? It's a CPU scaling tool and starts at boot. Has a conf file in /etc to set governors and/or min/max frequency.

Offline

#5 2026-01-30 18:47:37

unixuser
Member
Registered: 2024-09-13
Posts: 40  

Re: struggling starting auto-cpufreq --daemon

@EDX, I had to get powermgmt-base for a dependence, looks like your program is effective, but it uses 2 Gi of ram Oo I don't know what causes it yet.

@fanderal, thanks, I'll check it out

Offline

#6 2026-01-30 19:29:43

EDX-0
Member
Registered: 2020-12-12
Posts: 197  

Re: struggling starting auto-cpufreq --daemon

yes powermgmt-base is a dependency tho the afreq.sh repo bundles a copy of on_ac_power for tho whol don't want to install powermgmt-base or for distros that don't ship said package, as for the memory usage that is odd, it really shouldn't use anywhere even close to that amount of memory consumption as it is a shell script after all, how did you got that number for memory consumption? if you check with btop what does it say? i'm not at home rn so cannot check the memory usage on my personal machine.

Offline

#7 2026-01-30 21:27:58

unixuser
Member
Registered: 2024-09-13
Posts: 40  

Re: struggling starting auto-cpufreq --daemon

I can't understand why it uses that much. Well I check with fastfetch, free and i3status. Htop shows 1960 mib for afreq

Offline

#8 2026-01-30 23:10:39

EDX-0
Member
Registered: 2020-12-12
Posts: 197  

Re: struggling starting auto-cpufreq --daemon

that is extremely odd

you can get the PID of the running afreq instance by running cat /var/run/afreq/status

with vmrss https://github.com/ThePrimeagen/vmrss it says that afreq is using 1.88281 MB of memory

with btop tree view on the sleep part of the cycle it shows that afreq is using 1.8 MB while the busybox usleep is consuming also 1.8 MB (yes it does prefer busybox usleep when available as that is more reliable than just hoping sleep supports decimals as the system could be using a sleep implementation other than gnu sleep), the busybox usleep program runs every 500 milliseconds so at about 2MB per millisecond it uses 4 MB each second (even tho those are 2 different invocations), so if a program is measuring the memory usage every X seconds then it may get that afreq is using 6 MB times X seconds, say 5 seconds that ought to sum up to 30 MB, tho i dunno if some system monitoring program measures that way, unless this is some shenanigans with the caches...

bCKmrpR.png

during tick the programs vmstat, tail, awk and others are invocated, they complete so fast that btop could only register vmstat, tail and awk, in the tick step afreq would have a memory footprint of 12MB (i'm ceiling the sum)

kMcXDIP.png

looking at htop these are the numbers of resource usage for afreq and as far as i know those are in kilobytes

9NYkJ2s.png

so i am at a loss of how afreq could balloon all the way to 1960 megabytes on your machine

Offline

#9 Yesterday 12:17:39

unixuser
Member
Registered: 2024-09-13
Posts: 40  

Re: struggling starting auto-cpufreq --daemon

this is weird because, with afreq on :

user@~ >>> free -h
               total        used        free      shared  buff/cache   available
Mem:            14Gi       3.1Gi        10Gi        12Mi       635Mi        11Gi
Swap:           11Gi          0B        11Gi

without afreq :

user@~ >>> doas pkill afreq
doas (user@devx) password: 
user@~ >>> free -h
               total        used        free      shared  buff/cache   available
Mem:            14Gi       1.1Gi        12Gi        15Mi       638Mi        13Gi
Swap:           11Gi          0B        11Gi

but it is really using 1.8 MiB :

user@~ >>> ps aux | grep afreq
root      2075  0.1  0.0   2780  1884 ?        S    11:24   0:03 /bin/sh /usr/local/sbin/afreq
user      2625  0.0  0.0   4068  2092 pts/2    S+   11:54   0:00 grep afreq

Edit : yeah, with btop tree view I have almost same numbers as yours. So the problem isn't from afreq BUT the memory increases only when it's running... Still working on it lol

Last edited by unixuser (Yesterday 12:53:16)

Offline

Board footer