Continuous ACPI lid events and 100% CPU usage

Problem

With ACPI compiled into the kernel and acpid running, pressing the lid button results in continuous ACPI events, logged to /var/log/acpid. If you have any ACPI events installed, in /etc/acpi/events, then 100% CPU usage can result from the associated actions (in /etc/acpi/actions) being called over and over again. Note that this will probably also be a problem with ACPI installed as modules.

This is how it works:

  1. The user triggers an ACPI event by closing the lid, hence depressing the lid button.
  2. The event results in an event script in /etc/acpi/events/ being called.
  3. The event script checks what event occurred (e.g. the lid button was pressed) and calls an action script in /etc/acpi/actions/.
  4. The action script does whatever is required of the event, e.g. put the computer in standby mode.

The 100% CPU results from the multiple lid events calling an action script over an over again. The real problem is the continous lid events when the lid is closed, when only a single event should be triggered when the lid is closed and another one triggered when it is opened. Despite the fact that the generation of events and the writing of acpid log messages uses resources, the log file will eventually reach 2G in size and acpid will fail without warning.

If you have a laptop, two common programs that will install ACPI event/action scripts are laptop mode tools and the ati drivers.

Without any event/action scripts in /etc/acpi/ you'll see the following in /var/log/acpid:

...
[Mon Sep  4 17:32:43 2006] received event "button/lid LID 00000080 00000089"
[Mon Sep  4 17:32:43 2006] completed event "button/lid LID 00000080 00000089"
[Mon Sep  4 17:32:43 2006] received event "button/lid LID 00000080 0000008a"
[Mon Sep  4 17:32:43 2006] completed event "button/lid LID 00000080 0000008a"
[Mon Sep  4 17:32:43 2006] received event "button/lid LID 00000080 0000008b"
[Mon Sep  4 17:32:43 2006] completed event "button/lid LID 00000080 0000008b"
... 

With scripts in /etc/acpi/ you'll also see log messages describing what action scripts have been called:

[Mon Sep  4 19:20:22 2006] received event "button/lid LID 00000080 000004b5"
[Mon Sep  4 19:20:22 2006] executing action "/etc/acpi/ati-powermode.sh"
[Mon Sep  4 19:20:22 2006] BEGIN HANDLER MESSAGES
[Mon Sep  4 19:20:22 2006] END HANDLER MESSAGES
[Mon Sep  4 19:20:22 2006] action exited with status 0
[Mon Sep  4 19:20:22 2006] executing action "/etc/acpi/actions/lm_lid.sh button/lid LID 00000080 000004b5"
[Mon Sep  4 19:20:22 2006] BEGIN HANDLER MESSAGES
Laptop mode disabled, not active [unchanged].
[Mon Sep  4 19:20:22 2006] END HANDLER MESSAGES
[Mon Sep  4 19:20:22 2006] action exited with status 0
[Mon Sep  4 19:20:22 2006] executing action "/etc/acpi/actions/lid_test.sh button/lid LID 00000080 000004b5"
[Mon Sep  4 19:20:22 2006] BEGIN HANDLER MESSAGES
This option is not available. Please see --help for all possible usages.
[Mon Sep  4 19:20:22 2006] END HANDLER MESSAGES
[Mon Sep  4 19:20:22 2006] action exited with status 255
[Mon Sep  4 19:20:22 2006] completed event "button/lid LID 00000080 000004b5"
[Mon Sep  4 19:20:22 2006] received event "button/lid LID 00000080 000004b6"
[Mon Sep  4 19:20:22 2006] executing action "/etc/acpi/ati-powermode.sh"
[Mon Sep  4 19:20:22 2006] BEGIN HANDLER MESSAGES
[Mon Sep  4 19:20:22 2006] END HANDLER MESSAGES
[Mon Sep  4 19:20:22 2006] action exited with status 0
[Mon Sep  4 19:20:22 2006] executing action "/etc/acpi/actions/lm_lid.sh button/lid LID 00000080 000004b6"
[Mon Sep  4 19:20:22 2006] BEGIN HANDLER MESSAGES
Laptop mode disabled, not active [unchanged].
[Mon Sep  4 19:20:22 2006] END HANDLER MESSAGES
[Mon Sep  4 19:20:22 2006] action exited with status 0
[Mon Sep  4 19:20:22 2006] executing action "/etc/acpi/actions/lid_test.sh button/lid LID 00000080 000004b6"
[Mon Sep  4 19:20:22 2006] BEGIN HANDLER MESSAGES
This option is not available. Please see --help for all possible usages.
[Mon Sep  4 19:20:22 2006] END HANDLER MESSAGES
[Mon Sep  4 19:20:22 2006] action exited with status 255
[Mon Sep  4 19:20:22 2006] completed event "button/lid LID 00000080 000004b6"

Platform: Acer Travelmate 8104 WLMi running Gentoo linux kernel 2.6.16 or kernel 2.6.17.

Solution

Note: Solution found!.. I had to apply a custom DSDT. See How to apply a custom DSDT to fix continuous lid events.

Unfortunately I do not know of a solution to prevent the continuous lid events, other than completely disabling ACPI lid support. There are a couple of work-arounds that you can employ to be able to continue using ACPI for all events other than the lid event.

I have added details to the ACPI4Linux bug tracker, Bug 5852

1. The ati-drivers package

If you are getting 100% CPU usage and you are using the ati-drivers package, it could be due to the /etc/acpi/ati-powermode.sh action. Try removing the /etc/acpi/events/a-lid-aticonfig event and restarting acpid to see whether this makes a difference. It will not prevent the continuous lid events, so read on, but it could get rid of the 100% CPU usage.

2. The acpi_osi kernel parameter

Pass acpi_osi= as a boot option. This will turn off OSI, which apparently tells the BIOS to behave as if Windows is the OS. For example, the kernel line in my /boot/grub/grub.conf file is as follows:

kernel /boot/kernel root=/dev/sda8 acpi_osi=

This got rid of the 100% cpu problem for me. Continuous lid events were still written to /var/log/acpid but at least the cpu doesn't go nuts.

Unfortunately this parameter caused my wireless network card to stop working properly. lspci showed that I have an Intel Corporation PRO/Wireless 2915ABG Network Connection (rev 05), which I control using the ipw2200 module. The network service seemed to start correctly, but no network connection was created. Attempting to restart the service with /etc/init.d/net.eth1 restart failed with the message /sbin/wpa_supplicant already started. Killing wpa_supplicant with killall wpa_supplicant allows the service to be restarted and create a network connection (though an error message of bind(PF_UNIX): Address already in use is still received).

localhost steph # /etc/init.d/net.eth1 restart
 * Starting eth1
 *   Starting wpa_supplicant on eth1 ...
/sbin/wpa_supplicant already running.                                                                                      [ !! ]
localhost steph # killall wpa_supplicant
localhost steph # /etc/init.d/net.eth1 restart
 * Starting eth1
 *   Starting wpa_supplicant on eth1 ...
bind(PF_UNIX): Address already in use                                                                                      [ ok ]
 *   Starting wpa_cli on eth1 ...                                                                                          [ ok ]
 *     Backgrounding ...
localhost steph # 

3. Remove lid event scripts

Check every event script in /etc/acpi/events/ and remove any that will trigger an action on the lid event. Look for the event= line. If you'd rather not delete the file completely, you can comment out the action line to prevent it calling it's associated action script:

# /etc/acpi/events/lid
# Called when the user opens/closes the laptop lid
# 

event=button[ /]lid
#action=/etc/acpi/ati-powermode.sh

There will probably be other scripts that respond to all actions, in which case you'll have edit them and remove all functionality that will occur because of a lid event. For example, /etc/acpi/default.sh will respond to all actions and write a log message. To prevent this occuring when a lid event is triggered you have to comment out the line responsible for logging:

#!/bin/sh
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-power/acpid/files/acpid-1.0.4-default.sh,       v 1.1 2005/03/15 19:15:53 ciaranm Exp $

# Default acpi script that takes an entry for all actions

set $*

group=${1/\/*/}
action=${1/*\//}

case "$group" in
        button)
                case "$action" in
                        power)  /sbin/init 0
                                ;;
#                        *)      logger "ACPI action $action is not defined"
#                                ;;
                esac
                ;;

#       *)
#               logger "ACPI group $group / action $action is not defined"
#               ;;
esac

4. Disable ACPI lid support

You can also disable ACPI LID support completely. The following advice has been copied straight from widan's post on the Gentoo forums (Acer Travelmate 8100 continuous acpi events):

Something you can try (but I don't know if it will work, and it's only a workaround): open the file /usr/src/linux/drivers/acpi/button.c, and look for that line (it's around line 80):
Code:
.ids =      "ACPI_FPB,ACPI_FSB,PNP0C0D,PNP0C0C,PNP0C0E",
Replace it by that one:
Code:
.ids =      "ACPI_FPB,ACPI_FSB,PNP0C0C,PNP0C0E",
Recompile the kernel, install it, and reboot. Now the lid switch handling should be disabled (you can check it by verifying that the "ACPI: Lid Switch [LID]" line disappeared in dmesg).

Preventing acpid logging

If you used either of the first three methods, acpid will still write log messages to /var/log/acpid. When this file reaches 2G in size acpid will silently stop functioning. To prevent this, you will either need to set up logrotate to create new log files every time the 2G limit is reached, or you will need to prevent acpid logging.

I could not find a way of preventing acpid from writing to the log file, but you can get around it to some extent by passing -l /dev/null to the acpid command:

/usr/sbin/acpid -c /etc/acpi/events -l /dev/null

In the Gentoo /etc/init.d/acpid script, this is:

start-stop-daemon --start --exec /usr/sbin/acpid -- \
               -c /etc/acpi/events -l /dev/null

References

Last modified: 28/07/2008 Tags: (none)

This website is a personal resource. Nothing here is guaranteed correct or complete, so use at your own risk and try not to delete the Internet. -Stephan

Site Info

Privacy policy

Go to top