Bug 338230

Summary: frequent hard disk load/unload cycles on laptop
Product: [openSUSE] openSUSE 10.2 Reporter: Forgotten User sLJ7K2dvxj <forgotten_sLJ7K2dvxj>
Component: Mobile DevicesAssignee: Holger Macht <hmacht>
Status: RESOLVED DUPLICATE QA Contact: E-mail List <qa-bugs>
Severity: Major    
Priority: P5 - None CC: alberto.passalacqua, behlert, dr, elchevive68, forgotten_--EoyBps8f, forgotten_CRPsQFwJ3b, stefan.bruens, suse, vkrevs
Version: Final   
Target Milestone: ---   
Hardware: x86-64   
OS: openSUSE 11.0   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: Two files for a work-around to power management issue on openSUSE 10.3

Description Forgotten User sLJ7K2dvxj 2007-10-31 18:29:58 UTC
On ThinkPad-T60 with Hitachi (HTS541080G9SA00) drive I see freqent load/unload cycles:

'smartctl -A' reports:

Power_On_Hours: 2187
Load_Cycle_Count: 382333

This is about 3 cycles per minute, which is unacceptably high.

If I manually set the power management of the drive with

  hdparm -B 254 /dev/sda

the problem goes away, but the power management is reset to 128 after a resume from ram.

This is an old problem, but recently got lots of publicity:

  https://launchpad.net/bug59695.html

However the workarounds suggested for Ubuntu don't apply to SUSE, since we seem to have a different way of handling power management events.

What is the suggested workaround for SUSE?
Comment 1 Forgotten User sLJ7K2dvxj 2007-11-09 16:50:34 UTC
Raising severity to "Major", because this issue may shorten hardware life.

Additional info:

  - Fresh install of 10.3 exhibits the same problem

  - The power management level is reset after both a reboot and after suspend-to-ram

  - LWN article: http://lwn.net/Articles/257426/
Comment 2 Vadim Krevs 2007-11-09 23:38:03 UTC
I've got the same problem with openSUSE 10.3 for x86-64 on Dell Inspiron 9400 with a Hitachi HTS722020K9SA00 drive. Prior to the upgrade, openSUSE 10.2 for x86-64 did not exhibit the problem.
Comment 3 David Bailey 2007-11-26 13:46:07 UTC
I'm seeing similar behavior of openSUSE 10.3 x86-64 on a Dell Precision M90.

With the default configuration, I'm seeing a Load_Cycle_Count / Power_On_Hours ratio of 30.8216 or nearly 31 load/unloads per minute. This laptop is usually used with the power adapter plugged in.

This means that the Seagate ST9160823AS drive according to the manufacturer specifications of somewhere around 600,000 load/unload cycles per drive lifetime, I can expect only 2.2 years of operational use of the drive. As this laptop is often on 24 hours per day, this is unacceptable. Because servers and desktops are implementing power management as well, this is going to impact all kinds of systems.

I imagine this is related to Linux swap behavior impacting the power management features of the drive. Since this laptop has 3,354,360 bytes of usable memory, perhaps we should look into increasing the "cost" of swapping pages out to disk on systems that are performing power management on their drives? Another thought would be to pre-cache the important libraries and keep them from getting flushed during normal use?

Another more radical option would be to disable swap unless memory becomes critically low, but I've found that disabling swap can impact system stability in certain cases.
Comment 4 David Bailey 2007-11-26 13:56:09 UTC
I meant nearly 31 load/unloads per hour.
Comment 5 David Bailey 2007-11-26 14:00:43 UTC
One other note, I'm using KDE with kpowersave. I think the defaults for disk power management were standby after 10 minutes, suspend after 20 minutes, power off after 30 minutes.
Comment 6 David Bailey 2007-11-26 14:02:10 UTC
(In reply to comment #5 from David Bailey)
> One other note, I'm using KDE with kpowersave. I think the defaults for disk
> power management were standby after 10 minutes, suspend after 20 minutes, power
> off after 30 minutes.
> 

Nevermind. That's the screen, not drive.
Comment 7 Vadim Krevs 2007-11-26 20:27:58 UTC
My temporary hack for this issue, with a Hitachi HTS722020K9SA00, was to add the following line to /etc/init.d/boot.local:

hdparm -B 200 -M 128 -S 252 /dev/sda

This sets Advanced Power Management to 200, Automatic Acoustic Management to 128 (Quietest), and Standby/Spindown time to 21 min.
Comment 8 Holger Macht 2007-11-27 12:59:12 UTC
Due to the restructuring of the power management stack in the recent past, disk power management came off a little bit badly. We're working on that for the next openSUSE release.

Some kind of real fix, or a good workaround, would be to place a new hook into /etc/pm/power.d/

(some hints of doing this are at http://en.opensuse.org/Pm-utils#Creating_your_own_hooks)

It basically looks like this:

=============================
#!/bin/bash
. /usr/lib/pm-utils/functions

case "$1" in
        true)
                echo "**disabled pm harddisk"
                <some hdparm command> ;;
        false)
                echo "**enabled pm for harddisk"
                <some hdparm command> ;;
esac
============================


This can be called with 'pm-powersave {true,false}' and is also called by kpowersave or gnome-power-manager.

Maybe we should create a openSUSE wiki page with a suitable hook. Seife, what do you think?
Comment 9 David Bailey 2007-11-27 14:39:24 UTC
Created attachment 184879 [details]
Two files for a work-around to power management issue on openSUSE 10.3

Here's a work-around encompassing two files:

/etc/sysconfig/pm-disk
/etc/pm/power.d/disk
Comment 10 Holger Macht 2007-11-27 15:18:00 UTC
/etc/sysconfig/pm-disk should be in /etc/pm/config.d/pm-disk. But that's only a minor addition. Thanks for the scripts! Maybe you can even create www.opensuse.org/DiskPowerManagement giving a short guide how to get this working? If not, nevermind, I will do it as soon time permits.
Comment 11 Forgotten User ZhJd0F0L3x 2007-11-27 15:46:44 UTC
Yes, creating a wiki page sounds like a good short-term solution, i already created a feature request to solve this better in future releases.
Comment 12 David Bailey 2007-11-27 16:14:42 UTC
Here's our work-around page. Please add to this if you can improve it.

http://en.opensuse.org/Disk_Power_Management
Comment 13 Forgotten User ZhJd0F0L3x 2007-11-27 16:34:06 UTC
*** Bug 301691 has been marked as a duplicate of this bug. ***
Comment 14 Forgotten User CRPsQFwJ3b 2008-03-11 18:20:17 UTC
What is the status of this bug? Is there going to be a fix? It's fairly major in my opinion.
Comment 15 Forgotten User ZhJd0F0L3x 2008-03-18 20:32:05 UTC
i'll try to catch up with current upstream development of pm-utils and then reconsider the issue (maybe upstream already has a solution for it).
Comment 16 Forgotten User --EoyBps8f 2008-04-26 15:53:43 UTC
Would it make sense to mount all harddisks with the "realtime" flag? If not, would it at least make sense to add a checkbox to YaST's partitioning set-up that allows the user to add that flag via a GUI?
Comment 17 Forgotten User --EoyBps8f 2008-04-26 18:37:55 UTC
I meant relatime of course.
Comment 18 Alberto Passalacqua 2008-05-05 03:07:26 UTC
As written in Bug #386555, it's still present in 11.0 beta 2.
Comment 19 Jan Ritzerfeld 2008-05-08 18:20:03 UTC
@Sven: I have a high load cycle count rate on 11.0 Beta2 even with "noatime,nodiratime".
Comment 20 Forgotten User ZhJd0F0L3x 2008-05-09 10:19:05 UTC
I just submitted a package called "laptop-mode-tools" to the buildsystem (also available from my buildservice repository).

This package is integrated into pm-utils, so that the HAL "low power" method activates the "on battery" mode of laptop_mode, the "high power" method activates the "on AC" mode of laptop_mode.

Enable CONTROL_HD_POWERMGMT=1 in /etc/laptop-mode/laptop-mode.conf

BATT_HD_POWERMGMT=1
LM_AC_HD_POWERMGMT=254

Control the "hdparm -B" values sent to the disk.

More hints are in the duplicate bug 386555

*** This bug has been marked as a duplicate of bug 386555 ***
Comment 21 Jan Ritzerfeld 2008-05-10 08:27:06 UTC
I just wanted to install your storage-fixup script from Bug 38655 today. So, thanks for providing the laptop mode tool! Activating it after install and configuring by "pm-powersave true", it seems to do the trick (on 10.3, I used a script based on the wiki about DPM). I will test it and post the results here and there.
Comment 22 Jan Ritzerfeld 2008-05-10 08:46:42 UTC
"BATT_HD_POWERMGMT=1" will increase the already increased load cycle count rate up to 180 per hour for my system.

BTW, where should I file bugs and feature requests for ther new tool? 
Comment 23 Jan Ritzerfeld 2008-05-10 09:14:22 UTC
Forget about my results. I just realized that there is a laptop mode init script.
Comment 24 Forgotten User ZhJd0F0L3x 2008-05-13 14:54:10 UTC
- BATT_HD_POWERMGMT=1 in /etc/laptop-mode/laptop-mode.conf
- "chkconfig laptop-mode on" (make sure that laptop mode is started on every boot)
- "/etc/init.d/laptop-mode start" (or reboot)
- "pm-powersave true" -> powersave mode active, pretty aggressive unloading etc.
- "pm-powersave false" -> powersave mode disabled -> no unloading

The BATT_HD_POWERMGMT=1 is the "hdparm -B" value that is used for powersave mode, the LM_AC_HD_POWERMGMT=254 is the value for powersave-inactive mode.

I disabled the spindown with CONTROL_HD_IDLE_TIMEOUT=0 since a APM value of < 128 will spin down my disk no matter what idle timeout is given.
Comment 25 Jan Ritzerfeld 2008-05-14 17:12:58 UTC
> I disabled the spindown with CONTROL_HD_IDLE_TIMEOUT=0 since a APM value of < 128 will spin down my disk no matter what idle timeout is given.

Yes, same here. I disabled it in my old 10.3 script, too. It was derived from 
http://en.opensuse.org/Disk_Power_Management

However, there seem to be a problem with some proc values:
# pm-powersave true
[...]
Adjusting 2.6 kernel parameters to enable laptop mode.
Executing: echo 2 > /proc/sys/vm/laptop_mode
Executing: echo 60000 > /proc/sys/vm/dirty_writeback_centisecs
Executing: echo 60000 > /proc/sys/vm/dirty_expire_centisecs
Executing: echo 60 > /proc/sys/vm/dirty_ratio
Executing: echo 1 > /proc/sys/vm/dirty_background_ratio
[...]
# /etc/init.d/laptop-mode status
[...]
/proc/sys/vm/laptop_mode:       2
/proc/sys/vm/dirty_ratio:       60
/proc/sys/vm/dirty_background_ratio:    1
/proc/sys/vm/dirty_expire_centisecs:    30
/proc/sys/vm/dirty_writeback_centisecs: 30

Something is resetting "dirty_expire_centisecs" and "dirty_writeback_centisecs".
Comment 26 Forgotten User ZhJd0F0L3x 2008-05-15 06:56:28 UTC
pm-utils already contained a very crude and crappy laptop-mode script which is probably interfering here.

Make sure your pm-utils have this last changelog entry:

* Fr Mai 09 2008 seife@suse.de
- remove power.d/laptop-tools hook, is now handled much better by
  laptop-mode-tools package

If this is not yet available in FACTORY or you cannot update, then just remove the /usr/lib/pm-utils/power.d/laptop-tools file and try again. If it still does not work as expected, we have to further investigate ;-)
Comment 27 Jan Ritzerfeld 2008-05-18 09:20:26 UTC
Okay. I removed the link and "dirty_expire_centisecs" and
"dirty_writeback_centisecs" keep their settings. Thanks!