Bug 664388

Summary: high cpu usage on ThinkPad T60
Product: [Fedora] Fedora Reporter: Amit Shah <amit.shah>
Component: hdapsdAssignee: Tomasz Torcz <tomek>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 14CC: amit.shah, tomek
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-02-06 09:25:51 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
strace output none

Description Amit Shah 2010-12-20 09:37:48 UTC
Description of problem:

On my ThinkPad T60, hdapsd always uses 2% of cpu time.

Pasting 'top' output.  Note the 'TIME' column usage for hdapsd.


top - 15:08:35 up  2:49,  3 users,  load average: 2.21, 1.63, 0.96
Tasks: 205 total,   2 running, 203 sleeping,   0 stopped,   0 zombie
Cpu(s): 17.0%us,  3.4%sy,  0.0%ni, 74.7%id,  4.9%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   3090240k total,  2736540k used,   353700k free,      736k buffers
Swap:  4095996k total,        0k used,  4095996k free,  1844988k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND            
 3389 root      20   0  672m 225m  11m R 35.7  7.5   2:42.46 yum                
  929 root      20   0  6328  556  468 S  2.3  0.0   3:58.32 hdapsd             
 4475 amit      20   0 15176 1296  912 R  1.0  0.0   0:01.93 top

Comment 1 Tomasz Torcz 2010-12-20 11:09:12 UTC
Some CPU usage is expected - hdapsd wakes up 50 times per second to check the values of accelerometer.
Do you have latest hdaps.ko module from tp_smapi 0.40 installed? It is not shipped in Fedora or mainstream kernel, but can improve situation. See http://www.thinkwiki.org/wiki/Tp_smapi

Please check with "powertop" how many wakeups hdapsd generates.

Comment 2 Amit Shah 2010-12-21 12:47:30 UTC
I've not tried out the tp_smapi modules.

Powertop shows hdapsd wakes up the most on the system (not surprising):


     PowerTOP version 1.13      (C) 2007 Intel Corporation

Cn                Avg residency       P-states (frequencies)
C0 (cpu running)        ( 1.6%)         2.00 Ghz    42.8%
C0                0.0ms ( 0.0%)         1.67 Ghz     0.3%
C1 mwait          0.0ms ( 0.0%)         1333 Mhz     0.3%
C2 mwait          0.2ms ( 0.1%)         1000 Mhz    56.5%
C3 mwait          6.9ms (98.3%)

Wakeups-from-idle per second : 147.9    interval: 15.0s
no ACPI power usage estimate available

Top causes for wakeups:
  25.0% ( 48.7)   hdapsd

Comment 3 Tomasz Torcz 2010-12-28 08:09:13 UTC
FYI, I forwared the question to upstream developers, it is currently sitting in moderator approval queue. In the meantime, could you provide few seconds snippet from "strace -o logfile.hdapsd.txt -v -f -p <pid of hdapsd>"?

Comment 4 Amit Shah 2010-12-31 05:22:46 UTC
(In reply to comment #3)
> FYI, I forwared the question to upstream developers, it is currently sitting in
> moderator approval queue.

Thanks.  In the meantime, I tried playing around with the -s parameter.  The default of 15 doesn't introduce these wakeups but a value of 22 does.

> In the meantime, could you provide few seconds
> snippet from "strace -o logfile.hdapsd.txt -v -f -p <pid of hdapsd>"?

I'll get this in a bit.

Comment 5 Amit Shah 2011-02-04 16:42:04 UTC
Created attachment 477064 [details]
strace output

Attached is the strace output; the config is:

$ cat /etc/sysconfig/hdapsd 
# default sensivity is 15; bump it a little and enable adaptive tuning
HDAPSD_OPTIONS="-s 15 -a"

Comment 6 Tomasz Torcz 2011-02-06 09:25:51 UTC
Amit,

strace shows that hdaps on your system uses /sys interface for reading position. This is old interface and it's expected to consume more CPU.
Optimally, hdapsd should use /dev/input/event* which allows more efficient work. You probably need to install external hdapsd module. Get http://sourceforge.net/projects/tpctl/files/tp_smapi/0.40/ , unpack it and make "make HDAPS=1 install". Afterwards your hdapsd should work with less CPU.

FYI: this external tp_smapi won't be included in Fedora, because it is not in upstream kernel. And upstream kernel won't include tp_smapi because code ownership issues aren't clear.