Page 2 of 5 FirstFirst 1234 ... LastLast
Results 11 to 20 of 46

Thread: Improve battery life and ACPI functions on the macbookpro

  1. #11
    Join Date
    Apr 2007
    Beans
    68

    Re: Improve battery life and ACPI functions on the macbookpro

    I actually have the MBP 13", that has only one GPU (9400) and yet with this system I save at least 4W. I wish I could save more, though.

  2. #12
    Join Date
    Dec 2005
    Location
    Greece
    Beans
    436

    Re: Improve battery life and ACPI functions on the macbookpro

    Quote Originally Posted by Nikos.Alexandris View Post
    I am unsure if all this is worthy for an MBP5,1 15". The difference is the NVIDIA GeForce 9600M GT graphics in the 15" models. That's actually the "main" problem with respect to battery life.
    In the following thread/post http://ubuntuforums.org/showpost.php?p=7691208&postcount=905 I've posted a screenshot of the mbp5,1 running for almost 2 hours when using the onboard graphic card. Currently I can't get the power-manager and display/keyboard brightness to work correctly. I suppose that battery life will improve when dealing with these issues.

    Kind regards, Nikos

  3. #13
    Join Date
    Jul 2009
    Location
    Sydney, Australia
    Beans
    14
    Distro
    Ubuntu Studio 9.04 Jaunty Jackalope

    Re: Improve battery life and ACPI functions on the macbookpro

    * longer battery life (apple claims up to 7 hours and my experience is on that line)
    From my experience its been more like 5 hours max, running word or flicking through the web. Generally thought, its been more like 3 or 4 because of other applications like iTunes or something. But 7 hours... wow... macbooks do have good batteries, but are you sure its 7 hours? Maybe its the new-ish models or the pro, I've got 3 macbooks and an iBook in my house, no pros

  4. #14
    Join Date
    Apr 2007
    Beans
    68

    Re: Improve battery life and ACPI functions on the macbookpro

    Quote Originally Posted by stockley View Post
    From my experience its been more like 5 hours max, running word or flicking through the web. Generally thought, its been more like 3 or 4 because of other applications like iTunes or something. But 7 hours... wow... macbooks do have good batteries, but are you sure its 7 hours? Maybe its the new-ish models or the pro, I've got 3 macbooks and an iBook in my house, no pros
    This is the one I was referring to:
    http://www.apple.com/macbookpro/specs-13inch.html

    I haven't measure precisely the 7 hours to be honest, it's more of a feeling.

  5. #15
    Join Date
    Mar 2007
    Location
    Singapore
    Beans
    Hidden!
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: Improve battery life and ACPI functions on the macbookpro

    Cannot get 7 hours with web surfing!

  6. #16
    Join Date
    Jul 2009
    Location
    Back patio...
    Beans
    80
    Distro
    Ubuntu Karmic Koala (testing)

    Re: Improve battery life and ACPI functions on the macbookpro

    Thanks for the howto. Using a macbook4,1(non-pro) the suspend-resume portion fixed some issues with not properly waking or waking in a lagged state that made mousing and using the keyboard extremely difficult.

    If you don't mind, I'm going to post a link to the Karmic forum and suggest that these tools be looked at instead of the current default.

    Thanks again.
    Grand Master Turing once dreamed that he was a machine. When he awoke he exclaimed: "I don't know whether I am Turing dreaming that I am a machine, or a machine dreaming that I am Turing!." -- The Tao Of Programming

  7. #17
    Join Date
    Sep 2009
    Beans
    8

    Re: Improve battery life and ACPI functions on the macbookpro

    Quote Originally Posted by crocowhile View Post
    I recently got one the newest MacBookPro 13" and after giving a 2 weeks trial period to OSX I decided to switch back to ubuntu and I certainly don't regret it. The only two things I *really* loved in OSX were:

    * longer battery life (apple claims up to 7 hours and my experience is on that line)

    * very fast and efficient suspend/resume

    Those two weren't quite the same in an out-of-the box ubuntu 9.04 installation but with some hacks here and there I got them working not too bad. Here I want to describe what I did and then hopefully with a bit of team work we'll get even better!

    Suspend/Resume

    Suspend and Resume actually didn't work at all after installation. I figured the reason was that I didn't have the latest EFI version. So I rebooted in OSX, did the upgrade to 1.7 and voila. Worked fine.
    They were still a bit slower than OSX, though. Especially resume (which is the one we care the most, of course). To fix it I did the following

    install a package called uswsusp
    Code:
    sudo apt-get install uswsusp
    the package carries two nice tools: s2ram and s2disk
    First of all make sure they work launching
    Code:
    sudo s2ram --force
    to suspend to ram or
    Code:
    sudo s2disk
    to hibernate.

    I personally don't care too much about hibernation. Nice thing about s2ram, though, is that it goes to sleep maintaining somehow the proper wifi settings so that when you open up the lid again the machine is immediately connected to the internet, exactly as it happens in OSX. The resume takes about 5 seconds and you are ready to go.

    By default gnome prompts you with the password after resume. If you don't like this behaviour, you can change it running
    Code:
    gconftool -s /apps/gnome-power-manager/lock/suspend -t bool false
    you can of course use s2ram and s2disk as default tools. to do so, you need to replace two of the existing scripts.
    Code:
    sudo cp /usr/lib/hal/scripts/linux/hal-system-power-hibernate-linux /usr/lib/hal/scripts/linux/hal-system-power-hibernate-linux.bak
    sudo cp /usr/lib/hal/scripts/linux/hal-system-power-suspend-linux /usr/lib/hal/scripts/linux/hal-system-power-suspend-linux.bak
    and then
    Code:
     sudo gedit /usr/lib/hal/scripts/linux/hal-system-power-hibernate-linux
    replace what you find with:
    Code:
    #!/usr/bin/env bash
    /usr/sbin/s2disk
    Code:
     sudo gedit /usr/lib/hal/scripts/linux/hal-system-power-suspend-linux
    replace what you find with:
    Code:
    #!/usr/bin/env bash
    /usr/sbin/s2ram --force
    Restart
    Restart also doesn't seem to work out of the box. With kernels 2.6.28-13 and -14 the system would go throughout the entire rebooting procedure then hang at the very end with "Restarting System". As a workaround, install kexec-tools and make sure it's active. This will enable kexec restart (meaning, when you restart the computer will skip EFI/GRUB and load directly the kernel.
    Code:
    sudo apt-get install kexec-tools
    gedit /etc/default/kexec
    and make sure the load exec is set to True.

    Extend Battery life.


    This is a bit trickier. First of all, we should be aware of what the goal is. Let's learn more about the battery:
    Code:
    gg@ggmac:~$ cat /proc/acpi/battery/BAT0/info 
    present:                 yes
    design capacity:         54500 mWh
    last full capacity:      55300 mWh
    battery technology:      rechargeable
    design voltage:          10950 mV
    design capacity warning: 250 mWh
    design capacity low:     100 mWh
    capacity granularity 1:  10 mWh
    capacity granularity 2:  10 mWh
    model number:            bq20z45189ABCDEF0123456789ABCDE
    serial number:           
    battery type:            LIONz45189ABCDEF0123456789ABCDE
    OEM info:                DPONz45189ABCDEF0123456789ABCDE
    What we are interested in is the total capacity, in my case about 55W.
    Now, we need to know what the consumption is. To do this, the best way is to use powertop
    Code:
    sudo apt-get install powertop
    and then:
    Code:
    powertop -d
    powertop will run for 15 seconds and collect info about the system. There's plenty of documentation out there: go dive. For now let's say what you care the most is this line:
    Code:
    Power usage (ACPI estimate): 16.3W (2.7 hours)
    It says that your laptop consumes about 16W/hour meaning that with a full charge you'd get 55/16=~3.5 hours of battery. Our goal is to go down to something between 9 and 10 W.

    Here's how. First of all, the video. You probably have some new version of the nvidia driver. Open xorg.conf and add the following lines to the section Device:

    Code:
        
    Option "OnDemandVBlankInterrupts" "True"
    Option "RegistryDwords" "PowerMizerLevel=0x3"
    and the following to the section screen:

    Code:
    Option       "Coolbits" "1"
    these lines will enable VBlankondemand and will set powermizer to "ondemand"; the latter will allow overclocking/downclocking of the GPU.

    After having done this, you want to change a couple of kernel settings.
    Open /boot/grub/menu.list and add to the kernel line the following:
    Code:
    usbcore.autosuspend=1 hpet=force
    so, your kernel line should read something like this:
    Code:
    kernel        (hd0,2)/boot/vmlinuz-2.6.28-13-generic root=/dev/sda3 ro quiet splash usbcore.autosuspend=1 hpet=force vga=791
    Finally, the more juicy part. Create a file called 99-savings
    Code:
    gedit ~/99-savings
    and copy and paste the following code
    Code:
    #!/usr/bin/env bash
    
    # Go fast on AC power.  Similar to default Ubuntu settings
    if on_ac_power; then
      # Set the drive to mostly stay awake.  Some may want to change -B 200
      # to -B 255 to avoid accumulating Load_Cycle_Counts
      hdparm -B 200 -S 240 -M 254 /dev/sda
    
      # Remount ext3 filesystems so the journal commit only happens every 60
      # seconds.  By default this is 5 but, I prefer to reduce the disk
      # activity a bit.
      mount -o remount,commit=60 /
      mount -o remount,commit=60 /home
    
      # Turn off the laptop mode disk optimization
      #echo 0 > /proc/sys/vm/laptop_mode
    
      # Set kernel dirty page value back to default
      echo 10 > /proc/sys/vm/dirty_ratio
      echo 5 > /proc/sys/vm/dirty_background_ratio
    
      # Only wakeup every 60 seconds to see if we need to write dirty pages
      # By default this is every 5 seconds but, I prefer 60 to reduce disk
      # activity.
      echo 6000 > /proc/sys/vm/dirty_writeback_centisecs
    
      # Turn off sound card power savings
      echo 0 > /sys/module/snd_hda_intel/parameters/power_save
      
      # Set the SATA to max performance
      echo max_performance > /sys/class/scsi_host/host0/link_power_management_policy
      echo max_performance > /sys/class/scsi_host/host1/link_power_management_policy
    
      # Make sure ondemand governor is set
      echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor 
    
      # Enable the webcam driver
    #  modprobe uvcvideo
    
      #restart bluetooth
      sudo /usr/sbin/hciconfig hci0 up
    
      # Start optional  services
    #  sudo /etc/init.d/cron start
      sudo /etc/init.d/bluetooth start
      sudo /etc/init.d/preload start
    
      #reset brightness of screen and keyboard
      sudo nvclock -S 85
      sudo echo 50 | sudo tee -a /sys/class/leds/smc::kbd_backlight/brightness
    
      #Enable eth0
      sudo ifconfig eth0 up
    
      #reset clock nvidia card (requires coolbits=1)
      sudo nvidia-settings -a GPU2DClockFreqs=100,0
      sudo nvidia-settings -a GPU3DClockFreqs=450,0
    
    else # Save power
    
      # Set the disks to aggressively save power and use the lowest acoustic
      # level.  Some might find these settings too aggressive.  If so, change 
      # "-S 4" to something larger like -S 24 (two minutes) and -B 1 to -B 255.
      hdparm -B 1 -S 4 -M 128 /dev/sda
      
      # Change the ext3 commit times to 10 minutes.  This reduces diskhcd
      # activity
      mount -o remount,commit=600 /
    
      # Set laptop disk write mode
      echo 5 > /proc/sys/vm/laptop_mode
    
      # Manually set the iwl3945 driver to power savings.
      echo 5 > /sys/bus/pci/drivers/iwl????/0000\:??\:00.0/power_level  
    
      # Reduce disk activity by waiting up to 10 minutes before doing writes
      echo 90 > /proc/sys/vm/dirty_ratio
      echo 1 > /proc/sys/vm/dirty_background_ratio
      echo 60000 > /proc/sys/vm/dirty_writeback_centisecs
    
      # Set sound card power savings
      echo 10 > /sys/module/snd_hda_intel/parameters/power_save
    
      # Set SATA to minimum power
      echo min_power > /sys/class/scsi_host/host0/link_power_management_policy
      echo min_power > /sys/class/scsi_host/host1/link_power_management_policy
    
      # Make sure ondemand governor is set
      echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor 
      
      # Remove the webcam driver
    #  modprobe -r uvcvideo
    
      #Disable eth0
      sudo ifconfig eth0 down
    
      # Stop unneccessary  services
    #  sudo /etc/init.d/cron stop
      sudo /etc/init.d/bluetooth stop
      sudo /etc/init.d/preload stop
    
      #poweroff bluetooth
      sudo /usr/sbin/hciconfig hci0 down
    
      #dim screen and keyboard brightness to minimum
      sudo nvclock -S 15
      sudo echo 0 | sudo tee -a /sys/class/leds/smc::kbd_backlight/brightness
    
      #downclock nvidia card (requires coolbits=1)
      sudo nvidia-settings -a GPU2DClockFreqs=25,0
      sudo nvidia-settings -a GPU3DClockFreqs=125,0
    
    fi
    Most of the content of this script comes from this thread and has been tweaked to my needs. Based on your personal taste you can also decide to uncomment the lines with the load/load video module and cron.

    install the script doing
    Code:
    sudo install 99-savings /etc/pm/sleep.d
    sudo install 99-savings /etc/pm/power.d
    In the thread I linked above you also find a script called 99-nvidia You may want to install that one too.

    Doing so I get a usage of 9.5W, equivalent of about 6 hours. This is with WIFI on, browsing the internet and having the screen brightness very low.
    Still not quite like OSX but not too bad either.

    Let me know how it works for you.
    (YMMV)
    I just bought a new macbook pro 5,5 and I was horrified how low was the battery life in Ubuntu jaunty. However, I did the quoted tutorial, and the power consumption came down from 16.something W to 8.6W. Amayzing! I created this ubuntuforum account just to say thank you very, very much!


    Code:
    PowerTOP 1.11   (C) 2007, 2008 Intel Corporation 
    
    Collecting data for 15 seconds 
    
    
    Cn              Avg residency
    C0 (cpu running)        ( 4.4%)
    polling          0.0ms ( 0.0%)
    C1 mwait      0.0ms ( 0.0%)
    C2 mwait      0.1ms ( 0.0%)
    C4 mwait      7.0ms (95.6%)
    P-states (frequencies)
      2.27 Ghz     0.0%
      2.13 Ghz     0.0%
      1.87 Ghz     0.0%
      1.60 Ghz     0.0%
       798 Mhz   100.0%
    Wakeups-from-idle per second : 137.2    interval: 15.0s
    Power usage (ACPI estimate): 8.6W (0.9 hours) 
    Top causes for wakeups:
      27.2% ( 57.5)       <interrupt> : ohci_hcd:usb3 
      27.2% ( 57.5)   USB device  3-6 : Apple Internal Keyboard / Trackpad (Apple Inc.) 
       9.8% ( 20.7)      <kernel IPI> : Rescheduling interrupts 
       6.2% ( 13.2)     <kernel core> : hrtimer_start (tick_sched_timer) 
       5.4% ( 11.4)     <kernel core> : scan_async (ehci_watchdog) 
       5.2% ( 11.0)       <interrupt> : extra timer interrupt 
       3.6% (  7.6)       <interrupt> : ahci 
       2.8% (  6.0)    wpa_supplicant : wl_add_timer (wl_timer) 
       2.6% (  5.6)       <interrupt> : ehci_hcd:usb2 
       2.2% (  4.7)   USB device  2-5 : Card Reader (Apple) 
       2.2% (  4.6)    gnome-terminal : schedule_hrtimeout_range (hrtimer_wakeup) 
       1.9% (  4.0)       <interrupt> : eth1, HDA Intel 
       0.5% (  1.1)           firefox : futex_wait (hrtimer_wakeup) 
       0.5% (  1.0)       <interrupt> : ohci1394, nvidia 
       0.5% (  1.0)              Xorg : nv_start_rc_timer (nv_kern_rc_timer) 
       0.4% (  0.9)   hald-addon-stor : schedule_hrtimeout_range (hrtimer_wakeup) 
       0.3% (  0.7)     <kernel core> : neigh_table_init_no_netlink (neigh_periodic_timer) 
       0.3% (  0.7)              Xorg : schedule_hrtimeout_range (hrtimer_wakeup) 
       0.2% (  0.3)    gnome-terminal : do_nanosleep (hrtimer_wakeup) 
       0.2% (  0.3)   gnome-power-man : schedule_hrtimeout_range (hrtimer_wakeup) 
       0.1% (  0.3)       compiz.real : schedule_hrtimeout_range (hrtimer_wakeup) 
       0.1% (  0.2)   update-notifier : schedule_hrtimeout_range (hrtimer_wakeup) 
       0.1% (  0.2)       gnome-panel : schedule_hrtimeout_range (hrtimer_wakeup) 
       0.1% (  0.2)              hald : schedule_timeout (process_timeout) 
       0.1% (  0.1)       <interrupt> : acpi 
       0.1% (  0.1)         ssh-agent : schedule_hrtimeout_range (hrtimer_wakeup) 
       0.1% (  0.1)    NetworkManager : schedule_hrtimeout_range (hrtimer_wakeup) 
       0.0% (  0.1)     <kernel core> : input_handle_event (input_repeat_key) 
       0.0% (  0.1)           syslogd : hrtimer_start (it_real_fn) 
       0.0% (  0.1)     <kernel core> : neigh_add_timer (neigh_timer_handler) 
       0.0% (  0.1)          gconfd-2 : schedule_hrtimeout_range (hrtimer_wakeup) 
       0.0% (  0.1)              hald : schedule_hrtimeout_range (hrtimer_wakeup) 
       0.0% (  0.1)              Xorg : laptop_io_completion (laptop_timer_fn) 
       0.0% (  0.1)           pdflush : schedule_timeout (process_timeout) 
       0.0% (  0.1)     <kernel core> : queue_delayed_work (delayed_work_timer_fn) 
       0.0% (  0.1)           firefox : schedule_hrtimeout_range (hrtimer_wakeup) 
    
    A USB device is active 100.0% of the time:
    USB device  2-5 : Card Reader (Apple)
    
    Suggestion: Enable USB autosuspend by pressing the U key or adding 
    usbcore.autosuspend=1 to the kernel command line in the grub config
    
    Suggestion: Enable SATA ALPM link power management via: 
      echo min_power > /sys/class/scsi_host/host0/link_power_management_policy
    or press the S key.
    
    Suggestion: Disable 'hal' from polling your cdrom with:  
    hal-disable-polling --device /dev/cdrom 'hal' is the component that auto-opens a
    window if you plug in a CD but disables SATA power saving from kicking in.
    
    Recent USB suspend statistics
    Active  Device name
    100.0%    USB device 4-1.1 : Bluetooth USB Host Controller (Apple, Inc.)
    100.0%    USB device  3-6 : Apple Internal Keyboard / Trackpad (Apple Inc.)
    100.0%    USB device  3-5 : IR Receiver (Apple Computer, Inc.)
    100.0%    USB device  4-1 : BCM2045B2 (Broadcom)
    100.0%    USB device  2-5 : Card Reader (Apple)
    100.0%    USB device  1-4 : Built-in iSight (Apple Inc.)
    100.0%    USB device usb4 : OHCI Host Controller (Linux 2.6.28-15-generic ohci_hcd)
    100.0%    USB device usb3 : OHCI Host Controller (Linux 2.6.28-15-generic ohci_hcd)
    100.0%    USB device usb2 : EHCI Host Controller (Linux 2.6.28-15-generic ehci_hcd)
    100.0%    USB device usb1 : EHCI Host Controller (Linux 2.6.28-15-generic ehci_hcd)

  8. #18
    Join Date
    Oct 2008
    Beans
    63

    Re: Improve battery life and ACPI functions on the macbookpro

    I have an error:
    Code:
    ercoppa@ercoppa-laptop:~/Desktop$ sudo nvidia-settings -a GPU2DClockFreqs=25,0
    
      Attribute 'GPU2DClockFreqs' (ercoppa-laptop:0.0) assigned value 25,0.
    The program 'nvidia-settings' received an X Window System error.
    This probably reflects a bug in the program.
    The error was 'BadValue (integer parameter out of range for operation)'.
      (Details: serial 69 error_code 2 request_code 139 minor_code 3)
      (Note to programmers: normally, X errors are reported asynchronously;
       that is, you will receive the error a while after causing it.
       To debug your program, run it with the --sync command line
       option to change this behavior. You can then get a meaningful
       backtrace from your debugger if you break on the gdk_x_error() function.)
    ercoppa@ercoppa-laptop:~/Desktop$ sudo nvidia-settings -a GPU3DClockFreqs=125,0
    
      Attribute 'GPU3DClockFreqs' (ercoppa-laptop:0.0) assigned value 125,0.
    The program 'nvidia-settings' received an X Window System error.
    This probably reflects a bug in the program.
    The error was 'BadValue (integer parameter out of range for operation)'.
      (Details: serial 69 error_code 2 request_code 139 minor_code 3)
      (Note to programmers: normally, X errors are reported asynchronously;
       that is, you will receive the error a while after causing it.
       To debug your program, run it with the --sync command line
       option to change this behavior. You can then get a meaningful
       backtrace from your debugger if you break on the gdk_x_error() function.)
    What's wrong? I have an MacBook 5,1.
    Excuse me for my bad english - MacBook 5,1 2.0 Ghz

  9. #19
    Join Date
    Sep 2008
    Location
    CyberSpace
    Beans
    240
    Distro
    Kubuntu 22.10 Kinetic Kudu

    Re: Improve battery life and ACPI functions on the macbookpro

    Just an FYI, this script helps a lot, but there is now way you can get 6-7 hours if you are using the computer.

    If you look in finer detail to what MAC says you can get 7 hours from. It uses pretty much nothing. The tests are for no wireless no bluetooth. And running small *** programs that use no memory.

    I can get mine to run for 7 hours on Ubuntu, but only if I have everything turned off and the lib closed...Then I an get like 8 hours or 9. But there is no way even using your computer at its lowest, is going to get you 7 hours. Unless you like to watch your screen saver.

    Anyway, everyone should use this script if they have a MacBook or Pro. It helps with power consumption a lot. Plus, if you just let Ubuntu's own ACPI do it's thing it helps a bit.
    I am now back to help the Proton Gaming phase!
    OS: Kubuntu 22.10

  10. #20
    Join Date
    Jan 2007
    Beans
    68

    Re: Improve battery life and ACPI functions on the macbookpro

    I see the script is deactivating bluetooth... While I do not use bluetooth most of the time and I do have bluetooth disabled on Mac OSX when on battery power, this seems an important limitation.

    Isn't there any way the bluez stack could implement a feature to enable/disable bluetooth so the various bluetooth front-ends in KDE and Gnome can disable this from the GUI? Just like wireless using network-manager?

    Anyway, as soon as I fix my stability and wifi problems on Kubuntu 9.10 on my MBP 5,5, I'll try some of these things, thanks!

Page 2 of 5 FirstFirst 1234 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •