Linux.com

Community Blogs



Slackware Linux Tip-of-the-day: Power savings/CPU frequency scaling

Some Linux laptop users may have noticed that the battery life under Linux outperforms the performance under windows or Mac. The reason for this is the cpu frequency scaling modules and utilities, some distros enable this by default while others like Slackware leave the choice to the user. 

What this function does is throttle the power used by your processor which slows down the system when little performance is needed and increases the power when full performance is needed. There are multiple settings depending on your needs but for most production servers and laptops setting up the automatic throttling is a good practice because it will save you battery life and power consumption.

Recently when looking in the /etc/rc.d/rc.modules file in Slackware  13.0, I noticed that Pat has slipped an auto-configure script in for frequency scaling, the extract which starts on line 814 is shown below: 

### CPU frequency scaling support
#
# Below, set CPUFREQ to enable CPU frequency scaling to save system power.
#
# To always try to use CPU frequency scaling, set to:  on
# To never use CPU frequency scaling, set to:  off
# To use it only when the battery module is loaded (this will cause it to
# be used by default with most laptops), set to:  battery
#
CPUFREQ=battery

# If CPUFREQ=battery and the battery module is loaded, turn on CPUfreq.
if [ "$CPUFREQ" = "battery" ]; then
  if /sbin/lsmod | grep -wq battery ; then
    # CPUFREQ=battery and a battery was detected, so change CPUFREQ
    # to 'on' so that the block of script below will try to enable it.
    CPUFREQ=on
  fi
fi

### Enable CPU frequency scaling if requested:
if [ "$CPUFREQ" = "on" ]; then
  ### CPU frequency scaling modules for the Linux kernel CPUfreq subsystem.
  #
  # Clock scaling allows you to change the clock speed of the CPUs on the fly.
  # This is a nice method to save battery power, because the lower the clock
  # speed is, the less power the CPU consumes.
  # 
  # It should not hurt anything to try to load these modules.
  #
  # generic ACPI P-States based driver:
  /sbin/modprobe acpi-cpufreq 2>/dev/null
  # AMD mobile K6-2/3+ PowerNow!:
  /sbin/modprobe powernow-k6 2>/dev/null
  # AMD mobile Athlon PowerNow!:
  /sbin/modprobe powernow-k7 2>/dev/null
  # AMD Cool&Quiet PowerNow!:
  /sbin/modprobe powernow-k8 2>/dev/null
  # Intel SpeedStep using the SMI BIOS interface:
  /sbin/modprobe speedstep-smi 2>/dev/null
  # Intel SpeedStep on ICH-based chipsets:
  /sbin/modprobe speedstep-ich 2>/dev/null
  # Intel Enhanced SpeedStep :
  /sbin/modprobe speedstep-centrino 2>/dev/null
  # Intel Pentium4/Xeon clock modulation is not enabled by default.
  # The kernel documentation says "This adds the CPUFreq driver for Intel
  # Pentium 4 / XEON processors.  When enabled it will lower CPU temperature
  # by skipping clocks.  This driver should be only used in exceptional
  # circumstances when very low power is needed because it causes severe
  # slowdowns and noticeable latencies.  Normally Speedstep should be used
  # instead."
  # If you still want to try the Pentium4/Xeon module, uncomment the next line:
  #/sbin/modprobe p4-clockmod 2>/dev/null
  # NatSemi Geode GX / Cyrix MediaGXm:
  /sbin/modprobe gx-suspmod  2>/dev/null
  # Transmeta Crusoe / Efficeon LongRun:
  /sbin/modprobe longrun  2>/dev/null
  # VIA Cyrix Longhaul:
  /sbin/modprobe longhaul  2>/dev/null
  # nForce2 FSB changing cpufreq driver:
  /sbin/modprobe cpufreq-nforce2 2>/dev/null
  # Enhanced PowerSaver driver for VIA C7 CPUs:
  /sbin/modprobe e_powersaver 2>/dev/null

  ### CPU frequency scaling policies:
  #
  # Use the CPUFreq governor 'powersave' as default.  This sets the
  # frequency statically to the lowest frequency supported by the CPU.
  #/sbin/modprobe cpufreq_powersave
  #
  # Use the CPUFreq governor 'performance' as default. This sets the
  # frequency statically to the highest frequency supported by the CPU.
  #/sbin/modprobe cpufreq_performance
  #
  # Use the CPUFreq governor 'conservative' as default.  This allows you
  # to get a full dynamic frequency capable system by simply loading your
  # cpufreq low-level hardware driver.  Be aware that not all cpufreq
  # drivers support the 'conservative' governor -- the fallback governor
  # will be the 'performance' governor.
  #/sbin/modprobe cpufreq_conservative
  #
  # Use the CPUFreq governor 'ondemand' as default.  This allows you to
  # get a full dynamic frequency capable system by simply loading your
  # cpufreq low-level hardware driver.  Be aware that not all cpufreq
  # drivers support the 'ondemand' governor -- the fallback governor will
  # be the performance governor.  This seems to be the most-recommended
  # scaling policy, so rc.modules will try to load this by default.
  /sbin/modprobe cpufreq_ondemand

  ### CPU scaling governor:
  #
  # Set the default scaling_governor to be used (such as userspace or ondemand)
  # if there is a CPUFreq scaling policy module loaded that supports it:
  SCALING_GOVERNOR=ondemand
  #
  # Try to enable the scaling_governor selected above:
  if [ -r /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors ]; then
    if grep -wq "$SCALING_GOVERNOR" /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors ; then
      if [ -r /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ]; then
        for SYSCPUFILE in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor ; do
          echo "$SCALING_GOVERNOR" > $SYSCPUFILE
        done
      fi
    fi
  fi

fi # End enabling CPU scaling support


Your first option is to choose if you want to enable the frequency scaling,  on line 823 you can choose on, off or battery. on and off are self explanatory, but battery is quiet cool, if you choose battery the script will autocheck if you are running on a battery and if it is true then it will turn the support on.

The next step is to choose the module for your processor type, Pat's script tried all available modules which will not hurt anything but will start your module if it is available. Once you have determined which module you use you can comment out the unused ones.

The next option is to choose  the policy/governor, explanations are listed above so I won't give redundant data, but the simplest approach is to comment out the ones you don't want to use and replace them with the governor you want to use.  For most environments ondemand is the best policy because it quickly recovers back to full performance when needed, however that governor used more power by making a quick jump so for laptops using the conservative policy will slow you down a bit but help to increase the life of your battery.

Now that you have all of the options chosen you only need to build and install the cpufrequtil package from Slackbuilds.org (http://slackbuilds.org/repository/13.0/libraries/cpufrequtils/), once that has been installed and the above listed options have been configured all you need to to is rerun the rc.module script or restart the computer. After the reboot you will notice a difference in your power usage and the heat generated by the processor.To confirm the scailing is enabled and running you you call the program cpufreq-info which will disply a similar output to what is shown below and tell you what is running and what frequency your system is running under at that point in time. 

cpufrequtils 005: cpufreq-info (C) Dominik Brodowski 2004-2006
Report errors and bugs to This e-mail address is being protected from spambots. You need JavaScript enabled to view it , please.
analyzing CPU 0:
  driver: powernow-k8
  CPUs which need to switch frequency at the same time: 0 1
  hardware limits: 1000 MHz - 2.40 GHz
  available frequency steps: 2.40 GHz, 2.20 GHz, 2.00 GHz, 1.80 GHz, 1000 MHz
  available cpufreq governors: ondemand, userspace
  current policy: frequency should be within 1000 MHz and 2.40 GHz.
                  The governor "ondemand" may decide which speed to use
                  within this range.
  current CPU frequency is 1000 MHz (asserted by call to hardware).
analyzing CPU 1:
  driver: powernow-k8
  CPUs which need to switch frequency at the same time: 0 1
  hardware limits: 1000 MHz - 2.40 GHz
  available frequency steps: 2.40 GHz, 2.20 GHz, 2.00 GHz, 1.80 GHz, 1000 MHz
  available cpufreq governors: ondemand, userspace
  current policy: frequency should be within 1000 MHz and 2.40 GHz.
                  The governor "ondemand" may decide which speed to use
                  within this range.
  current CPU frequency is 1000 MHz (asserted by call to hardware).

I hope this helps, and I will follow up with more hidden features that I find in the latest release.  

 

Slackware Linux Tip-of-the-day: Use your documentation

One great benefit of using Slackware is that documentation is provided by default for nearly every command and application that is installed on your system. If you run into an issue try looking in the following locations for assistance: 

  • The application manual pages (example.. man bash, in konqueror you can go to man:bash for a html presentation of the manual)
  • The application info pages (example.. info bash)
  • Your /usr/docs/ directory – this usually contains text and html based manuals to help you find your answers.   

If you still cannot find a resolution in those locations you can try the following communities/sites:  

 

Smaller update sizes in Fedora 12

After spending the past hour installing and getting my new Fedora 12 box set up "just right" I noticed that I had around 400MB of updates to install.

With my internet quota almost gone, I was going to put off installing the updates until later that night when I get free data, but decided I should just bite the bullet and go for it anyway. (Australian ISPs have crazy download quotas, if you're not already aware).

I was suprised to see that the package sizes where considerably smaller than they have been in previous releases.  Curious, I decided to do some reasearch and found that they now use a different compression type and that deltarpm is enabled by default.   Nice work Fedora!

More info at: http://fedoraproject.org/wiki/Fedora_12_Alpha_release_notes#Smaller_Packages

 

New isn't always better?

 My problem with my web cam was actually with Skype after upgrading, Before, all was well.. so I went backwards to see if anything changes. I have nothing against progress, but if something works, why change it. I like the 8.04 version. It's a lot simpler, not so many applications- many of which I don't need or don't understand.  I am not a computer programmer. What I know is from experimenting... mostly trial and error. More error! We learn more from our mistakes. 

I'll  give the  web cam a try this week end when I talk with my sons. If it works I'll post it. ( I came upon this in one of the forums.  Where someone said that the webcam  worked fine in a previous distribution,  but not in  a recent update. )   If this is the case, I will have solved the last of my problems, and will have become a faithful Linux/ Ubuntu user. Also I went back to the debian version of skype instead of Ubuntu 9.04, which was beta. I might return to the newer versions in the future, when I learn more.

It's nice to have choices.  It is also nice to be able to  experiment. I feel that I play  an important part in designing  something that is suitable for me. I have learned more about IT through Linux, than any other OS, and have taken a more active interest in OS's that in the past. I have surpassed my cousin,  who has studied computer programming in  university, and now I think he's jealous. He looks at me differently. This was made possible by reading various forums and sites, like this one. Thanks  for being here.  Keep up the updates, even if I don't. (I have a collection of all the distributions, so if I feel adventurous, or  get bored....I can change.

 

more to come

Well, I know that I haven't been here for a while.

I have found drivers for my printer/scanner. Works great! So does my digital camera. Microphone working, still no luck with webcam, but a friend is helping. He also (fortunately uses Ubuntu), and he will help me with searching for the right command for the webcam. I have installed Skype for Linux as well, and it works great, will be even better with video.  Does anybody know what Xv support is?

 

NiHao Home Desktop User Troubleshooter QA Blog

This blog is a simple FAQ and Troubleshooter blog for the Linux users that have downloaded and / or installed the NiHao Home Desktop Live Cd.

Myself; Grant K, of NiHao Studios will post known bugs here and workarounds as well as recieve questions from other Linux.com users regarding the NiHao Home Desktop Live Cd.

- A short historical account regarding the background of NiHao Studios.

Nihao Studios was created in 2002 by a team of teachers, and programmers while on their big OE in China.

It started small with the development of language learning software solutions for universities and colleges in and around Fujian Province.

Then later over coffees discussions were based around RPG gaming in China and the "Metaverse" (as written about in the book "SnowCrash" by Neal Stephenson [1]) and how these elements could improve the students ability to acquire new languages and / or skills.

The idea that gaming, education, and a better overall internet user system could be developed prompted allot of what is known today as NiHao World.

The first step was the building of the 3d world in which all of what we considered to be worthy of keeping from the internet of today could be housed. This project still and always will be in development is known as NiHao 3d. [2]

Then the NiHao Studios team went onto developing a CMS Portal Named NiHao People [3] based upon the Boonex Dolphin [4] CMS Script. 

Shortly after completing a running build of Dolphin on the NiHao servers the NiHao Studios team worked in conjunction with Intel(TM)[5] within the confines of the Intel Software Partner Program to aide in the development and testing of the then new release of Moblin [6].

It was after gaining Linux experience with Moblin that the final part of the NiHao set of software packages that is to become the NiHao rendition of Neal Stephenson's Metaverse began its existance with the NiHao Home Desktop [7].

It was ofcourse natural that a 3d world, a community portal, and moblin tools be based in the world's best operating systems - without saying more than needs to be said - Linux systems.

So we started out with a openSUSE [8] base, and developed our first release; the Home Desktop, and then went on to develop the Gamer edition, and finally the Server SDM suites.

It is the NiHao Gamer edition that will encompass all of the NiHao Empire products and software packages for it was with the "Metaverse"  (see[1]) in mind that all of the above story came to be and eos2 Gamer will be its host and base.

It is an enormously big project to build Neal Stephenson's Metaverse and I wonder if we will ever achieve it. Being said we are however enjoying the task whether it be fruitful or just another great Linux build.

We do welcome like minded folk to join our team whether it be for scripting or other. Its an impossible task but its a happy road.

I hope all that try the Nihao Systems and other software entities created by the NiHao Studios team find enjoyment within our creations, and do freely give feedback either here or at the NiHao sites.

Our motto "For the People, by the People" being similar with that of the Linux Foundation's  "For the Community, by the Community" ecompasses all that NiHao is....

We started as a scrabbly bunch of tourists meeting by chance in China and are now the Grandfathers of the China experience, and have been helping China develop since then by the works of our own hands.

We believe strongly in contribution and callaboration, and ask our users to follow the same simple principles belonging to the world of Linux.

For comments, bug reports, help requests, and general chatter please feel (GNU-GPL) free to add to this post :) 

Link List:

Link [1]: Wikipedia - SnowCrash, book by Neal Stephenson. 

Link [2]: NiHao 3d website.

Link [3]: NiHao People website.

Link [4]: Boonex Dolphin website.

Link [5]: Intel Corporation website.

Link [6]: Moblin.org website.

Link [7]: eOS2.org website.

Link [8]:  openSUSE.org website.

Grant K of NiHao Studios

 

openSuSE 11.2 RC1 non-U.S. keyboard problem

I am in the process of installing openSuSE 11.2 RC1 on all of my systems.  One of the first things I have found is that it still has a problem with non-U.S. keyboards.  No matter what keymap I select during installation, the installed image ends up with the U.S. definition.

You can manually change the definition by editing /etc/sysconfig/keyboard and changing the KEYTABLE value.  Look in /usr/share/kbd/keymaps/i386 to find the known maps - and don't overlook the fact that there are separate directories for qwerty and qwertz keyboard maps.  Reboot after changing.

jw 15/10/2009

 

A Tip for Mandriva 2010.0 RC2 Installation and Configuration

I've been installing the new Mandriva 2010.0 RC2 distribution on various of my notebooks, netbooks and nettop  this morning.  Well, trying to, anyway.  It has turned out to be a bit more difficult than I had expected.  I can only speak about the Mandriva One KDE LiveCD, as that is the only one I have tried, but I would assume that this is true at least for all of the One LiveCD versions.

The first problem is that the LiveCD failed to boot on my Fujitsu Lifebook S6510, which is really a pretty standard Intel Core2 Duo system with an Intel 965 graphic controller, and on my HP Pavillion dv2-1010ez, which is a not-so-standard AMD Athlon Neo CPU and ATI Mobility Radeon 3410 graphic controller.  What I finally found was that Mandriva is still trying to auto-generate their own xorg.conf  file, on those two systems they got it sufficiently wrong that the X display server couldn't even start.  However, they are using the latest X.org server (1.6.4), which is plenty smart enough to figure out everything it needs to know on its own, so it doesn't need an xorg.conf file.  So the solution was to just login as root on the text console, delete the file /etc/X11/xorg.conf, and then run startx to get the X display server going so that you can then use the LiveCD graphic installer as usual.

The second problem is that after installation, at least on the S6510 (Intel 965 graphics), the screen resolution was incorrect (1024x768 rather than 1280x800).  Once again, the problem is that they tried to auto-generate an xorg.conf file, and got it wrong, and once again the solution is to just delete (or rename, if you are very conservative) the xorg.conf file.  Then reboot, or otherwise restart the X server, and all should be well with the world.

In fact what I have done is delete the xorg.conf  file after the installation completes, even on those where they "got it right", because it's not necessary and I don't see any benefit to having it any more.  I have checked screen resolution, keyboard maps and such, and it all seems to work just fine.  If anyone should try this and find a system which does not work properly, I would be very interested in hearing about it.

jw

 

New distribution...

I have just installed Ubuntu 9.04 from a cd that came with the Linux format magazine. Wow!

It has so many applications. I'll enjoy learning them. I hope there is one for a webcam driver.

I no longer have any other OS's , only this.  I'm new to this, so it'll take time.

 

ojuba Linux 3 is released

After the release of ojuba Linux 2 (code named
alqahira which means victorious) we are pleased to announce our third
release of ojuba Linux code named "arrebat” (which means standing firm
before enemies)

ojuba Linux is an Arabic/Islamic focused Linux distribution based on Fedora (and rpmfusion). Ojuba which contains many patches (for example Arabic shaping in wine)

ojuba is gnome centric our LiveDVD/USB is a gnome desktop

we also provide an installation media which contains kde and other desktops

this release contains kde 4.3.1  and it supports off-line installation of packages

note: ojuba means wonderful or incredible.

http://www.ojuba.org/wiki/news/14300926-en

 

Linux Mint Xfce on Notebooks and Netbooks

Two of my favorite things converged over the weekend - Linux Mint, which I think is an excellent distribution for average users, and the Xfce desktop, which I find myself using and liking more than either Gnome or KDE, especially on netbooks.  So the Linux Mint 7 'Gloria' Xfce Community Edition was a welcome addition for me.  The following are a few notes that I have made about installing and configuring it on various of my notebook and netbook computers.

- The Mint Xfce Community Edition is built from the Xubuntu distribution, in much the same way that the standard Linux Mint distribution is built from the standard Ubuntu distribution.  It looks like it includes all the 'mint' utilities, such as install/update/backup/disk/nanny, and the same artwork and themes as the standard Linux Mint distribution.

- Installation is essentially identical to installing the stand Mint or Ubuntu distributions.  When the installation is complete it boots to a gdm session manager, and on login you get a pretty standard Xfce desktop (very similar to Xubuntu).

- When the installation is complete, the first thing to do is let mintUpdate install all updates.

- mintUpdate does not pick up all of the updates that have been made by Ubuntu for the base distribution.  At the present time, for example, Linux Mint still runs on the 2.6.28-11 Linux kernel, while Ubuntu is running 2.6.28-15.  If you want or need to have all of the latest updates, you have to run the Synaptic Package Manager, select "Status" from the display options at the bottom left, then "Installed (upgradeable)" from the status list.  That will show you what upgrades are available, then you can select the ones you want, or simply click "Mark All Upgrades" and "Apply". 

- Even after updating with Synaptic, you're still not quite home free.  Mint Xfce uses Wicd for network management, and like Xubuntu it is using version 1.5.9.  The latest version, though, is 1.6.2 - and I have found that on my HP 2133 Mini-Note with a Broadcom wireless adapter, the older version of Wicd causes the system to hang during boot very frequently if the wireless adapter is enabled, but the newest version of Wicd does not.  So, I update to the latest Wicd by adding their Repo to Synaptic.  Of course, you could do this before doing the full update with Synaptic, and it would then be updated along with everything else.  The Sourceforge pages for Wicd contain instructions for doing this.   (Hint: the -O- in the wget command is an upper case letter O, not a numeric 0, it is used to direct the output of the command to stdout; if the entire command works, you should get a response of "OK")  After adding the key and repo, all you need to do is click "Reload", then "Mark All Upgrades", then "Apply".

- The sound on all three of the notebook/netbook systems I have installed on was working immediately after installation, but after installing all updates there was no sound.  I had to click the mixer icon in the panel, select controls and add "Master", then un-mute and set the volume level.

- The mintDisk program will automatically mount any FAT or NTFS partitions it finds on boot.  If you don't want/need those to be mounted you can control that through Applications/System/mintDisk

- The visible desktop icons are selected in "Desktop Settings...".  Because screen space is at a premium on netbooks, I remove the Trash, Home and Filesystem icons; on ordinary notebooks with larger screens, I leave them on.

- On my netbooks, I set up two panels on the Xfce desktop.  In addition to the standard one at the bottom of the screen, I create a new one on the right side of the screen.  I move all of the simple "icon only" objects there, such as the mixer, clock (which I change to analog), workspace switcher, notifier and show desktop, and I add a Logout button.  That leaves only the text items on the bottom panel - the menus and task list.  I then set both panels to "Fixed position" and "Normal Width", and the bottom panel to Autohide.  The idea behind all of this is that netbook screens are small, so I need to save space, but there are certain icons I like to be able to see and access at all times.  For those, the netbook screen generally has more room to spare horizontally than vertically so I shift them to the right side and don't hide them, and then hide what is left on the bottom panel.  I like the result, but it is really a matter of taste.

- I was very pleased to see that Linux Mint includes Opera in its Software Manger package list (aka mintInstall) - and it is even at the latest version (10.00) already!  Firefox is of course included in the basic installation, but I prefer Opera in most situations.  It's nice to have it included in the package manager, so it will get updated automatically and thus save me from having to keep an eye on Opera updates.

- In fact, it is interesting and probably worthwhile to start mintInstall (Applications/Software Manager), and just click the "Featured Applications" to see what is there.  Lots of good stuff.  I generally also install Picasa and the VLC media player, for example.

That is essentially what it took to get the Linux Mint Xfce distribution installed and configured on my systems.   I strongly recommend it to casual users, and I honestly think that even experienced users are likely to be pleased and impressed with it.  I certainly am.

jw 15/9/2009 

 
Page 12 of 17

Upcoming Linux Foundation Courses

  1. LFS426 Linux Performance Tuning
    08 Sep » 11 Sep - New York
    Details
  2. LFS520 OpenStack Cloud Architecture and Deployment
    08 Sep » 11 Sep - Virtual
    Details
  3. LFD320 Linux Kernel Internals and Debugging
    15 Sep » 19 Sep - Virtual
    Details

View All Upcoming Courses


Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board