Limit maximum processor speed

cpu

For a long time I wondered why my computer overheated in Linux, although it also happened to me in Windows but not so often, so I wondered what would happen and I realized that it only happened when either of the 2 processors was at 100% frequency by a prolonged time which caused it to overheat and eventually shut down.

This made it almost impossible to install any linux distro since from the live cd they made to put the processor to maximum and I had to put a fan in the ventilation inlet of the laptop, I did this several times because of my mania of installing which distro I was put it in front only until entering the section but only gnome 2 could limit the frequency of the processor (in userspace mode) with the applet that was included but it stayed all the time in the frequency that I put it and it was not in ondemand and that It made it always be at the frequency that I let it and not the one that the processor needed.

It was when I was looking for how to limit the maximum frequency at which the processor can work, so that the processor would be handled in ondemand without reaching 100% of the processor so that it did not overheat.

First we must know how many processors we have in a terminal write:

ls / sys / devices / system / cpu / | grep cpu [0-9]

In my case the output was

cpu0 cpu1

It means I have 2 processors

Then for each processor you have

more / sys / devices / system / cpu / cpu [0-9] / cpufreq / scaling_available_frequencies

In my case the outputs were

:::::::::::::: / sys / devices / system / cpu / cpu0 / cpufreq / scaling_available_frequencies :::::::::::::: 2100000 1050000 525000 --More-- (Next file: / sys / devices / system / cpu / cpu1 / cpufreq / scaling_availabl :::::::::::::: / sys / devices / system / cpu / cpu1 / cpufreq / scaling_available_frequencies :::: :::::::::: 2100000 1050000 525000

For both processors, as I told you if I have the processors at 2100000 hertz it overheats after a while so I want to limit the maximum frequency, as the files in the directory / sys / devices / system / cpu / cpux / cpufreq / are from the administrator is necessary to make the changes we want as administrator

The maximum speed is edited in the file

/ sys / devices / system / cpu / cpu0 / cpufreq / scaling_max_freq / sys / devices / system / cpu / cpu1 / cpufreq / scaling_max_freq

And since I want to change it at each start, it is convenient for me to put it in /etc/rc.local then I edit that file as administrator
Gnome

gksu gedit /etc/rc.local

KDE

kdesu kate /etc/rc.local

Terminal (change nano to your favorite editor or use su before typing the command)

sudo nano /etc/rc.local

Add between the lines

 #! / bin / sh -e echo 1050000> '/ sys / devices / system / cpu / cpu0 / cpufreq / scaling_max_freq' echo 1050000> '/ sys / devices / system / cpu / cpu1 / cpufreq / scaling_max_freq' exit 0

And so the maximum speed of the processor will be 1050000.

I hope it is useful to someone.


31 comments, leave yours

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   merlin the debianite said

    What a good tip, in fact I have a Desktop PC with Solus that could not do anything that turned off I am going to try thanks for the article.

  2.   Ivan Barra said

    Hey, did you ever check or update your computer's BIOS? Is it an HP model? I ask you, because it is most likely a problem with the BIOS and the configuration of the Intel SpeedStep or the AMD cool & Quiet, I have solved the issue of overheating a lot of times by updating the BIOS (I am a team builder), the other , is to change the thermal paste that comes from the factory (they are generally very bad), for one with silver compounds, they cost USD $ 10 and are generally much better than those used when assembling. The other, check the dirt or dust, the lint inside your equipment and finally, you can buy a base (that is aluminum, the plastic ones have the opposite effect for which they were acquired), and with that ventilate the part bottom of the equipment.

    That, I hope it helps you,

    Greetings.

    1.    Christopher castro said

      It's a Toshiba Satellite A305D-SP6905R http://pcxion.com/shop/printinfo.php?products_id=1080

      Since new I had the problem, when I have money I take it to maintenance and I had to update the BIOS since I could not install windows 7 in its time so I had to update by force and I suppose it was the last BIOS update that had to be installed.

      1.    Ivan Barra said

        How strange that happens to you, I have had 2 Toshiba and never had temperature problems. Not so the HP, I had a 13.3 ″ tablet-type HP Compaq and it came out horribly bad. And I have repaired dozens of HP with the same problem, but it has been mostly a design problem, and those with Nvidia graphics, the typical soldering problem, so I had to apply reballing.

        Greetings.

  3.   Germaine said

    Thanks for the information, at the moment my Samsung RV408 laptop with 6GB RAM and LM14 KDE RC x64 works without problems, however as a precaution and from some time ago I use a base with 3 motor fans for both this and the Acer AOD255E netbook with 2 GB RAM and LM14 KDE RC x32 and keep very cool, only the netbook is noticeable that it gets a little hot when I have many programs and windows open, otherwise I have never been turned off or given overheating alarms.
    It would be good to get to know what makes and models give these problems and how they have solved them, in order to have references.

  4.   Alf said

    Mine sometimes gets hot, the frequency of my 2 processors

    alf @ Alf: ~ $ more / sys / devices / system / cpu / cpu [0-9] / cpufreq / scaling_available_frequencies
    :::::::::::::::
    / sys / devices / system / cpu / cpu0 / cpufreq / scaling_available_frequencies
    :::::::::::::::
    1900000 1800000 1600000 1400000 1200000 1000000 800000
    :::::::::::::::
    / sys / devices / system / cpu / cpu1 / cpufreq / scaling_available_frequencies
    :::::::::::::::
    1900000 1800000 1600000 1400000 1200000 1000000 800000
    alf @ Alf: ~ $

    How often do you suggest I leave as maximum?

    1.    Christopher said

      1600000

      I really don't know very well, but if 1.9Ghz is the maximum, 1.6 is a good frequency.

  5.   hexborg said

    Good tip. I have never had a heat issue, but I will take that into account just in case.

  6.   reevil said

    In practice, this should significantly reduce the speed with which applications open and other events in which the processor has peaks in workload (especially in single-core computers)
    I'm right?

    1.    Ivan Barra said

      It is correct, but it depends, if you only use the computer to watch the internet, music and videos, you will not notice the difference, now, if you are a compulsive code compiler, you will notice the difference.

      Greetings.

  7.   self said

    I also have this problem in an old Acer Aspire 5315 that I want to solve once and for all; but the path of my directory tree differs from the one you indicate, until cpu0 matches but from then on I can't find the cpufreq folder but these other caches, cpuidle, power, subsystem, thermal-throttle, topology and the crash-notes and files uevent and in none of the folders I see the file scaling_max_freq.

    1.    husband said

      cpu freq scaling is only available for mics after core2duo, not pentium D, 4, celeron or mononucleos. It is because even the prescotts worked to the maximum, wasting energy and heat, I had one that always walked at 40 or more always, that if in winter I did not have cold feet 😛 greetings

      1.    Germaine said

        Hehehe 🙂 you can't imagine the idea you've given me… !!!

  8.   Uno said

    For Gnome or Unity there is the indicator-cpufreq, which allows you to change the processor speed and power settings from the top panel.

  9.   Ergean said

    Hi @Christopher Castro, congratulations on the article, concise and useful, just a small correction, do not call the CPU / UCP cores (the processor) processor, as people could get confused.

    What surprises me is that having two processor cores, you have heating problems, perhaps you should open it and clean it, or if it is not due to dirt or dust, you should take it to technical service.

    Greetings to all.

  10.   msx said

    It doesn't really make sense to limit the processor speed if the ONDEMAND * governor is activated unless you know in advance that the tasks you are going to perform are not going to be CPU intensive such as browsing heavy web pages *.

    Keep in mind that the less we scale the processor, the more time it will need to render the pages and the more energy it will consume, on the other hand, the ONDEMAND governor automatically sets the frequencies to the lowest level when the machine is idle.
    Ideally, use ONDEMAND and tweak the governor correctly so that it activates and deactivates as quickly as possible depending on the system load, for example:

    w / sys / devices / system / cpu / cpu [0-3] / cpufreq / scaling_governor - - - - ondemand
    w / sys / devices / system / cpu / cpufreq / ondemand / up_threshold - - - - 85
    w / sys / devices / system / cpu / cpufreq / ondemand / sampling_down_factor - - - - 20
    (nomenclature in systemd format)

    Just as important as the rulers is to turn off the dedicated graphics card if we are not using it (in case our machine has a hybrid video system) the same as the rest of the devices that the system uses and, above all, use POWERTOP 2 to put in low energy mode those devices that are set to work at maximum performance.

    j: 0 ~ $ cat /etc/tmpfiles.d/optimized.conf
    w / sys / kernel / debug / vgaswitcheroo / switch - - - - OFF

    #w / sys / class / drm / card0 / device / power_profile - - - - low
    w / sys / class / drm / card0 / device / power_method - - - - dynpm

    w / sys / devices / system / cpu / cpu [0-3] / cpufreq / scaling_governor - - - - ondemand
    w / sys / devices / system / cpu / cpufreq / ondemand / up_threshold - - - - 85
    w / sys / devices / system / cpu / cpufreq / ondemand / sampling_down_factor - - - - 20

    #w / sys / module / snd_hda_intel / parameters / power_save - - - - 1

    w / sys / kernel / mm / transparent_hugepage / enabled - - - - madvise
    w / sys / kernel / mm / transparent_hugepage / defrag - - - - madvise
    w / sys / kernel / mm / transparent_hugepage / khugepaged / defrag - - - - 0

    w / proc / sys / kernel / watchdog - - - - 0
    w / sys / class / scsi_host / host [0-5] / link_power_management_policy - - - - min_power
    w / sys / bus / pci / devices / * / power / control - - - - auto

    w / proc / sys / vm / dirty_writeback_centisecs - - - - 1500

    j: 0 ~ $ cat /etc/rc.local
    #! / Bin / bash
    #
    # /etc/rc.local: Local multi-user startup script.
    #

    mod probe radeon
    echo OFF> / sys / kernel / debug / vgaswitcheroo / switch
    rmmod radeon
    (Be careful with the rmmod because if we want to activate the specialized video card and try to reload the module while it is off, the system will give us a beautiful kernel panic).

    1.    mariochannels said

      If you had understood something, I would try it. I am new to this and I need to see things step by step, with pears and apples. I found your answer interesting.

  11.   Carlos Carmona said

    What a nice guy, I'll give it a try since I've had some problems with the team. Thank you

  12.   tuxi said

    Hi, could you tell me what is the normal temperature for a 2ghz dual-core processor, Thanks and regards

  13.   jony127 said

    Good,

    This is a very important issue to which, after a while of being using Linux I started to investigate to reduce the temperature of the CPU as well as its energy consumption.

    This topic took me several hours of research and testing and I am going to tell you about a simple way to configure our cpu in Debian to work on demand, that is, the cpu automatically adjusts its frequency according to the workload that the processor receives, increasing it when It is necessary to not lose performance and working at the lowest frequency when necessary, thus reducing the power consumption of our processor and consequently the temperature. Although I did this on debian it should work with any distro.

    Install the cpufreqd and cpufrequtils packages. (I think a reboot was necessary after this).

    Choosing and loading the module for the processor, for modern intel processors we do it with modprobe acpi-cpufreq (note in debian it loads itself, we can check it with lsmod, I suppose it will be the same for the rest).

    Check operation.

    First we are going to check that our driver for the processor has been loaded, for this we only have to make a cat to the correct file:

    cat / sys / devices / system / cpu / cpu0 / cpufreq / scaling_driver

    The output you should observe is something like ...
    acpi-cpufreq

    Now if the previous test has been successful we can check which are the available frequencies for our processor again with the cat command:

    cat / sys / devices / system / cpu / cpu0 / cpufreq / scaling_available_frequencies

    The output you should observe is something like ...
    1600000 800000

    We can also show the available governors:

    cat / sys / devices / system / cpu / cpu0 / cpufreq / scaling_available_governors

    The output you should observe is something like ...
    powersave userspace conservative ondemand performance

    And what is the governor used at this time:
    cat / sys / devices / system / cpu / cpu0 / cpufreq / scaling_governor

    Giving us something like this:
    Performance

    Note: debian loads ondemand by default.

    This last command indicates the governor that is currently working, the most recommended is ondemand, which is the one that adjusts the speed of the processor according to demand.

    Another more direct utility to know the info of our cpu:
    cpufreq-info (we execute this command to see the info of our cpu):

    pufrequtils 002: cpufreq-info (C) Dominik Brodowski 2004-2006
    Report errors and bugs to linux@brodo.de, por favor.
    CPU analyzing 0:
    driver: acpi-cpufreq
    CPUs which need to switch frequency at the same time: 0
    hardware limits: 800 MHz - 1.73 GHz
    available frequency steps: 1.73 GHz, 1.33 GHz, 1.07 GHz, 800 MHz
    available cpufreq governors: conservative, ondemand, powersave, userspace, performance
    current policy: frequency should be within 800 MHz and 1.73 GHz.
    The governor “ondemand” may decide which speed to use
    within this range.
    current CPU frequency is 800 MHz.

    The hardware limits lines: 800 MHz - 1.73 GHz and available frequency steps: 1.73 GHz, 1.33 GHz, 1.07 GHz, 800 MHz are important, which mark the possibilities of the processor that we have.

    As you can see, they also indicate the governor that we are using and the frequency at which our cpu is currently working.

    To change the governor for all processors (required for dual and quad cores):

    cpufreq-set -r -g ondemand

    The following command also shows the speed of the processor, if the saving works well it should give values ​​lower than the max of the processor:
    $ cat / proc / cpuinfo | grep -i mhz
    o
    $ watch grep \ »cpu MHz \» / proc / cpuinfo

    Greetings, with this you can have your processor working more efficiently without wasting resources.

    1.    Christopher castro said

      Never change the governor of my cpu, I only limit the maximum speed.

      I still use ondemand: D.

  14.   Ernest said

    Friend, thank you very much, it is precisely what I am looking for.
    It worked great for me on my Athlon II x2 250 at 3GHz.
    Whenever I opened 1080p video on linux, my CPU used 100%, now, it uses
    an average of 40 to 50%.

    I was afraid that the frequency would be fixed at 1.8 GHz (which is where
    I adjusted it), but «OnDemand» is still active, when the computer is idle
    the CPU goes down to 800 MHz. Fabulous! 🙂

  15.   ellebkey said

    I have tried it in elementary Os and Ubuntu and it has worked, but I have tried it in fedora 17 and it has not worked, it does not let me save the changes when changing the amount of max_freq. Anyone know of any way to achieve it? Very good article by the way

    1.    Christopher castro said

      Actually what happens is that in fedora 17 the rc.local file does not exist and must be created in the /etc/rc.d/ folder leaving the path /etc/rc.d/rc.local

  16.   John Jho said

    I did the test with the arctic silver 5 and the temperature of the cpu under 10 ° !!!!

    1.    Blaire pascal said

      Oo sounds interesting. I have to buy a syringe with that, it really catches my attention.

  17.   crilawar said

    Thanks for the information, how can I manage the speed of my CPU whenever I want without having to use the terminal, it does not help me to do it every restart, only when I leave the machine on doing a job that does not take more than one 10%, some script to download it and to make it return normal

    Thank you

  18.   Juan Carlos Acig said

    Thank you very much for your advice. It has helped me a lot to limit the frequency of my 4 i3-2330m cpu's; I was concerned about the damage that can cause working at full speed of the process.

  19.   Francisco islas said

    Thank you very much for this valuable contribution, you helped me to have linux installed on my macbook pro. Really, thank you so much

  20.   Carlos Diaz said

    Great solution…. to extend the useful life of equipment with old technologies, whose performance is already stressed by the demands of current software. Thank you very much for the contribution !!

  21.   Luciano Ponti said

    Hello friends, thanks for your contribution I hope it works for me in my OpenSuse Tumbleweed ♣

    regards