Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Daemon to set scaling_max_freq according to CPU temperature
View unanswered posts
View posts from last 24 hours

Goto page Previous  1, 2, 3, 4  
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3618
Location: Rasi, Finland

PostPosted: Thu Aug 15, 2024 5:45 pm    Post subject: Reply with quote

Ok. That was what I've been using, so that's good.

However I get crashes. I'll start the daemon on foreground to see if it tells something upon crashing...
_________________
..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
logrusx
Advocate
Advocate


Joined: 22 Feb 2018
Posts: 2182

PostPosted: Thu Aug 15, 2024 6:45 pm    Post subject: Reply with quote

pa4wdh wrote:
logrusx wrote:
Today my computer started stuttering and I noticed the following:

Code:
^C2024-08-15 10:05:58: Received signal 2, exiting.
2024-08-15 10:05:58: Set scaling frequency to CPU's minimum frequency


Why'd you do that? Then I have to manually adjust the scaling frequency.

My personal goal with this program was my passively cooled desktop, which means that it can overheat when the daemon is not running. As a safety measure it sets the CPU frequency to it's minimum when it exits (either a normal exit or due to an error). I could make that behavior optional if that makes more sense.

Thanks for updating you overlay Zucca.


It looks like unexpected side effect. A daemon is supposed to have effect only when it's running. And it even contains the effect in its name. No problem, I can kill it instead of terminate it, but I don't need it running all the time, nor I need it to render my computer sluggish on exit.

Best Regards,
Georgi


Last edited by logrusx on Fri Aug 16, 2024 4:49 am; edited 1 time in total
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3618
Location: Rasi, Finland

PostPosted: Thu Aug 15, 2024 7:55 pm    Post subject: Reply with quote

tail of the log:
Aug 15 21:01:01 [cputemp2maxfreq] Minimum frequency: 1400000
Aug 15 21:01:01 [cputemp2maxfreq] Maximum frequency: 2100000
Aug 15 21:01:01 [cputemp2maxfreq] Scaling maximum frequency: 1400000
Aug 15 21:01:01 [cputemp2maxfreq] Transition Latency: 100000 (Set via commandline)
Aug 15 21:01:01 [cputemp2maxfreq] Increase scaling_max_freq to 2100000
Aug 15 21:09:52 [cputemp2maxfreq] Decrease scaling_max_freq to 2000000
Aug 15 21:09:52 [cputemp2maxfreq] Failed to set scaling_max_freq, exiting
Aug 15 21:09:52 [cputemp2maxfreq] Set scaling frequency to CPU's minimum frequency
Code:
NBLK-WAX9X ~ # cpupower frequency-info | fgrep avail
  available frequency steps:  2.10 GHz, 1.70 GHz, 1.40 GHz
  available cpufreq governors: conservative ondemand userspace powersave performance schedutil

Ah. My CPU only supports three frequency states. And the jumps are 400Mhz and 300Mhz.
I guess if I set the step to 700Mhz I should not get crashes.
_________________
..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
pa4wdh
l33t
l33t


Joined: 16 Dec 2005
Posts: 868

PostPosted: Fri Aug 16, 2024 3:10 pm    Post subject: Reply with quote

Zucca wrote:
I vote for:
Change governor to powersave and adjust frequency to minimum, unless configured otherwise.

Changing the governor shouldn't make any difference if the frequency is set to minimum, unless the governor ignores that value, which it shouldn't.

logrusx wrote:
It looks like unexpected side effect

No, it's completely intended and expected. My use-case is to have it running all the time, if it exists for whatever reason if should take safety measures.

Zucca wrote:
Ah. My CPU only supports three frequency states. And the jumps are 400Mhz and 300Mhz.
I guess if I set the step to 700Mhz I should not get crashes.

My program is intended to be used on CPU's that allow any frequency to be set (with a range of course), so i expect it to stop anytime when the jump the processor can make is different from the step size.
_________________
The gentoo way of bringing peace to the world:
USE="-war" emerge --newuse @world

My shared code repository: https://code.pa4wdh.nl.eu.org
Music, Free as in Freedom: https://www.jamendo.com
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3618
Location: Rasi, Finland

PostPosted: Fri Aug 16, 2024 5:37 pm    Post subject: Reply with quote

pa4wdh wrote:
Zucca wrote:
Ah. My CPU only supports three frequency states. And the jumps are 400Mhz and 300Mhz.
I guess if I set the step to 700Mhz I should not get crashes.

My program is intended to be used on CPU's that allow any frequency to be set (with a range of course), so i expect it to stop anytime when the jump the processor can make is different from the step size.
I set it now to jump from 2.1GHz to 1.4GHz when the temperature reaches the limit. It works fine for my use-case now. ;)
Basically now governor scales the frequency however it likes. If the temperature is too high, the cpu is set to run at minimum frequency. And my laptop stays quiet. Yay!
_________________
..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
logrusx
Advocate
Advocate


Joined: 22 Feb 2018
Posts: 2182

PostPosted: Fri Aug 16, 2024 6:35 pm    Post subject: Reply with quote

pa4wdh wrote:

logrusx wrote:
It looks like unexpected side effect

No, it's completely intended and expected. My use-case is to have it running all the time, if it exists for whatever reason if should take safety measures.


It may be your intention and expectation but in general nobody would reasonably expect it. I personally will sync the previous version. It worked good enough for me.

Best Regards,
Georgi
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3618
Location: Rasi, Finland

PostPosted: Fri Aug 16, 2024 7:55 pm    Post subject: Reply with quote

logrusx wrote:
It may be your intention and expectation but in general nobody would reasonably expect it. I personally will sync the previous version. It worked good enough for me.

Best Regards,
Georgi
I think that reasonable default to drop to lowest speed. However maybe there should be a way to override this default in some way.
_________________
..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
pa4wdh
l33t
l33t


Joined: 16 Dec 2005
Posts: 868

PostPosted: Sat Aug 17, 2024 5:37 am    Post subject: Reply with quote

From our discussion here we can see points-of-view differ on this matter, so an option to control this behavior seems the way to go. My idea is to add an option to keep things as-is on a normal exit (so it sticks to whatever the program set as last value), on an abnormal exit (failure of some kind) i think it should always do some kind of failsafe.

Would that work for you?
_________________
The gentoo way of bringing peace to the world:
USE="-war" emerge --newuse @world

My shared code repository: https://code.pa4wdh.nl.eu.org
Music, Free as in Freedom: https://www.jamendo.com
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3618
Location: Rasi, Finland

PostPosted: Sun Aug 18, 2024 7:28 am    Post subject: Reply with quote

pa4wdh wrote:
Would that work for you?
I'm fine with the current behavior.
But as you may know when the user base grows, so does the amount of requested configuration options.

So If you want to please everyone have options for:
  • normal exit governor and frequencies
  • abnormal exit governor and frequencies


An example of both:
Code:
--exit performance 1400000 2100000 --failsafe powersave 1400000 1400000
... and if unset fallback to minimum frequency.
_________________
..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
pa4wdh
l33t
l33t


Joined: 16 Dec 2005
Posts: 868

PostPosted: Sun Aug 18, 2024 11:44 am    Post subject: Reply with quote

Pleasing everyone indeed leads to a lot of options. That's why i'm looking for something that's easy to implement and does enough to help with the issues.

Your suggestion looks nice, but with current parameter parsing this isn't easy to do. I'm using getopt (see man 3 getopt) which can handle simple switches (like -m) and arguments which take a single argument (like -i <sensor>).
_________________
The gentoo way of bringing peace to the world:
USE="-war" emerge --newuse @world

My shared code repository: https://code.pa4wdh.nl.eu.org
Music, Free as in Freedom: https://www.jamendo.com
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3618
Location: Rasi, Finland

PostPosted: Sun Aug 18, 2024 2:46 pm    Post subject: Reply with quote

Then maybe just implement "exit governor" and "failsafe governor" and just let frequency go as high as the governor allows?
Failsafe governor being 'powersave' by default and exit governor being the one being used when running cputemp2maxfreq by default.
_________________
..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
pa4wdh
l33t
l33t


Joined: 16 Dec 2005
Posts: 868

PostPosted: Sun Aug 25, 2024 3:47 pm    Post subject: Reply with quote

I just updated the repo (no ebuild yet). Most important changes:
- Added the -k option as proposed a few posts back to keep the last state instead of setting the lowest possible frequency
- Added multi-CPU support (also makes it a tiny bit more efficient on single-CPU machines), added -P parameter for that
- Added a manpage
- Added -Wall and -Werror to CFLAGS in the Makefile and fixed the errors it came up with
_________________
The gentoo way of bringing peace to the world:
USE="-war" emerge --newuse @world

My shared code repository: https://code.pa4wdh.nl.eu.org
Music, Free as in Freedom: https://www.jamendo.com


Last edited by pa4wdh on Sun Aug 25, 2024 5:24 pm; edited 1 time in total
Back to top
View user's profile Send private message
logrusx
Advocate
Advocate


Joined: 22 Feb 2018
Posts: 2182

PostPosted: Sun Aug 25, 2024 4:06 pm    Post subject: Reply with quote

Great!

I haven't used it for a while, no big builds necessitated it, but will report when I use it. For now I just started it to se how it behaves. No surprises.

Best Regards,
Georgi
Back to top
View user's profile Send private message
pa4wdh
l33t
l33t


Joined: 16 Dec 2005
Posts: 868

PostPosted: Wed Sep 04, 2024 9:09 am    Post subject: Reply with quote

I've just made a new release with a new ebuild.

I've added some more compiler flags to catch coding errors, and made it more explicit the code is GPL3 (this was already stated in the ebuild, but now it contains the license and copyright headers).

Ebuild and manifest can be found here: https://code.pa4wdh.nl.eu.org/tools/cputemp2maxfreq/tree/gentoo
_________________
The gentoo way of bringing peace to the world:
USE="-war" emerge --newuse @world

My shared code repository: https://code.pa4wdh.nl.eu.org
Music, Free as in Freedom: https://www.jamendo.com
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Goto page Previous  1, 2, 3, 4
Page 4 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum