Bug 133440 - acpid not starting on X due to race with X?
Summary: acpid not starting on X due to race with X?
Status: RESOLVED FIXED
: 131506 (view as bug list)
Alias: None
Product: SUSE Linux 10.1
Classification: openSUSE
Component: X.Org (show other bugs)
Version: unspecified
Hardware: Other Other
: P2 - High : Normal (vote)
Target Milestone: ---
Assignee: Stephan Kulow
QA Contact: Andreas Jaeger
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-11 12:05 UTC by Stefan Behlert
Modified: 2006-01-24 23:06 UTC (History)
6 users (show)

See Also:
Found By: Other
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
disables ACPI code (754 bytes, patch)
2005-11-18 11:25 UTC, Stefan Dirsch
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Behlert 2005-11-11 12:05:15 UTC
Installed 10.0RC4, updated to STABLE.
Now both powersaved and acpid are no longer starting because of:
# lsof|grep acpi
kacpid      16       root  cwd       DIR        8,5     688          2 /
kacpid      16       root  rtd       DIR        8,5     688          2 /
kacpid      16       root  txt   unknown                               /proc/16/exe
X         4299       root    4r      REG        0,3       0 4026532110 /proc/acpi/event
hald-addo 5181       root  txt       REG        8,5    7080      82162 /usr/sbin/hald-addon-acpi

# ps -edlaf |grep 4299
4 S root      4299  4297  0  76   0 -  4956 -      12:55 tty7     00:00:01 /usr/X11R6/bin/X
Machine is a dual-core, SATA-having machine.
Comment 1 Holger Macht 2005-11-11 12:25:31 UTC
What's X doing with the acpi event interface? We need acpid as multiplexer for powersave, hal and ial. We came to an agreement with the maintainers of those applications that no application will 'catch' the event interface itself and everybody has to use acpid as multiplexer.
Comment 2 Danny Al-Gaaf 2005-11-11 18:18:41 UTC
This is IMO a race and a result of new code in the X-server:

==========================================
2005-08-22 Alan Hourihane <alanh@fairlite.demon.co.uk>
        * programs/Xserver/hw/xfree86/os-support/linux/lnx_acpi.c
        * programs/Xserver/hw/xfree86/os-support/linux/lnx_apm.c
        * programs/Xserver/hw/xfree86/os-support/linux/Imakefile
        Add basic ACPI Linux support so that events can be passed to the driver.
        (Alan Hourihane)

2005-10-31  Kevin E. Martin  <kem-at-freedesktop-dot-org>

        * programs/Xserver/hw/xfree86/os-support/linux/lnx_acpi.c:
        (lnxACPIOpen), (lnxCloseACPI):
        Fix fd leak by closing them in the ACPI code instead of just using
        shutdown
==========================================

This need to be fixed. The X-Server never should try (as all other programms) to accec the kernel acpi interface directly. I acpid not available, retry to connect later in a loop.
Comment 3 Stefan Dirsch 2005-11-15 22:30:40 UTC
*** Bug 131506 has been marked as a duplicate of this bug. ***
Comment 4 Andreas Jaeger 2005-11-17 20:27:14 UTC
How do you plan to fix this?
Comment 5 Stefan Dirsch 2005-11-17 22:09:40 UTC
I need to discuss this will Egbert/Matthias next week, since both are absent tomorrow.
Comment 6 Stefan Dirsch 2005-11-17 22:30:43 UTC
BTW, it's an already knwon problem.

https://bugs.freedesktop.org/show_bug.cgi?id=4718
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=169766
Comment 7 Stefan Dirsch 2005-11-18 11:25:34 UTC
Created attachment 57714 [details]
disables ACPI code

I'll disable ACPI code for now.
Comment 8 Stefan Dirsch 2005-11-18 14:49:52 UTC
Use

  Option "NoPM" "on"

in 'Section "ServerLayout"' of /etc/X11/xorg.conf as workaround for now. But this disables APM as well!
Comment 9 Stefan Dirsch 2005-11-18 15:01:00 UTC
Could someone please check that the new Xserver no longer touches /proc/acpi/event?

/work/built/mbuild/shannon-sndirsch-6/i386/xorg-x11-server-6.9rc2-4.i586.rpm
/work/built/mbuild/shannon-sndirsch-6/x86_64/xorg-x11-server-6.9rc2-4.x86_64.rpm
Comment 10 Stefan Dirsch 2005-11-21 11:17:39 UTC
Sorry, I accidently removed the mbuild builds, but it's already in STABLE, so simply use the RPMs from STABLE.
Comment 11 Stefan Behlert 2005-11-22 08:28:41 UTC
Ok, will test today.
Comment 12 Stefan Behlert 2005-11-22 13:08:59 UTC
Tested on two machines, after various boots everytime everything worked as expected. So I say - fixed.
Comment 13 Stefan Dirsch 2005-11-22 13:15:44 UTC
Sorry, but this is a workaround by disabling new ACPI code completely.
Comment 14 Stefan Dirsch 2005-11-22 13:17:42 UTC
Is there any sample code available for using acpid?
Comment 15 Timo Hoenig 2005-11-22 13:20:19 UTC
Have a look at 

./hald/linux2/addons/addon-acpi.c

of HAL.

Comment 16 Stefan Dirsch 2005-11-22 13:43:36 UTC
Thanks. Looks like the code already exists, but the Xserver uses the acpi event interface, because acpid is not running yet.

[...]
    if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) > -1) {
        memset(&addr, 0, sizeof(addr));
        addr.sun_family = AF_UNIX;
        strcpy(addr.sun_path, ACPI_SOCKET);
        if ((r = connect(fd, (struct sockaddr*)&addr, sizeof(addr))) == -1) {
            shutdown(fd, 2);
            close(fd);
            fd = -1;
        }
    }

    /* acpid's socket isn't available, so try going direct */
    if (fd == -1) {
        if ((fd = open(ACPI_EVENTS, O_RDONLY)) < 0) {
            xf86MsgVerb(X_WARNING,3,"Open ACPI failed (%s) (%s)\n", ACPI_EVENTS,
                strerror(errno));
            return NULL;
        }
    }
[...]

Couldn't we make sure that acpid is started before the Xserver?
Comment 17 Timo Hoenig 2005-11-22 13:49:27 UTC
Yes. For 10.1 we really should push acpid and friends (hal) to the front of our boot process.  We have some orphan (?) dependency on $remote_fs in the acpid start script.
Comment 18 Timo Hoenig 2005-11-22 13:55:20 UTC
(In reply to comment #16)
> Thanks. Looks like the code already exists, but the Xserver uses the acpi event interface, because acpid is not running yet.

Could you please consider removing the fallback?  All of our packages depending on acpi events have agreed not to fall back and hence not to access the kernel interface directly.

For situations where acpid gets restarted (update, manual restart) it might be sane to poll for the acpid socket until its back.
Comment 19 Stefan Dirsch 2005-11-22 14:02:46 UTC
> Could you please consider removing the fallback?  All of our packages 
> depending on acpi events have agreed not to fall back and hence not to 
> access >the kernel interface directly.

I'll do so.

> Yes. For 10.1 we really should push acpid and friends (hal) to the front of > our boot process.  We have some orphan (?) dependency on $remote_fs in the 
> acpid start script.

Coolo should know best, which init script this exactly is. Probably xdm and earlygdm/earlykdm !?! Coolo?
Comment 20 Timo Hoenig 2005-11-22 14:08:50 UTC
Meanwhile I dropped 'should-start $remote_fs' from rcacpid and submitted an updated acpid package.
Comment 21 Stephan Kulow 2005-11-22 14:39:20 UTC
That acpid package is broken then. acpid is in /usr - as such in $remote_fs 

earlygdm/earlykdm need a should-start acpid then I guess, but only if acpid can be really started early and from /
Comment 22 Timo Hoenig 2005-11-22 14:41:48 UTC
I don't see any reason why this should not work.
Comment 23 Forgotten User ZhJd0F0L3x 2005-11-22 16:01:15 UTC
because /usr/ might not be available before network is up.

Am i allowed to install acpid to /sbin/? If yes, we can solve this properly.

Beware that acpid will need syslog in the not-too-distant future, though.
Comment 24 Stefan Dirsch 2005-11-22 16:10:30 UTC
New xorg-x11 package submitted.

Tue Nov 22 15:15:07 CET 2005 - sndirsch@suse.de
- ps_acpi.diff (obsoletes p_disable-acpi.diff):
  * disable fallback to proc acpi event interface (#133440)

Assigning to coolo to adjust earlykdm. Needs to be reassigned to gnome-maintainers@suse.de to adjust earlygdm afterwards.
Comment 25 Stephan Kulow 2005-11-22 16:15:40 UTC
#23: acpid will have to attach syslog when it's ready then. I won't accept an init script that relies on syslog and is before X startup.
Comment 26 Egbert Eich 2005-11-29 18:21:05 UTC
I will look at fixing the ACPI code in X.
Please reassing to me once other issues got ironed out.
Comment 27 Stefan Dirsch 2005-11-29 18:29:27 UTC
Egbert, what do you want to fix in ACPI code exactly? Is it supposed to be broken?

The bugreport is about accessing the proc acpi event interface directly instead of using acpid. I fixed this by removing this fallback, which is our policy. The problem is, that the Xserver is started before acpid. This needs to be fixed by the KDM and Gnome maintainers in earlygdm/earlykdm init scripts.
Comment 28 Forgotten User ZhJd0F0L3x 2005-11-29 20:13:52 UTC
i also fixed the acpid package to no longer need $remote_fs, so it should start pretty early, almost before everything else, so this is no longer really urgent, just check that it does not fall back to /proc/acpi/event if acpid ist restarted but instead reconnects to the socket.
Comment 29 Stefan Dirsch 2006-01-24 23:06:44 UTC
I think we can close this now.