Go Back   nV News Forums > Linux Support Forums > NVIDIA Linux

Newegg Daily Deals

Reply
 
Thread Tools
Old 03-12-08, 09:34 PM   #1
shaundennie
Registered User
 
Join Date: Nov 2006
Posts: 79
Default Alternative to PerfLevelSrc (specifically for 8400M GS)

Various people have complained about 8400M GS (and, in general nvidia laptop cards under linux) and, most people have suggested using the PerfLevelSrc hack in /etc/modprobe.d/options but, after doing a test of how much battery life I was losing keeping the card at max speed at all times (Almost 1 hour on a Dell XPS m1330), I decided to write these two scripts that emulate the performance benefits of PerfLevelSrc on AC power while still giving you maximum battery life.

I've only tested this on a 8400M GS with Ubuntu 7.10 but, it should work for any laptop that uses Adaptive Clocking. I just switched to this from PerfLevelSrc today but, so far, I'm getting the same desktop experience on AC power and nearly an extra hour of battery life when unplugged (and I don't have to use any spooky modprobe hacks). Once you have the first script running in the background and the second script installed, you'll need to get things rolling by switching to/from AC/battery (so, either unplug the machine for a second if you are plugged in or plug it in if you are on battery). After that it should just work as long as you run the first script at login time.

Note: If you are currently using the PerfLevelSrc hack in /etc/modprobe.d/options, you'll need to remove it and reboot before you'll see any benefit from these scripts.

Code:
$ cat nvidia-power.sh
#!/bin/bash

while true; do
    if [ -f /tmp/nv-power-on ]; then
        nvidia-settings -q all > /dev/null
    fi
    sleep 25;
done
Save this script somewhere and run it when you login. I'm not going to describe how to do that but, ask if you don't know. The script essentially forces the card to maximum power every 25 seconds if /tmp/nv-power-on exists.

The second script is an init script that hooks into the acpi system. It adds/removes the lock file that the first script looks for. If you use compiz and the OnDemandVBlankInterrupts option in xorg.conf, there are additional options that you can uncomment to save more power while on batteries. The directions for installation are at the top of the file.

Code:
$ cat 99-nvidia.sh
#!/bin/bash

# A companion script to nvidia-power.sh that removes/adds the lock that
# tells the script whether or not it should force the card into it's highest
# frequency every 25 seconds.  Think of it as sort of a poor mans powermizer
# manager.
#
# Also, see the two comments marked OPTION if you wish to save more power
# using OnDemandVBlankInterrupts and compiz.
#
# On Ubuntu install this script with the following commands:
#
# sudo install 99-nvidia.sh /etc/acpi/start.d
# sudo install 99-nvidia.sh /etc/acpi/resume.d
# sudo install 99-nvidia.sh /etc/acpi/ac.d
# sudo install 99-nvidia.sh /etc/acpi/battery.d
#

for x in /tmp/.X11-unix/*; do
        displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`
        getXuser;
        if [ x"$XAUTHORITY" != x"" ]; then
            export DISPLAY=":$displaynum"

        if on_ac_power; then
          # OPTION: Uncomment next line  to turn on compiz vsync when the 
          # laptop is plugged in
          # su $user -c "gconftool-2 --type boolean --set /apps/compiz/general/screen0/options/sync_to_vblank 1"
          touch /tmp/nv-power-on
          su $user -c "nvidia-settings -q all > /dev/null"
        else
          # OPTION: Uncomment next line if you use compiz and have 
          # OnDemandVBlankInterrupts set to true in xorg.conf.  This will 
          # remove the ~60 wakeups a second that compiz causes the nvidia 
          # driver to do.
          # su $user -c "gconftool-2 --type boolean --set /apps/compiz/general/screen0/options/sync_to_vblank 0"
          rm -f /tmp/nv-power-on
        fi
        fi
done
I hope others find this useful. Let me know if you have any questions or problems.

Shaun
shaundennie is offline   Reply With Quote
Old 04-08-08, 10:56 PM   #2
aviynw
Registered User
 
Join Date: Nov 2007
Posts: 6
Default Re: Alternative to PerfLevelSrc (specifically for 8400M GS)

Hi, I'm using pclinuxos and am trying to get this script to work. Installing the companion script creates the 4 files in /etc/acpi but the files in /tmp are not being created. Running the first script gets me this "line 1: $: command not found." In the folder acpi there are no other files. There are two folders labelled events and actions. There are no files in actions either. In events there are two files named power and sleep that look like this
Code:
event=button/power (PWR.|PBTN)
action=/sbin/poweroff
Code:
event=button/sleep
action=/usr/sbin/pmsuspend memory
Just giving you an idea of how pclinuxos handles this as I sense it is different than ubuntu.

If you can't help me the script maybe you can help me with setting the perfLevelsrc option correctly. In /etc/modprobe.d there is no file called "options"
From what I understand I am supposed to add this line to that file
options nvidia NVreg_RegistryDwords="PerfLevelSrc=0x2222"
Should I create the file options and add that line or do I need to do something different.
Thanks for the help.
aviynw is offline   Reply With Quote
Old 04-08-08, 11:38 PM   #3
logan
Registered User
 
Join Date: Aug 2002
Posts: 492
Default Re: Alternative to PerfLevelSrc (specifically for 8400M GS)

Sounds like you might be including the cat command in the script(s). They should start with #!/bin/bash, not $ cat 99-nvidia.sh.
logan is offline   Reply With Quote
Old 04-09-08, 04:07 AM   #4
aviynw
Registered User
 
Join Date: Nov 2007
Posts: 6
Default Re: Alternative to PerfLevelSrc (specifically for 8400M GS)

Thanks, my stupidity. I no longer get that error message by running the script, but the tmp lock still isn't being created and powermizer is reporting that the speeds keep changing.
aviynw is offline   Reply With Quote
Old 04-09-08, 03:03 PM   #5
shaundennie
Registered User
 
Join Date: Nov 2006
Posts: 79
Default Re: Alternative to PerfLevelSrc (specifically for 8400M GS)

I actually updated the script slightly. There was a bug when rebooting the computer because it wasn't creating the lock until an someone was logged in. The updated script is as follows:

Code:
#!/bin/bash
# A companion script to nvidia-power.sh that removes/adds the lock that
# tells the script whether or not it should force the card into it's highest
# frequency every 25 seconds.  Think of it as sort of a poor mans powermizer
# manager.
#
# Also, see the two comments marked OPTION if you wish to save more power
# using OnDemandVBlankInterrupts and compiz.
#
# On Ubuntu install this script with the following commands:
#
# sudo install 99-nvidia.sh /etc/acpi/start.d
# sudo install 99-nvidia.sh /etc/acpi/resume.d
# sudo install 99-nvidia.sh /etc/acpi/ac.d
# sudo install 99-nvidia.sh /etc/acpi/battery.d
#

if on_ac_power; then
  touch /tmp/nv-power-on
else
  rm -f /tmp/nv-power-on
fi

for x in /tmp/.X11-unix/*; do
	displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`
	getXuser;
	if [ x"$XAUTHORITY" != x"" ]; then
	    export DISPLAY=":$displaynum"

        if on_ac_power; then
          # OPTION: Uncomment next line  to turn on compiz vsync when the 
          # laptop is plugged in
          # su $user -c "gconftool-2 --type boolean --set /apps/compiz/general/screen0/options/sync_to_vblank 1"
          su $user -c "nvidia-settings -q all > /dev/null"
        else
          # OPTION: Uncomment next line if you use compiz and have 
          # OnDemandVBlankInterrupts set to true in xorg.conf.  This will 
          # remove the ~60 wakeups a second that compiz causes the nvidia 
          # driver to do.
          # su $user -c "gconftool-2 --type boolean --set /apps/compiz/general/screen0/options/sync_to_vblank 0"
        fi
	fi
done
Unfortunately, I don't know if that is going to help you. I've only tested this on Ubuntu and don't know how the acpi subsystem works on other distros. If the script doesn't work, you should be able to create /etc/modprobe.d/options and use the PerfLevelSrc hack or, adapt the script to work properly for your distro.
shaundennie is offline   Reply With Quote
Old 04-09-08, 03:10 PM   #6
NvFuchs
Registered Fox
 
NvFuchs's Avatar
 
Join Date: Oct 2007
Location: Confoederatio Helvetica
Posts: 530
Default Re: Alternative to PerfLevelSrc (specifically for 8400M GS)

Why not using the proc interface?

Code:
while true; do
    
    powerstate=`cat /proc/acpi/ac_adapter/AC/state | awk '{print $2}'`
    
    if [ $powerstate = "on-line"  ]; then
       nvidia-settings -q all > /dev/null
    fi
    sleep 25;
done
Afaik it is +- the same on different hardware,
or you can check for yourself with cat ...

Fuchs
NvFuchs is offline   Reply With Quote
Old 04-09-08, 03:17 PM   #7
shaundennie
Registered User
 
Join Date: Nov 2006
Posts: 79
Default Re: Alternative to PerfLevelSrc (specifically for 8400M GS)

/usr/bin/on_ac_power basically just does a more thorough version of checking the /proc interface(s). I suppose that script may not exist on all distros though. I can update the script to go directly to the /proc interface if people are trying the script and finding that on_ac_power doesn't exist on their machine.
shaundennie is offline   Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 03:21 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 1998 - 2014, nV News.