You are not logged in.

#1 2012-11-08 23:44:26

snack
Member
From: Italy
Registered: 2009-01-13
Posts: 907

[ALMOST SOLVED] HDD keeps parking/unparking heads with laptop-mode

I know that this is a delicate issue since it can kill a HDD, so I'm searching for some insight. I have laptop-mode-tools installed and running. When I'm on battery my HDD keeps parking and unparking heads, producing the characteristic "click" that is like a funeral bell for the drive... Through iotop I saw that, when in idle,  the typical disk activity is disk write by some process (mainly plasma-desktop and skype); then "click", heads are parked, and after some seconds there's a new disk write activity which triggers an unparking, and so on resulting in a continuous park/unpark. As far as I understand, one of the features of laptop-mode is to set a time period during which data to be written on disk is kept in memory to prevent fequentdisk activity and the above described situation. I think taht I set it to 10 minutes when on battery by the  LM_BATT_MAX_LOST_WORK_SECONDS setting in my /etc/laptop-mode/llaptop-mode-conf, but it actually doesn't seem to give many benefits. I'm really puzzled since I can't figure out how to solve this problem and save my HDD from premature death. Here's my laptop-mode.conf (purged from comments), in case someone has some good hint to give me:

ENABLE_LAPTOP_MODE_TOOLS=1
LOG_TO_SYSLOG=1
DEBUG=0
ENABLE_LAPTOP_MODE_ON_BATTERY=1
ENABLE_LAPTOP_MODE_ON_AC=1
ENABLE_LAPTOP_MODE_WHEN_LID_CLOSED=0
ENABLE_AUTO_MODULES=1
MINIMUM_BATTERY_CHARGE_PERCENT=3
DISABLE_LAPTOP_MODE_ON_CRITICAL_BATTERY_LEVEL=1
HD="/dev/[hs]d[abcdefgh]"
PARTITIONS="auto /dev/mapper/*"
ASSUME_SCSI_IS_SATA=1
LM_BATT_MAX_LOST_WORK_SECONDS=600
LM_AC_MAX_LOST_WORK_SECONDS=360
CONTROL_READAHEAD=1
LM_READAHEAD=3072
NOLM_READAHEAD=128
CONTROL_NOATIME=0
USE_RELATIME=1
CONTROL_HD_IDLE_TIMEOUT=1
LM_AC_HD_IDLE_TIMEOUT_SECONDS=7200
LM_BATT_HD_IDLE_TIMEOUT_SECONDS=20
NOLM_HD_IDLE_TIMEOUT_SECONDS=7200
CONTROL_HD_POWERMGMT=1
BATT_HD_POWERMGMT=127
LM_AC_HD_POWERMGMT=254
NOLM_AC_HD_POWERMGMT=254
CONTROL_HD_WRITECACHE=0
NOLM_AC_HD_WRITECACHE=1
NOLM_BATT_HD_WRITECACHE=0
LM_HD_WRITECACHE=0
CONTROL_MOUNT_OPTIONS=1
LM_DIRTY_RATIO=60
NOLM_DIRTY_RATIO=40
LM_DIRTY_BACKGROUND_RATIO=1
NOLM_DIRTY_BACKGROUND_RATIO=10
DEF_UPDATE=5
DEF_XFS_AGE_BUFFER=15
DEF_XFS_SYNC_INTERVAL=30
DEF_XFS_BUFD_INTERVAL=1
DEF_MAX_AGE=30
XFS_HZ=100
LM_SECONDS_BEFORE_SYNC=15

Thanks.

Last edited by snack (2012-11-10 16:46:02)

Offline

#2 2012-11-08 23:55:22

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,019

Re: [ALMOST SOLVED] HDD keeps parking/unparking heads with laptop-mode

Try setting BATT_HD_POWERMGMT to 254 or increasing LM_BATT_HD_IDLE_TIMEOUT_SECONDS.

Last edited by lucke (2012-11-08 23:57:25)

Offline

#3 2012-11-09 08:04:11

snack
Member
From: Italy
Registered: 2009-01-13
Posts: 907

Re: [ALMOST SOLVED] HDD keeps parking/unparking heads with laptop-mode

I want BATT_HD_POWERMGMT to stay on 127 since it is the highest value that permits spindown. Also, increasing LM_BATT_HD_IDLE_TIMEOUT_SECONDS should (if I'm correct) increase the idle time after which the disk spins down; so it is not related to head parking frequency. In fact, I don't want the heads to be parked less frequently, since it is the correct behavior to save energy; I'd like them to be unparked less frequently, since that consumes energy and triggers a subsequent parking.
BTW, my HDD type is:

$ sudo hdparm -I /dev/sda

/dev/sda:

ATA device, with non-removable media
        Model Number:       TOSHIBA MK3252GSX                       
        Serial Number:      68E6P0RGT
        Firmware Revision:  LV010A  
        Transport:          Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6
Standards:
        Supported: 8 7 6 5 
        Likely used: 8
Configuration:
        Logical         max     current
        cylinders       16383   16383
        heads           16      16
        sectors/track   63      63
        --
        CHS current addressable sectors:   16514064
        LBA    user addressable sectors:  268435455
        LBA48  user addressable sectors:  625142448
        Logical  Sector size:                   512 bytes
        Physical Sector size:                   512 bytes
        device size with M = 1024*1024:      305245 MBytes
        device size with M = 1000*1000:      320072 MBytes (320 GB)
        cache/buffer size  = 8192 KBytes
Capabilities:
        LBA, IORDY(can be disabled)
        Queue depth: 32
        Standby timer values: spec'd by Standard, no device specific minimum
        R/W multiple sector transfer: Max = 16  Current = 16
        Advanced power management level: 254
        DMA: sdma0 sdma1 sdma2 mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 *udma5 
             Cycle time: min=120ns recommended=120ns
        PIO: pio0 pio1 pio2 pio3 pio4 
             Cycle time: no flow control=120ns  IORDY flow control=120ns
Commands/features:
        Enabled Supported:
           *    SMART feature set
                Security Mode feature set                                                                                                                                           
           *    Power Management feature set                                                                                                                                        
           *    Write cache                                                                                                                                                         
           *    Look-ahead                                                                                                                                                          
           *    Host Protected Area feature set                                                                                                                                     
           *    WRITE_BUFFER command                                                                                                                                                
           *    READ_BUFFER command                                                                                                                                                 
           *    NOP cmd                                                                                                                                                             
           *    DOWNLOAD_MICROCODE                                                                                                                                                  
           *    Advanced Power Management feature set                                                                                                                               
                SET_MAX security extension
           *    48-bit Address feature set
           *    Device Configuration Overlay feature set
           *    Mandatory FLUSH_CACHE
           *    FLUSH_CACHE_EXT
           *    SMART error logging
           *    SMART self-test
           *    General Purpose Logging feature set
           *    WRITE_{DMA|MULTIPLE}_FUA_EXT
           *    64-bit World wide name
           *    IDLE_IMMEDIATE with UNLOAD
           *    Gen1 signaling speed (1.5Gb/s)
           *    Native Command Queueing (NCQ)
           *    Host-initiated interface power management
           *    Phy event counters
           *    Idle-Unload when NCQ is active
           *    DMA Setup Auto-Activate optimization
                Device-initiated interface power management
           *    Software settings preservation
           *    SMART Command Transport (SCT) feature set
           *    SCT Error Recovery Control (AC3)
           *    SCT Features Control (AC4)
           *    SCT Data Tables (AC5)
Security: 
        Master password revision code = 65534
                supported
        not     enabled
        not     locked
                frozen
        not     expired: security count
        not     supported: enhanced erase
        128min for SECURITY ERASE UNIT. 
Logical Unit WWN Device Identifier: 5000039112403511
        NAA             : 5
        IEEE OUI        : 000039
        Unique ID       : 112403511
Checksum: correct

Offline

#4 2012-11-09 08:33:59

Perfect Gentleman
Member
Registered: 2012-10-25
Posts: 222

Re: [ALMOST SOLVED] HDD keeps parking/unparking heads with laptop-mode

CONTROL_HD_POWERMGMT=0
BATT_HD_POWERMGMT=255

sudo hdparm -B255 /dev/sda

yaourt -S systemd-hddapm

sudo systemctl enable hddapm

Offline

#5 2012-11-09 08:39:50

snack
Member
From: Italy
Registered: 2009-01-13
Posts: 907

Re: [ALMOST SOLVED] HDD keeps parking/unparking heads with laptop-mode

I suppose that you are suggesting me to disable laptop-mode's HDD management and install the corresponding systemd tool... Yes, I could give it a try but there's not so much documentation on how it works and in the end I like laptop-mode and I would like to understand why it is not working properly and maybe fix it, not just throw it away.

Offline

#6 2012-11-09 16:21:53

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,019

Re: [ALMOST SOLVED] HDD keeps parking/unparking heads with laptop-mode

You can use "dstat -d  --top-bio" to see when your disk is being read from or written to and what process is doing it. Chances are your disk is waking up because something is reading from it - laptop_mode can only batch writes.

-edit-

If those are writes indeed that are waking the disk, make sure /proc/sys/vm/laptop_mode is indeed non-zero and /proc/sys/vm/dirty_writeback_centisecs and /proc/sys/vm/dirty_expire_centisecs are set to 60000 (10 min).

Last edited by lucke (2012-11-09 16:37:41)

Offline

#7 2012-11-09 16:31:44

snack
Member
From: Italy
Registered: 2009-01-13
Posts: 907

Re: [ALMOST SOLVED] HDD keeps parking/unparking heads with laptop-mode

As I wrote on my first post, I already did it using iotop. I found that most disk activity comes from skype and kdeinit plasma-desktop, and since it is mostly write activity I would expect that write caching configured by laptop-mode would prevent the actual write on disk and the related load/unload cycles...

Offline

#8 2012-11-09 16:58:14

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,019

Re: [ALMOST SOLVED] HDD keeps parking/unparking heads with laptop-mode

Please note my edit.

I've just tested laptop-mode on my desktop pc and I do get writes fairly often. Last time I was monitoring it on my netbook, it was working okay. Maybe it's some kernel regression? You could try on linux-lts and/or some old kernel from Arch's Rollback Machine. Or maybe reading http://www.mjmwired.net/kernel/Document … p-mode.txt would give you some idea.

Offline

#9 2012-11-09 17:04:20

snack
Member
From: Italy
Registered: 2009-01-13
Posts: 907

Re: [ALMOST SOLVED] HDD keeps parking/unparking heads with laptop-mode

Thanks lucke, you've been kind to add a post since edits are not notified and I was missing your edit. I'll try your suggestions this evening as I get back home.

Offline

#10 2012-11-10 15:15:22

snack
Member
From: Italy
Registered: 2009-01-13
Posts: 907

Re: [ALMOST SOLVED] HDD keeps parking/unparking heads with laptop-mode

I tested what lucke suggested and here's the result:

$ cat /proc/sys/vm/laptop_mode
5
$ cat /proc/sys/vm/dirty_writeback_centisecs
60000
$ cat /proc/sys/vm/dirty_expire_centisecs
60000

so I think that settings are correct. I verified that the real culprit is "kdeinit4: plasma-desktop [kdeinit]", which always trigger the disk write, while skype's writes seems to be correctly cached. I'm not an expert but I think that maybe plasma-desktop has too much disk flush instructions, or something like that...
About the kernel: I'm on linux-ck with bfq scheduler. I tried also the cfq scheduler and the stock linux-lts, but the behavior is always the same.
I'm going to install and try lxde to nail down the problem to KDE.

Offline

#11 2012-11-10 15:33:58

snack
Member
From: Italy
Registered: 2009-01-13
Posts: 907

Re: [ALMOST SOLVED] HDD keeps parking/unparking heads with laptop-mode

OK, I confirm that it is  a KDE issue. On lxde there's no such anomalous behavior. I don't know however how to dig further, maybe the best thing is to open a bug report on KDE bug tracker. Any other idea?

Offline

#12 2012-11-10 16:01:29

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,019

Re: [ALMOST SOLVED] HDD keeps parking/unparking heads with laptop-mode

laptop_mode works indeed on my netbook. Firefox likes to write stuff often, though, as it was doing on the desktop (I was using Opera last time I checked how it works on my netbook). I'm a KDE user and I don't get writes from plasma-desktop, so it's probably one of your widgets (I use panels with a pretty regular set of widgets). First step would be to find out which one.

Offline

#13 2012-11-10 16:45:06

snack
Member
From: Italy
Registered: 2009-01-13
Posts: 907

Re: [ALMOST SOLVED] HDD keeps parking/unparking heads with laptop-mode

Your suggestion was a great shot, lucke: the trouble comes from the complex-plotter palsmoid. Removing it everything works normally. Now I have to figure out why it does so much disk activity and eventually report a bug upstream (if upstream still exists...)

Last edited by snack (2012-11-10 16:45:27)

Offline

Board footer

Powered by FluxBB