Xorg hangs use 99% of CPU on systemd reboot

Barry Scott barry.scott at onelan.co.uk
Thu Jul 16 02:21:32 PDT 2015


Opss pressed send not save...

On Wed 15 Jul 2015 13:35:28 Peter Hutterer wrote:
> On Mon, Jul 13, 2015 at 05:18:54PM +0100, Barry Scott wrote:
> > On Fri 03 Jul 2015 16:14:13 Peter Hutterer wrote:
> > > On Thu, Jul 02, 2015 at 04:26:19PM +0100, Barry Scott wrote:
> > > > The attached patch works around an issue we hit after we
> > > > ported from Fedora 20 to Fedora 21.
> > > > 
> > > > When systemd reboot starts something happens to dbus that
> > > > causes Xorg to loop hard using 99% CPU in WaitForSomething.
> > > > 
> > > > The reason for the loop is that the bus_info.fd in dbus-core.c
> > > > has been closed. But the expected Disconnected signal is not
> > > > received by the messages filter.
> > > 
> > > wouldn't it be better to set up the filter so we get the disconnect
> > > signal?
> > 
> > The dbus ping example does not add a filter to see Disconnected.
> > https://github.com/sgh/dbus-examples/blob/master/dbus-ping-listen.c
> 
> looking at config/dbus-core.c, there's message_filter which has the handling
> for the disconnect signal. and the dbus doc says it's always sent. so the
> question is now: did you put printfs into message_filter() to verify that
> the signal never arrives?

The attached dbus-core-logging.patch shows the instrumentation I was using.
You can patch that on top of the proposed fix. I used other logging to show the 
contents of the fd_set's to find that the dbus FD was the problem FD.

> 
> I also notice that message_filter partially shuts down stuff, but it leaves
> bus_info.fd in the select set even though as I understand this is closed
> now. so it seem the RemoveGeneralSocket() and info->fd = -1; call should go
> into message_filter.

The call to teardown() does the necessary cleanup and was the original code.


Barry

> 
> Cheers,
>    Peter
> 
> > > > The patch works around this issue by removing the fd from the
> > > > fd_set that is feed into the Select in WaitForSomething by
> > > > calling RemoveGeneralSocket from within wakeup_handler in
> > > > dbus-core.c.
> > > > 
> > > > When systemctl is used to stop and restart Xorg outside of the
> > > > reboot it works without any problems.
> > > > 
> > > > Barry
> > > > 
> > > > 
> > > > From ca770dd6e8ebb9a780ce68a07535f976f6120247 Mon Sep 17 00:00:00 
2001
> > > > From: Barry Scott <barry.scott at onelan.co.uk>
> > > > Date: Tue, 30 Jun 2015 15:58:22 +0100
> > > > Subject: [PATCH] server loops in WaitForSomething when dbus closed by
> > > > systemd>
> > > > 
> > > >  shutdown
> > > > 
> > > > Work around issue with dbus fd becoming closed by WaitForSomething
> > > > still using it in Select. The Select return EBADF but becuase the dbus
> > > > fd
> > > > is not taken out of the fs_set the code loop forever.
> > > > 
> > > > This state has been seen when systemd starts to shutdown on Fedora 21.
> > > > 
> > > > Signed-off-by: Barry Scott <barry.scott at onelan.co.uk>
> > > > ---
> > > > 
> > > >  config/dbus-core.c | 13 +++++++++++++
> > > >  1 file changed, 13 insertions(+)
> > > > 
> > > > diff --git a/config/dbus-core.c b/config/dbus-core.c
> > > > index 8351ea4..fac8116 100644
> > > > --- a/config/dbus-core.c
> > > > +++ b/config/dbus-core.c
> > > > @@ -52,6 +52,19 @@ wakeup_handler(void *data, int num_fds, void
> > > > *read_mask)
> > > > 
> > > >  {
> > > >  
> > > >      struct dbus_core_info *info = data;
> > > > 
> > > > +    if (info->fd < 0) {
> > > > +        return;
> > > > +    }
> > > > +
> > > > +    if (!dbus_connection_get_is_connected(info->connection)) {
> > > > +        /* must remove the FD here as WaitForSomething's Select will
> > > > now
> > > > fail +           and WaitForSomething will loop hard calling Select.
> > > > +           The "Disconnected" message has been seen to not arrive. */
> > > > +        RemoveGeneralSocket(info->fd);
> > > > +        info->fd = -1;
> > > > +        return;
> > > > +    }
> > > > +
> > > > 
> > > >      if (info->connection && num_fds > 0 && FD_ISSET(info->fd, (fd_set
> > > >      *)
> > > >      read_mask)) {>
> > > >      
> > > >          do {
> > > >          
> > > >              dbus_connection_read_write_dispatch(info->connection, 0);
> > > > 
> > > > _______________________________________________
> > > > xorg-devel at lists.x.org: X.Org development
> > > > Archives: http://lists.x.org/archives/xorg-devel
> > > > Info: http://lists.x.org/mailman/listinfo/xorg-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.x.org/archives/xorg-devel/attachments/20150716/188000fc/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dbus-core-logging.patch
Type: text/x-patch
Size: 4378 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-devel/attachments/20150716/188000fc/attachment-0001.bin>


More information about the xorg-devel mailing list