• We did not send an email asking for donations - please read this post.

What is the process of changing CPU Frequency?



KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
7,355
Reaction score
6,341
Credits
59,627

bob466

Well-Known Member
Joined
Oct 22, 2020
Messages
636
Reaction score
444
Credits
4,647
I say...If it ain't broke don't fix it.
m0104.gif
 
OP
B

beann

New Member
Joined
Sep 27, 2022
Messages
7
Reaction score
0
Credits
51
This link should help. Scroll down to Section 3 and that explains it well enough:

Thank you for your reply! I have seen this before. But it does not explain the mechanism. E.g., if I change the min_frequency and max_frequency file, what will happen? How can I make sure the frequency is really changed?
 

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
7,355
Reaction score
6,341
Credits
59,627
If you do that, you're CPU will stay between those two frequencies,

To check it, run 'lscpu | grep MHz' and that'll spit out your min and max frequencies.
 
OP
B

beann

New Member
Joined
Sep 27, 2022
Messages
7
Reaction score
0
Credits
51
If you do that, you're CPU will stay between those two frequencies,

To check it, run 'lscpu | grep MHz' and that'll spit out your min and max frequencies.
Yeah, If I set these files to the same value CPU will stay in a fixed value. But how can the CPU know which frequency to set? If I want to know the change delay, how can I measure it? This command may not have enough precision?
 

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
7,355
Reaction score
6,341
Credits
59,627
The CPU knows because the kernel tells it that it needs more processing power, so it will scale to the needs as best as possible. The delay will be trivial. You could write a script that runs the command and logs the changes every few seconds, but I'm mot sure you're going to learn anything useful. Just set it where you want and know the kernel works as intended.
 
OP
B

beann

New Member
Joined
Sep 27, 2022
Messages
7
Reaction score
0
Credits
51
Thank you for your reply! Actually, I want to do some fine-grained control (micro second level), so I was wondering how can I change the frequency fastest.
The CPU knows because the kernel tells it that it needs more processing power, so it will scale to the needs as best as possible. The delay will be trivial. You could write a script that runs the command and logs the changes every few seconds, but I'm mot sure you're going to learn anything useful. Just set it where you want and know the kernel works as intended.
 

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
7,355
Reaction score
6,341
Credits
59,627
There's no rule that says you have to have different values. So, if you want a specific frequency you can just set it at the minimal and maximum. It is indeed taking place in microseconds on a modern computer. The kernel is well-adapted for this. Unless you really need to, I'd not mess with it. You seem to be quite eager, which is just fine. It's Linux, and that's awesome that you can dig into these things. I am curious about your end goal, however. What exactly are you trying to accomplish.
 
OP
B

beann

New Member
Joined
Sep 27, 2022
Messages
7
Reaction score
0
Credits
51
I was trying to optimize the latency of frequency changing (to approximate the upper bound, i.e., hardware latency). So I was wondering how large is the OS overhead, and if it is possible to skip some of them to get a speedup.
 

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
7,355
Reaction score
6,341
Credits
59,627
Hmm... That's beyond my skill level but I'm pretty sure that'd mean mucking about with the kernel, changing things like priorities.
 
OP
B

beann

New Member
Joined
Sep 27, 2022
Messages
7
Reaction score
0
Credits
51
Hmm... That's beyond my skill level but I'm pretty sure that'd mean mucking about with the kernel, changing things like priorities.
Thank you for your answer. It seems I need working on the kernel, I guess maybe I can build it from the userspace govenor with a new daemon?
 

MikeWalsh

Member
Joined
Aug 29, 2022
Messages
93
Reaction score
92
Credits
1,157
Heh. It's the same on every Linux forum I've ever visited/joined up with. It's always the 'Beginners/Noobs' sections where you find the most ridiculously technical - and often, utterly pointless - questions being asked....

@beann :- Just out of curiosity, why would you NEED to be able to change your CPU frequency on a second by second basis? I fail to see what possible use it could have.

If you want to be able to view your CPU frequency literally by-the-second, install the gKrellM system monitor. And then, install the gkx86info plugin. And what you get is this:-


GIFCap-40.gif


Below the legend for the top CPU graph (you can have one for every core if you want, but it uses a lot of screen real-estate if you've got a lot of cores; me, I prefer a single composite graph) you will see the gkx86info plugin in action.......displaying the CPU frequency second-by-second.

I do like my toys! :D

Works for me. There's quite probably CLI solutions that will do the same thing, although gKrellM is not exactly resource-heavy.....quite the opposite, in fact.

------------------------------------------

Kernel compilation is not the easy process you might imagine it to be. This page from the Arch Linux wiki - one of the best sources of information anywhere in the open-source world - may give you some pointers. Do bear in mind, however, that these commands are specific to Arch Linux.......though it'll be easy enough to modify them for most mainstream distros.



Mike. ;)
 
Last edited:
OP
B

beann

New Member
Joined
Sep 27, 2022
Messages
7
Reaction score
0
Credits
51
Heh. It's the same on every Linux forum I've ever visited/joined up with. It's always the 'Beginners/Noobs' sections where you find the most ridiculously technical - and often, utterly pointless - questions being asked....

@beann :- Just out of curiosity, why would you NEED to be able to change your CPU frequency on a second by second basis? I fail to see what possible use it could have.

If you want to be able to view your CPU frequency literally by-the-second, install the gKrellM system monitor. And then, install the gkx86info plugin. And what you get is this:-


GIFCap-40.gif


Below the legend for the top CPU graph (you can have one for every core if you want, but it uses a lot of screen real-estate if you've got a lot of cores; me, I prefer a single composite graph) you will see the gkx86info plugin in action.......displaying the CPU frequency second-by-second.

I do like my toys! :D

Works for me. There's quite probably CLI solutions that will do the same thing, although gKrellM is not exactly resource-heavy.....quite the opposite, in fact.

------------------------------------------

Kernel compilation is not the easy process you might imagine it to be. This page from the Arch Linux wiki - one of the best sources of information anywhere in the open-source world - may give you some pointers. Do bear in mind, however, that these commands are specific to Arch Linux.......though it'll be easy enough to modify them for most mainstream distros.



Mike. ;)
Thank you, I'll try these.
 
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Linux.org Hosting Donations
Consider making a donation

Members online


Latest posts

Top