Bug 160659

Summary: hald polls /proc/apm excessively
Product: [Fedora] Fedora Reporter: Nick Lamb <njl>
Component: halAssignee: David Zeuthen <davidz>
Status: CLOSED NOTABUG QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 4CC: mclasen
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-06-16 14:23:15 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:

Description Nick Lamb 2005-06-16 14:02:59 UTC
Description of problem:

Duron 700 desktop (ie not laptop) - upgraded from FC3, and before that previous
versions of FC/ Red Hat - unnecessarily polls APM, wasting 0.2% of CPU all day,
every day.

Version-Release number of selected component (if applicable): 0.5.2-2

hald wakes up every so often (2 seconds? a bit less?) and reads the /proc/apm
file _twice_ before going back to sleep. This is undesirable at best.

Here's a system call trace of the behaviour.

poll([{fd=5, events=POLLIN}, {fd=10, events=POLLIN}, {fd=11, events=POLLIN},
{fd=7, events=POLLIN}, {fd=13, events=POLLIN}, {fd=9, events=POLLIN|POLLPRI},
{fd=8, events=POLLIN}], 7, 1514) = 0
gettimeofday({1118929418, 873249}, NULL) = 0
open("//proc/apm", O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0xb7f1c000
read(3, "1.16ac 1.2 0x03 0x01 0xff 0x80 -"..., 1024) = 40
close(3)                                = 0
munmap(0xb7f1c000, 4096)                = 0
open("//proc/apm", O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0xb7f1c000
read(3, "1.16ac 1.2 0x03 0x01 0xff 0x80 -"..., 1024) = 40
close(3)                                = 0
munmap(0xb7f1c000, 4096)                = 0
gettimeofday({1118929419, 31308}, NULL) = 0

At least I should like to see this code changed to read /proc/apm only once for
each repetition, but preferably I should like to be able to turn this off
altogether. There's nothing for HAL to see in this APM structure on a desktop
PC, just mindless repetition.

Comment 1 David Zeuthen 2005-06-16 14:23:15 UTC
> There's nothing for HAL to see in this APM structure on a desktop
> PC, just mindless repetition.

If you're using APM, there's unfortunately no reliable way (we can't trust the
DMI tables, sorry) to detect whether there is a battery or not so we have to do
this. Suggest to use ACPI instead and then this won't happen. 

I've noted upstream (I'm upstream) to only read /proc/apm once per poll and
perhaps poll less often (say every ten seconds instead of every two seconds) -
that will be in the next release.