linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Mack <daniel@zonque.org>
To: Andy Lutomirski <luto@amacapital.net>,
	David Herrmann <dh.herrmann@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Andy Lutomirski <luto@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Djalal Harouni <tixxdz@opendz.org>,
	Greg KH <gregkh@linuxfoundation.org>,
	Havoc Pennington <havoc.pennington@gmail.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>,
	Tom Gundersen <teg@jklm.no>,
	"Kalle A. Sandstrom" <ksandstr@iki.fi>,
	Borislav Petkov <bp@alien8.de>, cee1 <fykcee1@gmail.com>
Subject: Re: kdbus: to merge or not to merge?
Date: Thu, 6 Aug 2015 09:06:17 +0200	[thread overview]
Message-ID: <55C30769.9090509@zonque.org> (raw)
In-Reply-To: <CALCETrW-Qr+ztJ1W40nqyj58CTgJic8z6KNWPx+Lztk=kkrUTQ@mail.gmail.com>

Hi Andy,

On 08/05/2015 02:18 AM, Andy Lutomirski wrote:
> I added the missing sd_bus_unref call.
> 
> With userspace dbus, my program takes 95% CPU and dbus-daemon takes
> 88% CPU or so.
> 
> With kdbus, I see abuse-bus (my test), systemd-journald,
> systemd-bus-proxy, auditd, gnome-shell, mission-control, sedispatch,
> firewalld, polkitd, NetworkManager, systemd, avahi-daemon, audisp,
> abrt-dump-jour* (whatever it's called -- it truncated), upowerd, and
> systemd-logind all taking tons of CPU.  I've listed them in decreasing
> order of amount of CPU burned -- the top several are taking about as
> much as is possible.  Load average is over 13.  That's if I run it
> from a text console while I'm logged in to gnome in a different VT.

That's right, I can reproduce this here. To explain what's going on, let
me provide some background.

Every time a client connects to kdbus, a new ID is assigned to the
connection, and other connections which have previously subscribed to
notifications of type KDBUS_ITEM_ID_ADD or _REMOVE get a notification
and are woken up so they can dispatch it. By default, no such matches
exists, applicaions have to explicitly opt-in if they are interested in
these events.

In DBus (both kdbus and DBus1), such matches are installed on the
NameOwnerChanged signal, and they can be either specific to a single ID,
or broad, which will make them match on any ID. There's actually no
reason for applications to install unspecific matches, but if they do,
they will of course get what they asked for, and are woken up on every
ID that is added to or removed from the bus. What you're seeing in your
system profile is that some applications misbehave and install
unspecific matches when they shouldn't. That's a userspace bug that
needs fixing. Two candidates were actually in the systemd code base
(logind and PID1), and both are now patched.

Note that these applications are actually affected on both DBus1 and
kdbus. The reason you didn't see them trip up in your test is that
sd_bus_open() behaves differently in the two worlds. In kdbus, it will
immediately call into the kernel and register a new connection, hence
triggering the behavior described above. On DBus1, however, the HELLO
message will not be transmitted to the daemon until the first message is
sent, so no ID is assigned, and no notifications are sent. When
augmenting the test program a little so it reads its own ID on the bus,
you'll see similar behavior on DBus1 as well, but the bottleneck in this
case is the daemon, which significantly mitigates the load caused by
other tasks.

So, to wrap it up: you've triggered an existing userspace bug. The
userspace components under our control have now been fixed, and we'll
talk to other people to make them aware of the issue too. However, these
issues are not directly related to kdbus, but rather show more impact as
a side-effect now.

You've raised a valid point here. Thanks a lot for providing this test,
much appreciated!


Daniel


  reply	other threads:[~2015-08-06  7:06 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-23  6:06 kdbus: to merge or not to merge? Andy Lutomirski
2015-06-23  6:31 ` Andy Lutomirski
2015-06-23  6:41 ` Greg KH
2015-06-23  7:22   ` Richard Weinberger
2015-06-23  9:25     ` Martin Steigerwald
2015-06-23  9:38       ` Martin Steigerwald
2015-06-23 15:07     ` Andy Lutomirski
2015-06-25  2:14       ` Steven Rostedt
2015-06-25  2:20         ` Linus Torvalds
2015-06-25  6:01           ` Martin Steigerwald
2015-06-25  6:05             ` Martin Steigerwald
2015-06-25 13:34               ` Theodore Ts'o
2015-06-25 14:03                 ` Martin Steigerwald
2015-06-23  9:12   ` Borislav Petkov
2015-07-08 13:54   ` Pavel Machek
2015-07-09  8:39     ` Geert Uytterhoeven
2015-07-09 10:29       ` Joe Perches
2015-07-09 10:57         ` Geert Uytterhoeven
2015-07-09 11:36       ` Pavel Machek
2015-06-23 23:19 ` Linus Torvalds
2015-06-24  0:52   ` Andy Lutomirski
2015-06-24  8:05   ` Ingo Molnar
2015-06-24 10:41     ` Eric W. Biederman
2015-06-24 10:46     ` Martin Steigerwald
2015-06-24 13:18       ` Ingo Molnar
2015-06-24 17:39         ` David Lang
2015-06-24 18:41           ` Eric W. Biederman
2015-06-24 18:50           ` Martin Steigerwald
2015-06-24 19:12             ` David Lang
2015-06-25  7:57               ` Geert Uytterhoeven
2015-06-25 15:26                 ` Steven Rostedt
2015-06-25  6:31           ` Greg KH
2015-06-25  6:48             ` David Lang
2015-06-25  7:47           ` Ingo Molnar
2015-06-25  7:51             ` Ingo Molnar
2015-06-24 11:43     ` Martin Steigerwald
2015-06-24 13:27       ` Ingo Molnar
2015-06-24  9:55 ` Alexander Larsson
2015-06-24 14:38   ` Andy Lutomirski
     [not found]     ` <CAHr-LrYWNwv6_YLoP-B3duQ1QsjPiTiaEnjBQ7j2brPMeTgA3A@mail.gmail.com>
     [not found]       ` <CALCETrW3F6YP_H1oRJa47f1DT7B35OubhJYSnq0U-_GmFQHNOA@mail.gmail.com>
2015-06-24 17:11         ` Alexander Larsson
2015-06-24 19:43           ` Andy Lutomirski
2015-06-24 20:45             ` Alexander Larsson
2015-08-03 23:02 ` Andy Lutomirski
2015-08-04  8:58   ` David Herrmann
2015-08-04 13:46     ` Linus Torvalds
2015-08-04 14:09       ` David Herrmann
2015-08-04 14:47         ` Andy Lutomirski
2015-08-05  0:18           ` Andy Lutomirski
2015-08-06  7:06             ` Daniel Mack [this message]
2015-08-06 15:27               ` Andy Lutomirski
2015-08-06 17:24                 ` Daniel Mack
2015-08-05  7:10           ` David Herrmann
2015-08-05 20:11             ` Andy Lutomirski
2015-08-06  8:04               ` David Herrmann
2015-08-06  8:25                 ` Martin Steigerwald
2015-08-06 15:21                 ` Andy Lutomirski
2015-08-06 18:14                   ` Daniel Mack
2015-08-06 18:43                     ` Andy Lutomirski
2015-08-07 14:40                       ` Daniel Mack
2015-08-07 15:09                         ` Andy Lutomirski
     [not found]                         ` <CA+55aFxDLt-5+=xXeYG4nJKMb8L_iD9FmwTZ2VuughBku-mW3g@mail.gmail.com>
2015-08-09 19:00                           ` Greg Kroah-Hartman
2015-08-09 22:11                             ` Daniel Mack
2015-08-10  2:10                               ` Andy Lutomirski
2015-08-10 17:04                               ` Linus Torvalds
2015-08-10  2:48                             ` David Lang
2015-08-07 15:37                       ` cee1
  -- strict thread matches above, loose matches on Subject: below --
2015-07-01  0:03 Kalle A. Sandstrom
2015-07-01 16:51 ` David Herrmann
2015-07-06 21:18   ` Kalle A. Sandstrom

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55C30769.9090509@zonque.org \
    --to=daniel@zonque.org \
    --cc=bp@alien8.de \
    --cc=dh.herrmann@gmail.com \
    --cc=ebiederm@xmission.com \
    --cc=fykcee1@gmail.com \
    --cc=gnomes@lxorguk.ukuu.org.uk \
    --cc=gregkh@linuxfoundation.org \
    --cc=havoc.pennington@gmail.com \
    --cc=ksandstr@iki.fi \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=luto@kernel.org \
    --cc=teg@jklm.no \
    --cc=tixxdz@opendz.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).