|
|
Subscribe / Log in / New account

The unveiling of kdbus

By Jonathan Corbet
January 13, 2014

linux.conf.au 2014
Sporting an "Open Source Tea Party" T-shirt, Lennart Poettering used his linux.conf.au talk to introduce an effort that he and several others have been working on for the better part of the last year: reimplementing the D-Bus mechanism within the kernel. The result, should it make it through the review process, will equip Linux with a proper native interprocess communication mechanism for, Lennart said, the first time ever.

The good and bad of D-Bus

Unlike most other kernels, Linux has never had a well-designed IPC mechanism. Windows and Mac OS have this feature; even Android, based on Linux, has one in the form of the "binder" subsystem. Linux, instead, has only had the primitives — sockets, FIFOs, and shared memory — but those have never been knitted together into a reasonable application-level API. Kdbus is an attempt to do that knitting and create something that is at least as good as the mechanisms found on other systems.

Linux does have D-Bus, which he said, is a powerful IPC system; it is the closest thing to a standard in this area as can be found on Linux. Lennart put up an extensive list of advantages to using D-Bus. It provides a nice method-call transaction mechanism (allowing for sending a message and getting a response) and a means for sending "signals" (notifications) to the rest of the system. There is a discovery mechanism to see what else is running on the bus and the introspection facilities needed to learn about [Lennart
Poettering] what services are offered. D-Bus includes a mechanism for the enforcement of security policies, a way of starting services when they are first used, type-safe marshaling of data structures, and passing of credentials and file descriptors over the bus. There are bindings for a wide range of languages and network transparency as well.

On the other hand, D-Bus also suffers from a number of limitations. It is well suited to control tasks, but less so for anything that has to carry significant amounts of data. So, for example, D-Bus works well to tell a sound server to change the volume, but one would not want to try to send the actual audio data over the bus. The problem here is the fundamental inefficiencies of the user-space D-Bus implementation; a call-return message requires ten message copies, four message validations, and four context switches — not the way to get good performance. Beyond that, credential passing is limited, there are no timestamps on messages, D-Bus is not available at early boot, connections to security frameworks (e.g. SELinux) must happen in user space, and there are race conditions around the activation of services. D-Bus also suffers from what Lennart described as a "baroque code base" and heavy use of XML.

Even so, Lennart said, D-Bus is "fantastic" and it solves a number of real problems. Ten years of use have shown that the core design is sound. It is also well established and widely used. So the right thing to do is not to replace D-Bus, but to come up with a better implementation.

Into the kernel

That implementation is kdbus, an in-kernel implementation of D-Bus. This implementation is able to carry large amounts of data; it can be reasonably used for gigabyte-sized message streams. It can perform zero-copy message passing, but even in the worst case, a message and its response are passed with no more than two copy operations, two validations, and two context switches. Full credential information (user ID, process ID, SELinux label, control group information, capabilities, and much more) is passed with each message, and all messages carry timestamps. Kdbus is always available to the system (no need to wait for the D-Bus daemon to be started), Linux security modules can hook into it directly, various race conditions have been fixed, and the API has simplified.

Kdbus is implemented as a character device in the kernel; processes wishing to join the bus open the device, then call mmap() to map a message-passing area into their address space. Messages are assembled in this area then handed to the kernel for transport; it is a simple matter for the kernel to copy the message from one process's mapped area to another process's area. Messages can include timeouts ("method call windows") by which a reply must be received. There is a name registry that is quite similar to the traditional D-Bus registry.

The "memfd" mechanism enables zero-copy message passing in kdbus. A memfd is simply a region of memory with a file descriptor attached to it; it operates similarly to a memory-mapped temporary file, "but also very differently." A memfd can be "sealed," after which the owning process can no longer change its contents. A process wishing to send a message will build it in the memfd area, seal it, then pass it to kdbus for transport. Depending on the size of the message, the relevant pages may just be mapped into the receiving process's address space, avoiding a copy of the data. But the break-even point is larger than one might expect; Lennart said that it works better to simply copy anything that is less than about 512KB. Below that size, the memory-mapping overhead exceeds the savings from not copying the data.

Memfds can be reused at will. A process that needs to repeatedly play the same sound can seal the sample data into a memfd once and send it to the audio server whenever it needs to be played. All told, Lennart said, memfds work a lot like the Android "ashmem" subsystem.

The signal broadcasting mechanism has been rewritten to use Bloom filters to select recipients. A Bloom filter uses a hash to allow the quick elimination of many candidate recipients, making the broadcast mechanism relatively efficient.

There is a user-space proxy server that can be used by older code that has not been rewritten to use the new API, so everything should just work on a kdbus-enabled system with no code changes required.

When will this code make its appearance? It has been announced on the D-Bus mailing list, and the code is available in the relevant repositories now. The main thing that is missing at the moment is the policy enforcement mechanism. Everything will work, Lennart said, if one doesn't mind that it will all be "horribly insecure." The plan is to get the code merged into the mainline kernel sometime in 2014. He is optimistic that this will work out; having Greg Kroah-Hartman involved in the process helps with his confidence there. But Lennart noted that two previous attempts to get D-Bus functionality into the kernel have failed, so there are no guarantees. Stay tuned over the course of the next year to see how it goes.

See kdbus.txt in the kernel-side source repository for more information on the design of kdbus.

[Your editor would like to thank linux.conf.au for funding his travel to Perth].

Index entries for this article
Kernelkdbus
KernelMessage passing
Conferencelinux.conf.au/2014


to post comments

The unveiling of kdbus

Posted Jan 13, 2014 21:50 UTC (Mon) by cyperpunks (subscriber, #39406) [Link] (10 responses)

This can be merged in kernel after the 237 systemd bugs in Fedora[1] are fixed.

[1]: https://bugzilla.redhat.com/buglist.cgi?bug_status=NEW&...

The unveiling of kdbus

Posted Jan 13, 2014 22:04 UTC (Mon) by rahulsundaram (subscriber, #21946) [Link] (1 responses)

Upstream kernel features aren't gated by bug fixes within a single component in any distribution. New features are done in parallel to bug fixes especially when there is no interrelationship between them. Also your query includes both Fedora and RHEL and lists a large number of RFE's as opposed to just bug fixes.

The unveiling of kdbus

Posted Jan 13, 2014 22:10 UTC (Mon) by alexl (subscriber, #19068) [Link]

Just add a kdbus RFE and we're golden.

The unveiling of kdbus

Posted Jan 13, 2014 22:32 UTC (Mon) by ovitters (guest, #27950) [Link] (2 responses)

Every software has bugs. Unreasonable expectations or requests will probably be ignored. Meaning, it'll be merged even though systemd has bugs. Also note that kdbus is not tied to systemd. You'd know this by watching the presentation…

Or in other words: you're wrong.

The unveiling of kdbus

Posted Jan 14, 2014 21:05 UTC (Tue) by marcH (subscriber, #57642) [Link] (1 responses)

> Or in other words: you're wrong.

You are assuming you understood something.

The unveiling of kdbus

Posted Jan 15, 2014 0:22 UTC (Wed) by ovitters (guest, #27950) [Link]

So? You're not explaining anything, yet try to show off that I am wrong. Further, just focussing on one small part of my post. Unable to explain properly?

The unveiling of kdbus

Posted Jan 14, 2014 2:56 UTC (Tue) by mezcalero (subscriber, #45103) [Link] (3 responses)

Well get to those systemd bugs right after fixing all those unfixed kernel bugs:

https://bugzilla.kernel.org/buglist.cgi?bug_status=NEW&...

Unfortunately I cannot tell you how many those are, because my browser choked on the immense number of them...

;-)

The unveiling of kdbus

Posted Jan 17, 2014 1:13 UTC (Fri) by deepfire (guest, #26138) [Link] (2 responses)

More seriously, though -- what's the portion of "systemd bugs, that actually are kernel bugs"?

I'm asking because 237 bugs is a lot for a Core OS, well, core component.

Yes, I realise that systemd is still under heavy development, but it's also extremely widely deployed and these bugs probably bite a lot of people -- so that I don't feel you can just shrug off the implications..

The unveiling of kdbus

Posted Jan 17, 2014 4:52 UTC (Fri) by rahulsundaram (subscriber, #21946) [Link]

1) compared to the number of bugs in any core component, systemd is on par with it or better (compare kernel, glibc etc)

2) it is not 237 bugs as I have already pointed out earlier. Many of them are requests for enhancements, several unconfirmed issues, several cloned bugs, several tracker bugs etc.

The unveiling of kdbus

Posted Jan 17, 2014 4:56 UTC (Fri) by mathstuf (subscriber, #69389) [Link]

Let's do some data mining. Right now there are 234 bugs[1]. Of these, 34 are RFE's (6 assigned, 1 "post"[2], the rest "new"), 6 are tracking bugs (one tracks problems with "known problems but unknown solutions" of which there seem to be 3 and one of those is an RFE(‽)), 2 contain patches (one "post"). That leaves us with 190 bugs.

I see 16 in the QA pipeline and 5 "post", so presumably these are fixed, just not in Fedora (stable) yet (down to 169). Maybe a third have substantial discussion (10+ comments), so I'll assume they're on their way.

That's still a lot and I'm just going to skim it for bugs that probably[3] don't belong (not many; maybe 10%): scan-build errors (#1047009; no report offered, just asking devs to use it since they found a lot), some probable RFEs (#1054473, #1054348), bash-completion-related bugs (#1024379), things that look harmless for actual usage (#1047148, #1008188), one pulseaudio-related (#928513), tmpfs-on-/tmp (#1028155), and some others. I also see duplicate bugs for journal-related problems (slowness when the logs get large, missing logs for some services) and packaging errors (#907719).

I'd guess there are maybe ~75 (reported) bugs with the systemd *package*, a handful of which are serious without much discussion about them (not sure if it's a bunch of "me too" or real discussion though). Does that sound better?

[1]https://admin.fedoraproject.org/pkgdb/acls/bugs/systemd
[2]Seems to mean "committed upstream"; not in Fedora (yet?).
[3]Just going by the summary for the most part.

The unveiling of kdbus

Posted Jan 14, 2014 10:48 UTC (Tue) by johannbg (guest, #65743) [Link]

I have not gotten to do the ususal cleanup of reports against systemd in Fedora hence the higher number then usual I've just been busy with $dayjob.

We have had on average 50 bugs filed against systemd per Fedora release cycle.

With the trend of reports being one third RFE's, one third has been misfiled and one third been actual bugs.

As per maintenance policy those bugs *always* get fixed upstream then Michal or Zbyszek decide if and then to which GA releases those fixes will be backported to.

I'm hoping we get to the point where we can adapt rebase policy align with the kernel as well as adapting the bug handling Justin has been working on in the kernel sub-community which seems to be working afaikt.

If and when we get there you should see bugs in the number of <10 against systemd if any et all.

memfds

Posted Jan 13, 2014 22:00 UTC (Mon) by tau (subscriber, #79651) [Link] (35 responses)

The memfd functionality looks interesting in its own right, but as I understand it's currently tied to kdbus somehow (I think you have to perform an ioctl on a kdbus fd to allocate a memfd? I might be mistaken).

Are there any plans to break this functionality out so that it can exist independently of kdbus for things like Wayland or mainlined Android? AFAIK the current state of the art here is to securely create a temporary filename in /dev/shm and then unlink it after opening (or do some hack with procfs to anonymously create a fd charged to the /dev/shm filesystem), then mmap that and pass the fd. However, tmpfs files don't have any facility like memfd sealing. It seems that this primitive may have applications in a number of other areas.

memfds

Posted Jan 13, 2014 22:22 UTC (Mon) by wahern (subscriber, #37304) [Link] (4 responses)

There already exists vmsplice(2). I wonder why they didn't use this.

The problem with vmsplice, and presumably memfd, is that you can't easily reuse that memory. Which means you can only use it for a fixed number of objects throughout the process lifetime.

It would be nice if a lot of the new code is composable and can be used to accelerate things not related to D-Bus. If not, then it's a real shame, and a sign that Linux is being taken down the path of Windows and OS X, in terms of short-sighted, niche, "fad" APIs.

memfds

Posted Jan 14, 2014 3:05 UTC (Tue) by mezcalero (subscriber, #45103) [Link] (2 responses)

Here's a hint why we didn't use vmsplice(): because it's something completely different.

vmsplice() splices pages to a fifo, but there isn't a way to get the pages out of it without copying them. The stuff is also note reusable. You cannot mmap a fifo... and so on and so on.

An unlinked file in tmpfs is certainly much closer to the memfd concept than vmsplice() is. However the sealing concept it lacks, which is the major limiting factor making it unusable as a transport for D-Bus without requiring copying on the receiving side.

Lennart

memfds

Posted Jan 15, 2014 17:41 UTC (Wed) by TD-Linux (guest, #92557) [Link]

This reminds me a lot of the kernel DMA API, specifically the streamable part - once mapping a streamable DMA buffer, you can't (safely) change the contents as the process of mapping it flushes the appropriate cache lines.

I'm currently writing a driver that basically exposes regions of memory to userspace, and the ioctl() controls mapping/unmapping (just like sealing memfds).

Because both memfds and streamable DMA buffers basically appear the same from userspace, maybe a standard API could be used to support both?

memfds

Posted Jan 16, 2014 15:53 UTC (Thu) by bcrl (guest, #5934) [Link]

Why not just add support for immutable files on tmpfs rather than creating a whole new chunk of code for doing the same thing? Mark a tmpfs file as immutable and you have your "sealing" functionality. The ABI already exists, it reuses tmpfs code rather than recreating yet another chunk of code that needs to be maintained, and it's a relatively minor change to make.

memfds

Posted Jan 14, 2014 3:48 UTC (Tue) by vrfy (guest, #13362) [Link]

Memfds are more about *sharing* and not only *gifting* memory regions. The sealing functionality provides a facility to safely share things, vmsplice cannnot provide anything like that.

memfds

Posted Jan 13, 2014 22:25 UTC (Mon) by alogghe (subscriber, #6661) [Link] (29 responses)

What's real advantage to "breaking it out"?

Part of the point of (k)dbus is for applications to not reinvent the wheel with all the the other bits and pieces they will inevitably need.

memfds

Posted Jan 13, 2014 22:50 UTC (Mon) by wahern (subscriber, #37304) [Link] (28 responses)

<snark>
Which is why we have HTTP, and no other way for applications to manipulate TCP/IP sockets, because that would be reinventing the wheel.
</snark>

Once upon a time Linus would frown on these sorts of single-use interfaces. He tended to prefer focusing on making other primitives more performant so that you could compose more complex interfaces in userspace. And for the kernel that's an excellent rule of thumb.

Remember the HTTP server wars? Microsoft had a blazing fast HTTP server in-kernel. So somebody coded one up in the Linux kernel, to one up Microsoft. But then somebody with infinitely more sense tweaked some kernel APIs and wrote an HTTP server in user-space that bested both the in-kernel servers.

memfds

Posted Jan 13, 2014 23:12 UTC (Mon) by alogghe (subscriber, #6661) [Link] (21 responses)

This is fast ipc with a variety of primitives for any application running in Linux, I don't see where you get "single use".

The reasoning for having some parts of dbus in the kernel are quite sound (good presentation from Lennart).

memfds

Posted Jan 14, 2014 0:35 UTC (Tue) by wahern (subscriber, #37304) [Link] (20 responses)

I can't find Lennart's presentation, but I found one from May of last year at github.com/gregkh/presentation-kdbus

If AF_BUS was rejected, what was changed to make something like this more amendable for inclusion?

If there are "no blocking calls", what happens when you hit a kernel memory limit? Or is it simply the case that all I/O operations behave as-if O_NONBLOCK is set.

I understand that, fundamentally, you need kernel cooperation for performant (low-latency, low-power, high-throughput, etc) broadcast messaging. You don't necessarily need a complex naming schema in kernel, but that's kind of a grey area.

AF_DBUS

Posted Jan 14, 2014 0:54 UTC (Tue) by corbet (editor, #1) [Link] (18 responses)

With regard to AF_DBUS, they have addressed that problem by avoiding the network stack altogether. The functionality is fully contained within a char device now.

AF_DBUS

Posted Jan 14, 2014 1:19 UTC (Tue) by Cyberax (✭ supporter ✭, #52523) [Link] (17 responses)

Which is funny and is probably a good lesson for kernel subsystem maintainers, because a multicast AF_UNIX sockets would have been a really nice idea in general.

AF_DBUS

Posted Jan 14, 2014 8:56 UTC (Tue) by edeloget (subscriber, #88392) [Link] (16 responses)

I tend to agree.

Having something the size of kdbus with some kind of fixed guidelines on how to use it is IMHO a bad idea. There are situations where you want to devise your own protocol (i.e. while I always thought kdbus was a good idea, I also always thought that it would be socket-based and lightweight).

A multicast AF_UNIX socket makes more sense (possibly with something like memfd, which sounds quite interesting and would deserve a user space API on its own). Once you have both, implementing dbus in userspace is far less tricky and the resulting code should be both faster and cleaner.

Putting the dbus daemon and its complexity into the kernel is IMHO a bad idea (seriously: this kdbus moduledoes too many things).

AF_DBUS

Posted Jan 14, 2014 10:23 UTC (Tue) by smurf (subscriber, #17840) [Link] (13 responses)

The point is: some people want a way for processes to talk to each other that's (a) fast (zero-copy if at all possible), (b) secure, (c) behaves mostly like dbus -- including its introspective and data marshalling features, (d) doesn't require a daemon process which manages all of the above.
Oh yes, (e) it should have enough features to eventually supersede Android's binder and ashmem drivers.

Please either tell us how to achieve that with a multicast AF_UNIX and some (OK … a lot) of libdbus_mcast-ish scaffolding around it, or kindly shut up.

The people who did the kdbus work think that a userspace solution either won't work or would be significantly more complex than a kernel driver.
Having no information to the contrary and being aware of the complexity of the problem, I tend to agree.

AF_DBUS

Posted Jan 14, 2014 20:22 UTC (Tue) by edeloget (subscriber, #88392) [Link]

Thanks for telling me to shut up. I'm not fully sure I deserve it but then who am I to judge your immense qualities ? If you say I must, I'll do it.

AF_DBUS

Posted Jan 14, 2014 21:52 UTC (Tue) by edeloget (subscriber, #88392) [Link] (11 responses)

I'm not sure I really want to shut up.

You ask me to tell you how I would implement some kind of dbus with AF_UNIX multicast alone. It seems to me that kdbus goes around that limitation by allowing programs to instantiate memfd objects. So an AF_UNIX multicast would probably use memfd too (and I already said that this idea sounds quite interesting).

Now, using the multicast mechanism to throw short messages (signaling) and memfd to pass data blocks make things quite sexy in the end. The libdbus (which is still needed and still have big things to do) can do the marshalling in and out - no need for a daemon to do that. Having the marshalling done in user space instead of kernel space does indeed add complexity to the library but it also removes this complexity from the kernel (not to mention that with your argument about complexity in the kernel to avoid complexity in user space, you are paving the way to the "glorious" day when you'll see that big emacs.ko land in staging/).

On that marshalling point: as some already said (on the mailing list, I believe), there are some "weird" field inversion and changes in the kdbus protocol when compared to the current dbus protocol. These changes will require some kind of marshalling in the library itself - so it's definitely possible.

Now that I've something with (a) zero copy (or a limited number of copies for the signaling info that foes thru the AF_UNIX multicast socket), (b) secure (because access to both the multicast socket and the memfd object can be kernel controlled), (c) looks like dbus (because, well, it's libdbus), (d) doesn't require a daemon process, can I explain what I believe is the biggest flaw in the current kdbus approach ? Or should I still shut up for eons and eons and not speak in front of your Glorious Person again?

When I say that the current implementation of kdbus does too many things, I really mean it. The fact is that the kdbus protocol is quite large and not very flexible. If kdbus is integrated into the kernel, this procotol will be part of the kernel ABI which means that it'll need to be supported for years, maybe decades. So the first point is to make sure that the defined protocol is complete and not broken - because an incomplete/broken, public protocol in the kernel is far harder to fix than a private (WRT the kernel), incomplete/broken protocol in an application. If you have to add one field in one central structure of the defined protocol then you may need to implement a new version of the protocol (possibly all the protocol, not just the change you wanted to make ; I failed to see any version field in any of the protocol structs) ; meaning that you'll have to support two protocols instead of one. Add one other error and you'll get a new one. In 5 years, you'll have multiple protocol versions to support and maintain - unless you can assure me that the full protocol is OK and will never change.

A large protocol also means that handling this protocol and the interraction between the protocol messages will be complex. It seems you are willing to put this complexity in the kernel when I think that complexity should be put far away from the kernel. The kernel in itself is already more complex and difficult to apprehend than any other program I know. This very complexity is often cited as a barrier that limit the possible participation of newcomers. If you come with a killer algorithm for the kernel scheduler you'll have a hard time producing a patch that will allow you to test and distribute your idea. Adding complexity where it can be avoided is therefore a bad idea.

@judas_iscariote: I hope I answered to your questions as well (and obiously, kdbus is not for me ; the question is not about me using it, me liking it, or someone else using it or liking it ; it's about the integration of kdbus in the Linux kernel, the pros, the cons, the possible issues in the current approach and alternatives).

AF_DBUS

Posted Jan 14, 2014 22:30 UTC (Tue) by peter-b (guest, #66996) [Link] (3 responses)

I think that the main reason the socket approach was abandoned was that the net subsystem maintainer (David Miller) said, "No, no, no, no, hell no, no matter how well you design it, how securely you implement it or how carefully it's tested." I exaggerate only slightly.

Anyway, so Greg etc. gave up on that idea, hence the kdbus driver.

AF_DBUS

Posted Jan 14, 2014 22:58 UTC (Tue) by Cyberax (✭ supporter ✭, #52523) [Link] (2 responses)

As far as I remember, he also proposed using TCP multicast on localhost instead.

AF_DBUS

Posted Jan 15, 2014 5:08 UTC (Wed) by CameronNemo (guest, #94700) [Link] (1 responses)

Who? Greg KH? Or the net subsystem maintainer?

AF_DBUS

Posted Jan 15, 2014 5:08 UTC (Wed) by Cyberax (✭ supporter ✭, #52523) [Link]

David Miller - the network maintainer.

AF_DBUS

Posted Jan 15, 2014 7:54 UTC (Wed) by alexl (subscriber, #19068) [Link] (2 responses)

You seem to believe that kdbus does marshalling and demarshalling in the kernel. It does not, it just passes on an opaque blob of data to the destination. All the metadata needed for routing is extracted from the message by userspace and passed to the kernel separate from the message.

As for the no daemon part, you seem to have a limited knowledge of dbus. The things you list are not really enough for replacing dbus, unless you want the kernel to e.g. read dbus service config files and spawn processes as described in them.

AF_DBUS

Posted Jan 15, 2014 16:29 UTC (Wed) by edeloget (subscriber, #88392) [Link] (1 responses)

> You seem to believe that kdbus does marshalling and demarshalling in the kernel. It does not, it just passes on an opaque blob of data to the destination. All the metadata needed for routing is extracted from the message by userspace and passed to the kernel separate from the message.

Which is exactly what I proposed, minus the metadata protocol (which needs its own marshalling) because I firmly believe that this protocol is

> As for the no daemon part, you seem to have a limited knowledge of dbus. The things you list are not really enough for replacing dbus, unless you want the kernel to e.g. read dbus service config files and spawn processes as described in them.

I'm not sure kdbus is going to handle that as well, unless the kdbus developpers want the kernel to e.g. read dbus service config files and spawn processes as described in them.

My previous mail was about proposing something that would replace the proposed implementation of kdbus (a) without the unneeded complexity of the proposed kdbus (b) using simple, reusable kernel mechanisms.

My point is that (kdbus with its internal memfd) can be replaced by (libdbus+multicast AF_UNIX+memfd) - the result is very likely to be more elegant (both in and out the kernel), less intrusive (kernel-wise) and less limited (change to regular AF_INET multicast and bam, you've got distributed dbus on a local network ; not sure it's a good idea but who knows?).

If you need additional functionalities like spawning a process, you can still have a dbus daemon but instead of being a central point in the design its goal will be to listen to a particular set of messages (i.e. it's an endpoint).

(BTW, I may not know dbus as much as some others ; I don't know music like Mozart did yet that doesn't prevent me to hear and recognize false notes).

AF_DBUS

Posted Jan 15, 2014 16:32 UTC (Wed) by edeloget (subscriber, #88392) [Link]

missing words

> because I firmly believe that this protocol is

... too complex and too fragile to fit in the kernel.

AF_DBUS

Posted Jan 15, 2014 19:37 UTC (Wed) by mezcalero (subscriber, #45103) [Link] (3 responses)

You are seriously overestimating the complexity of kdbus. It's short and simple code. The reason it is that way is that we do not do marshalling/demarshalling in kernel, we just route blobs the kernel doesn't need to understand.

The semantics of sockets and kdbus are quite different actually, and single-copy stuff with sockets cannot really be done...

I am pretty sure our current design is simpler, shorter, faster and more likely to be acceptable upstream.

Lennart

AF_DBUS

Posted Jan 15, 2014 20:22 UTC (Wed) by nix (subscriber, #2304) [Link] (2 responses)

Hm, isn't single-copy stuff with sockets precisely what splice() was intended for? (Of late, sendfile() can do similar things.)

Not that I've tried to use it for that, or anything, so I could easily be wrong.

AF_DBUS

Posted Jan 15, 2014 23:27 UTC (Wed) by wahern (subscriber, #37304) [Link] (1 responses)

I guess the response would be that splice works well for streams, but not well for discrete messages. For example, you could distribute a large file very efficiently using splice(2) and tee(2), but establishing the streams--i.e. distributing all the file descriptors--would be complicated and slow.

Also, what do you do if a single process hangs and holds up the queue in your tree of tee(2) calls? Actually, I have the same question regarding kdbus, but it's been left unanswered--how does the flow control work with kdbus?

AF_DBUS

Posted Jan 17, 2014 17:03 UTC (Fri) by nix (subscriber, #2304) [Link]

Aah, that makes a lot of sense. It's by no means the first time we've needed different infrastructure to handle streams versus datagrams.

AF_DBUS

Posted Jan 14, 2014 20:53 UTC (Tue) by judas_iscariote (guest, #47386) [Link] (1 responses)

> There are situations where you want to devise your own protocol

For this cases, kdbus is not what you are looking for.

> Putting the dbus daemon and its complexity into the kernel is IMHO a bad >idea (seriously: this kdbus moduledoes too many things).

why do you think "does too many things" is an argument.. ?

AF_DBUS

Posted Jan 15, 2014 5:11 UTC (Wed) by CameronNemo (guest, #94700) [Link]

What he is basically saying is that Linux has innovated in the past by devising useful building blocks to implement userspace solutions. When you tie memfd to kdbus, you limit its use to one in kernel IPC mechanism, and it is immediately unavailable to competitor IPC mechanisms that may be able to do better than kdbus. The parent comment wants to provide only what is **absolutely necessary** to achieve performant IPC in the kernel, and the rest as a userspace daemon that pieces it all together and provides a application oriented API.

memfds

Posted Jan 14, 2014 3:11 UTC (Tue) by mezcalero (subscriber, #45103) [Link]

The new kdbus stuff is a basically a stand-alone device driver which creates a char device, and does not touch any other code. It's very isolated from the rest of the kernel and not intrusive to any other subsystems. That's quite different from the previous attempts.

The presentation slides are available here btw:

http://0pointer.de/public/lca.pdf

History: In-Kernel HTTP Acceleration

Posted Jan 14, 2014 20:16 UTC (Tue) by brugolsky (guest, #28) [Link] (4 responses)

"Remember the HTTP server wars? Microsoft had a blazing fast HTTP server in-kernel. So somebody coded one up in the Linux kernel, to one up Microsoft. But then somebody with infinitely more sense tweaked some kernel APIs and wrote an HTTP server in user-space that bested both the in-kernel servers."

While my bias is in favor of your broader point about providing generally-useful orthogonal services to userspace, I believe that your recollection is faulty, and unfairly maligns the work that went into the TUX webserver. In the wake of the Mindcraft Benchmarks, which showed IIS / NT outperforming Apache / Linux 2.2 at web serving, Ingo Molnar leveraged the wide-ranging scalability improvements in the Linux 2.4 kernel to create the TUX in-kernel HTTP accelerator, which crushed everything that existed at that time. Less than a year later, the X-15 userspace webserver appeared and matched or slightly exceeded TUX's performance -- proving that the Linux syscall interface was complete and performant enough to be negligible for the SpecWeb99 workload.

The initial Windows in-kernel accelerator, http.sys, appeared later, in IIS 6.0 / Windows 2003.

TUX was popular for serving static content (in CDNs and other high-volume applications) for some time, but was eventually superceded by event-driven userspace webserver designs like nginx.

History: In-Kernel HTTP Acceleration

Posted Jan 14, 2014 21:29 UTC (Tue) by PaXTeam (guest, #24616) [Link] (3 responses)

you probably shouldn't cite TUX as the pinnacle of engineering unless you're talking about how incompetence managed to bring remotely exploitable kernel bugs to linux a few years too early. not exactly something to be proud of.

History: In-Kernel HTTP Acceleration

Posted Jan 15, 2014 11:16 UTC (Wed) by hummassa (subscriber, #307) [Link] (2 responses)

That was uncalled for.
Nobody "called TUX a pinnacle of engineering".
The only thing the GPP stated was the true fact that it outperformed other web servers by an orders-of-magnitude margin.

History: In-Kernel HTTP Acceleration

Posted Jan 15, 2014 12:33 UTC (Wed) by PaXTeam (guest, #24616) [Link] (1 responses)

start the day with a little ad hominem eh? calling me a nobody, tsk tsk. and what was uncalled for is presenting one side of the coin as if the other didn't matter. maybe go out into the real world every now and then and ask server operators how they like to clean up after getting owned. so yes, when performance comes at the cost of security (we're talking about *remote* kernel bugs, do you even comprehend the seriousness of that?) then i'll call it gross incompetence and a little sarcasm can go with it (and apparently fly above your head too ;).

History: In-Kernel HTTP Acceleration

Posted Jan 15, 2014 13:20 UTC (Wed) by hummassa (subscriber, #307) [Link]

Sarcasm without indicators in written language (especially in a forum where serious discussion usually takes place, or should, like lwn) will fly above my and many others' head all the time. :D

> maybe go out into the real world every now and then and ask server operators how they like to clean up after getting owned. so yes, when performance comes at the cost of security (we're talking about *remote* kernel bugs, do you even comprehend the seriousness of that?)

This seems to be the non-sarcastic part of your post, so I'll seriously respond:

Been there, done that, got many white hairs in interminable tech-versus-accounting discussions on the topic of IIS (ugh) versus Apache versus Tux and what was cheaper, to let our webserver be cracked and then restore the backups on a new one (oh, the early nineties, no need for cdns and stuff) or to harden them. (Hint: accounting wins all discussions, [joke] those discussions are a good rehearsal for marriage [/joke]).

Tux won for the two years where the profit of serving ten times more clients in the same hardware was greater than the cost of having a spare server semi-ready, rotating them from time to time, etc.

But, for what is worth, you are right that it was a dreadful time, security-wise. But it was before script kiddies, and before 9/11 and DHS and the NSA. We did telnet our machines at the time, all the time.

memfds

Posted Jan 23, 2014 16:35 UTC (Thu) by psusi (guest, #95157) [Link]

Microsoft didn't have an in kernel http server. What they had was apis to do zero copy IO with a small worker thread pool. I wrote my own ftp server at the time using these methods and reverse engineered IIS in the process, and advocated for linux to grow similar apis. Finally linux did grow a sendfile() api that is equivalent to Microsoft's TransmitFile(). This allowed apache to catch up to IIS, not blow it away. Later linux grew aio allowing for zero copy sending of arbitrary memory rather than just files, and for a small worker thread pool to handle many clients instead of one thread per client.

The unveiling of kdbus

Posted Jan 13, 2014 22:42 UTC (Mon) by tau (subscriber, #79651) [Link] (62 responses)

Also, regarding this posting to the D-Bus list, Lennart Poettering's ... distinctive style of diplomacy is doing nobody any favours. The amount of venom in the discussion just six posts down from his initial post is really quite staggering. The guy appears on another project's mailing list out of nowhere, announces to them that they are obsolete, and that a new code path is to be added to their project by his gang, relegating the existing system architecture to a legacy subsystem that will integrate with systemd, and do you have any questions about that? To which the list (or at least the first person he ended up corresponding with) quite rightly told him (cordially) to go f- himself.

From a purely technological standpoint I personally would definitely like to see systemd and its associated stack succeed, not just for the improved process management, but because it standardises a lot of previously distro-specific functionality and sticks an actual API on top of it. But it's not going to happen if Mr Poettering keeps marching into the room, declaring himself to be in charge and asking the volunteers who cross his path what orders they want to receive first. Or if it does, then it will happen with far more hard feelings than it strictly needs to.

The unveiling of kdbus

Posted Jan 13, 2014 22:58 UTC (Mon) by rahulsundaram (subscriber, #21946) [Link]

Your interpretation of the list discussions seems way too negative. In any case, for reference

http://lists.freedesktop.org/archives/dbus/2013-December/...

It continues well into Jan for those who want to follow and make up their own minds.

The unveiling of kdbus

Posted Jan 13, 2014 23:43 UTC (Mon) by ovitters (guest, #27950) [Link] (11 responses)

I'm not any of what you're describing after reading 30+ messages. You said it is quite staggering plus easily visible after 6. I've read way more and didn't see it.

Think you're biased, especially the way you describe things. I'm guessing you're not used to different communication styles?

The unveiling of kdbus

Posted Jan 14, 2014 2:05 UTC (Tue) by hazmat (subscriber, #668) [Link] (10 responses)

i've spent the last hr reading the whole thread and frankly i have to agree with the grand parent. it maybe there's too politic in this. but if the kdbus is trying to adhere to dbus semantic (with zero benchmark outside of the obvious), then the cost of moving a few metadata headers to the benefit of all lsm is miniscule. a central point of control is the nature of security, devolving all this to untrusted apps is inane.

The unveiling of kdbus

Posted Jan 14, 2014 13:57 UTC (Tue) by ovitters (guest, #27950) [Link] (9 responses)

You agree that after 6 messages it got extremely messy? I read 30+ and saw none of it. Only after loads and loads more messages I saw the Canonical discussion.

then the cost of moving a few metadata headers to the benefit of all lsm is miniscule. a central point of control is the nature of security, devolving all this to untrusted apps is inane

According to the kdbus developers (Lennart, Greg, Kay) it should NOT be done. They've suggested people try and write patches to understand this. Yet you so easily say that it is miniscule. Suggest to write patches instead. Further, as suggested in the same thread, this bit can be implemented by a LSM / linux security module.

Your argument seem to boil down to "everything should be in the kernel" / "please everyone". LSM would be in the kernel.

The unveiling of kdbus

Posted Jan 14, 2014 15:02 UTC (Tue) by hazmat (subscriber, #668) [Link] (3 responses)

mostly i'm agreeing that lennart has an abrasive style, the thread with him and ted early in the december archives qualifies for under 6 messages to messy. The more reasoned discussion in january also has some qualifiers.

reading through more of the messages with fresh eyes, its pretty clear that the kernel impl wants to be lean and clean with tight focus, which is perfectly normal. Also normal is the desire for a message bus to be a policy attachment point as its pretty natural and indeed there is discussion there from lennart on direct extension of the acl mechanism with selinux tags (http://thread.gmane.org/gmane.comp.freedesktop.dbus/15499). The issue is that for those wanting fine grained security (down to method invocations) the use of kdbus is going to be problematic without extension of the headers. The issue with patches here is that they've explicitly already stated they'll be rejected, so what's the point of producing them?

its not so much about putting everything in the kernel as it about an implementation than satisifies a general set of use cases such as those that the existing dbus already does. its unfortunate the previous impl didn't make it past the net maintainers (binder/ashmem compatible). anyways given the kdbus impl and the desire for not wanting to extend its routing headers with additional message attributes its clear that those who want fine grain will either have to implement payload parse in particular lsms or more likely fallback to dbus daemon and not get the benefit of kdbus.

The unveiling of kdbus

Posted Jan 14, 2014 16:57 UTC (Tue) by gregkh (subscriber, #8) [Link]

The reason you should still write patches, even if someone has said that they will reject them is that it makes it easier for you to use the entire infrastructure, with just a small patch, for your use cases.

Also, it allows you to be able to persuade the original developers that such a change really isn't a big deal.

And, it also might just prove to yourself that asking for such a feature, really was a bad idea as the patches to implement it was horrible and caused major problems.

That's why the Linux kernel mailing list very rarely has "idea" discussions, real patches are what matters.

The unveiling of kdbus

Posted Jan 14, 2014 22:14 UTC (Tue) by ovitters (guest, #27950) [Link] (1 responses)

Greg also explained the patch bit in other comment, but there was an email explaining this in the thread: I think it doesn't make sense, but if you can do it in a good clean way without performance impact/whatever, then we'll rethink.

Initially they were quite firm on the no. But seems more like "no, that'll be bad", followed by a later "but convince me with code if you can". That's pretty much kernel style way of discussing design. Maybe too used to the kernel mailing list though (even though I haven't read it for many years, I rely on LWN).

I really like a flat out "no" though. Much clearer.

The unveiling of kdbus

Posted Jan 15, 2014 10:53 UTC (Wed) by jonnor (guest, #76768) [Link]

I really prefer a "no, because ...". Just saying "no" is not very helpful.

The unveiling of kdbus

Posted Jan 25, 2014 15:24 UTC (Sat) by makomk (guest, #51493) [Link] (4 responses)

There's also stuff like the discussion later on, where Lennart makes it clear that he doesn't think users should have more than one session open at once and will refuse patches that make this work. He talks about their views as being political and portrays them as having some kind of unneccesary attachment to the idea this should work, whilst spinning his own insistence on dictating how people use their computers as an entirely technical "design choice" - yet one that he will not budge from even if other people do the hard work and come up with patches to make it possible. Frankly, the whole thing reminds me of the tactics that some of the more unpleasant ideologues use to dismiss people who won't go along with their ideology.

The unveiling of kdbus

Posted Jan 25, 2014 16:11 UTC (Sat) by kmacleod (guest, #88058) [Link]

I misunderstood the "one session" part too.

Lennart's design goal appears to be (from his comments to the ml and irc) that there is only one user bus (and one process manager per user) and that each login on any graphical display be merged into one compositor+shell, xinerama-style.

The GNOME guys are insistent on having only one logical session (where session in this context means the compositor+shell doesn't treat multiple displays as independently usable workplaces).

It seems to me that a different compositor+shell could easily support merging multiple logins into one user bus (and one process manager) but still treat some displays as independent workplaces by presenting a menu/topbar/hot-spots and attached devices on separate workspace displays, even to the point of allowing someone to simply throw a running app from one workplace to another.

So having one user bus and one process manager per user seems like a very reasonable low-level approach that allows the desktop environments to handle multiple workplaces however they want.

The unveiling of kdbus

Posted Jan 26, 2014 20:46 UTC (Sun) by ovitters (guest, #27950) [Link]

He said the lower levels would allow it, just that the higher levels (GDM) would turn everything back into one session.

> Frankly, the whole thing reminds me of the tactics that some of the more
> unpleasant ideologues use to dismiss people who won't go along with their
> ideology.

Frankly, that kind of comments are inappropriate.

The unveiling of kdbus

Posted Jan 26, 2014 23:22 UTC (Sun) by smurf (subscriber, #17840) [Link] (1 responses)

I wonder what the use case of having multiple sessions per user is.
Power users can easily create another login if they need a separate session for whatever reason.

Everybody else should just get attached to their existing session. That already happens today, you get a strongly-worded "either you use your existing session or something might break" warning (I cannot remember which desktop environment does that, as I usually only use the login screen directly after boot-up).

What's the problem, beside "it has always worked that way and now Lennart says it's nonsense, therefore Lennart is full of it"?

The unveiling of kdbus

Posted Jan 27, 2014 1:50 UTC (Mon) by kmacleod (guest, #88058) [Link]

Use cases I see:

  • Remote desktop: When I VNC/RDP into my desktop from another location (home or conference room). This shouldn't "replace" my primary session (log me off or mess up all my apps on my desktop screen) and I should get my own menu and hot-spots.
  • Remote apps: Same thing, but just one app thrown rootless to my phone or TV, which has its own input and audio devices. In reverse: where I'm running apps on a VM back to desktops.
  • Microsoft's PixelSense (nee Surface): All about having multiple user's remote apps on shared displays, moving between common workspaces and personal workspaces.
  • Multiple terminals: Seats/workplaces in the kitchen, bedroom, bathroom, wallscreen. Might be a dumb USB seat or a tablet/laptop/wireless touchscreen not running the same OS or version of Linux (ie. you can't just migrate the running app container to the other location, only the I/O).
  • Development/testing: With one user bus and user process manager it's still necessary to run different "desktop sessions" to develop and test alternate desktop environments, compositors, and shells on the same host (with containers and, given the above, with VMs). They need to be able to function reasonably (or better) under one bus and manager.

As I said in my comment earlier, one user bus and one process manager per user/host is good, I'll go further to say one "instance" of GNOME/other DE is good too but there should be (probably freedesktop.org-level) support for multiple session-like support for different desktops, seats, workplaces, apps, etc.

This might take the form of namespace hierarchies in the D-Bus user bus or, more likely across different machines, some other way to provide "localilty" to apps that need to know.

X11 was originally intended to fulfill this and did extremely well for years (and for many legacy cases still works great). Over time as apps got closer to the hardware X started performing poorly and really doesn't work well for this anymore. Wayland and remote display protocols are much better placed for doing this today.

The unveiling of kdbus

Posted Jan 14, 2014 1:43 UTC (Tue) by smurf (subscriber, #17840) [Link]

Please name names. Or, in this case, post URLs to messages you think are too abrasive.

The unveiling of kdbus

Posted Jan 14, 2014 3:25 UTC (Tue) by mezcalero (subscriber, #45103) [Link] (47 responses)

I'll not discuss with you whether I am a dick or not. However, let me point out one thing you definitely didn't get right:

"Another project's mailing list out of nowhere" --- well, I have been the maintainer of the dbus package for a while before Simon took over. Not for long, and I didn't do a good job at it, except for doing a few releases, but well, I have contributed my small share to it.

Quite the opposite to that "first person" you are refering to as "the list", who contributed the staggering amount of ... zero patches to dbus over all those years....

That said, this game is stupid. Regardless whether somebody has contributed something in the past or is an "outsider", I am quite sure that in Open Source we should accept and review everybody's patches. At least for systemd we try hard to judge by quality of code and the concepts behind it, and not by anything else...

The discussion on the dbus mailing list was messy and certainly not overly productive (except for the good stuff Simon posted), however, try to see the from our perspective for an instant, if the first mails you get are from some random folks who never contributed anything, contain no technical comments but tell you that you shouldn't call this "dbus", and tell you that your code should not have been written in the first place.

Lennart

The unveiling of kdbus

Posted Jan 14, 2014 10:19 UTC (Tue) by tsmithe (guest, #57598) [Link] (46 responses)

To me, as a layman, kdbus seems superior; so does systemd. The upstart event model strikes me as interesting, but not necessarily how you want to write your unit files. PulseAudio is brilliant.

Yet -- watching these sagas evolve is fascinating (and by the number of comments they attract here on LWN, clearly I am not alone in thinking this). There is something Machiavellian in it: I don't understand all the technicalities (though I enjoy learning), and so I watch the power struggle.

It is a power struggle that seems to exist only because the people on the edges have willed it. I think you just want to write good software -- but because you have originated so much good software, your actions are misconstrued. And yet, now, because of such misperceptions, fights really do break out, and there really do seem to be clans of people pro and versus you.

It must be unsettling.

The unveiling of kdbus

Posted Jan 15, 2014 14:12 UTC (Wed) by NAR (subscriber, #1313) [Link] (38 responses)

PulseAudio might be brilliant, but definitely broke lots of peoples audio (including mine) back in the day. The actual bugs might have been in ALSA drivers (at least this was what the PulseAudio developers said), but from the user perspective it looked like PulseAudio was introduced in the system, then the system no longer produced sounds. This was the last straw that made me go back to Windows on the desktop. I think episodes like this founded Lennart's bad reputation: introduces new "revolutionary" technology that breaks "everyone's" system.

The unveiling of kdbus

Posted Jan 15, 2014 15:20 UTC (Wed) by johannbg (guest, #65743) [Link] (6 responses)

With my QA hat on in Fedora 90% of audio issues where alsa related issues exposed by pulseaudio when it got introduced which is consisted with what the pulseaudio developers say.

If the alsa maintainers had manned up, stepped up and admitted this when people where flaming Lennart his reputation might be better intact.

The fact is Lennart has been working hard to make people lives easier but people are working hard to make his life harder by discouraging his work and the project he works ( which he never works on alone btw ) and that has gone far enough already and people should stop flaming Lennart period

The unveiling of kdbus

Posted Jan 16, 2014 1:23 UTC (Thu) by eean (subscriber, #50420) [Link] (5 responses)

> alsa related issues exposed by pulseaudio

Which was why it was inappropriate for the distributions to deploy pulseaudio when it was deployed. There are other ways to fix ALSA drivers. You don't have the make sound unfun for thousands of users. :)

That said I don't see the same mistakes being made with systemd at all. It was completely unnoticed when I upgraded to the version where openSUSE started using systemd. I'm guessing it's a combination of lessons-learned and no dependency on device drivers.

Mostly the comparisons to PulseAudio is ad hominem attack on Pottering. I've never heard any substantive comparison. There's no equivalent to "broken ALSA drivers, but let's ship anyways" in systemd.

The unveiling of kdbus

Posted Jan 16, 2014 3:01 UTC (Thu) by mchapman (subscriber, #66589) [Link] (3 responses)

> Which was why it was inappropriate for the distributions to deploy pulseaudio when it was deployed. There are other ways to fix ALSA drivers. You don't have the make sound unfun for thousands of users. :)

I'm not sure if most of the problems would have been found if PulseAudio had had a more limited initial release. Sometimes you need thousands of users with thousands of different hardware combinations.

I'm wondering how many problems were actually ALSA bugs and how many were just due to the settings Ubuntu had chosen. The PA developers made it quite clear that those settings were suboptimal.

The unveiling of kdbus

Posted Jan 16, 2014 14:41 UTC (Thu) by mathstuf (subscriber, #69389) [Link]

Yeah, the way it was distributed in Ubuntu was a problem for the longest time (I don't know the details though). I got PulseAudio when I upgraded to Fedora 9 Alpha and had issues, but they were pretty well figured out by Fedora 11's release (or so). So something like one year of issues for me.

The unveiling of kdbus

Posted Jan 19, 2014 2:22 UTC (Sun) by krakensden (subscriber, #72039) [Link] (1 responses)

> I'm wondering how many problems were actually ALSA bugs and how many were just due to the settings Ubuntu had chosen. The PA developers made it quite clear that those settings were suboptimal.

I've heard this a million times but I've never actually seen a list of what they did wrong. I've honestly started to chalk it off more to PA-developer deflection than truth.

That said, I've certainly seen Debian and Ubuntu developers screw up packaging before.

The unveiling of kdbus

Posted Jan 19, 2014 3:04 UTC (Sun) by mchapman (subscriber, #66589) [Link]

> I've heard this a million times but I've never actually seen a list of what they did wrong. I've honestly started to chalk it off more to PA-developer deflection than truth.

I don't use Ubuntu, so I only got to watch the debacle from the sidelines. It's rather hard to piece together the story now some 5 years later.

As far as I can tell it was a confluence of several problems.

* https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug...
Ubuntu had not backported a kernel patch that would allow rtkit to run properly, so PA was unable to get realtime priority.

* http://ubuntuforums.org/showthread.php?t=789578
This HOWTO suggests that they didn't divert ALSA apps to use PA, which meant those apps' audio would not be mixed with the audio from PA-using apps.

There might have been other issues too. It's complicated, because this all coincided with the time PA implement so-called "glitch-free" audio, which as I understand it exercised a lot of code in the ALSA drivers that was rarely used before.

The unveiling of kdbus

Posted Jan 16, 2014 15:08 UTC (Thu) by HelloWorld (guest, #56129) [Link]

> There are other ways to fix ALSA drivers.
Like what?

The unveiling of kdbus

Posted Jan 15, 2014 15:26 UTC (Wed) by raven667 (subscriber, #5198) [Link] (29 responses)

There is a reason everyone keeps bringing up the same example of PulseAudio in 2008 or whenever it first landed in a widely-used distro, it's because they don't have examples from more recent development such as systemd.

There is one lesson to be learned though, Lennart has a visceral rejection of cluttering up his services with workarounds when the problems are in other open-source software which can be changed to fix the bugs instead. His pushback to fix the bugs where they lie at the source has made the whole stack more robust.

What is unfortunate is that there is not a large enough desktop Linux ecosystem to have the vendors of consumer hardware do their own testing and bug fixes rather than requiring things to break on end-user desktops before bugs can be discovered and fixed.

The unveiling of kdbus

Posted Jan 15, 2014 16:06 UTC (Wed) by NAR (subscriber, #1313) [Link] (4 responses)

That first impression made the bad reputation, that's why that is brought up all the time.

Also, "no workarounds" is understandable from the engineer's perspective, but from the user's perspective it looks like "that *** broke my system and doesn't even want to fix it!". In proprietary environment this is the time when a manager intervenes one way or other to avoid public relation disaster.

The unveiling of kdbus

Posted Jan 15, 2014 16:56 UTC (Wed) by niner (subscriber, #26151) [Link] (3 responses)

Lennart did not break any systems. Pulseaudio did not break any systems. Distributions that switched on Pulseaudio before the problems in ALSA were fixed and did not provide simple ways to turn it off broke people's systems.

As an openSUSE user I found the whole discussions about Pulseaudio rather strange. It was just one easily discoverable click to turn Pulseaudio off when it didn't work and one click to turn it on again when the problems were fixed. And nowadays I have a wonderful system and can use the very nice features Pulseaudio provides.

The unveiling of kdbus

Posted Jan 17, 2014 1:56 UTC (Fri) by deepfire (guest, #26138) [Link] (2 responses)

..and of course Lennart did not have any way to influence the Pulseaudio rollout by the distributions:

- no rollout strategy discussions were possible
- he couldn't even predict there'd be any problems!

Sorry, this view doesn't fly. Lennart had a meaningful power to specify the pulseaudio use scenarios -- but he didn't exercise it. Probably because everything worked fine on his systems.

I'm not saying it's an uncommon mistake -- but it's an uncommon situation as a whole -- the impact was tremendous, since, well, everybody uses sound.

The unveiling of kdbus

Posted Jan 17, 2014 2:20 UTC (Fri) by rahulsundaram (subscriber, #21946) [Link]

" - he couldn't even predict there'd be any problems!"

On the contrary, he predicted that any such rollout will have to deal with issues and those issues would likely only surface with mass deployments of the software under different real world configurations due the wildly different set of hardware out there. This is the nature of complex software (compatibility layering requirements) and the amount of investment commercial Linux vendors are willing to make to move the desktop oriented technology forward.

The unveiling of kdbus

Posted Jan 17, 2014 3:55 UTC (Fri) by mathstuf (subscriber, #69389) [Link]

Lennart is involved with Fedora and things were bad there (at least among my machines with pretty well-supported hardware) for at most a year (Fedora 11 was fine). The Ubuntu deployment was one of the worse ones and AFAIK (though I have no details though), it was mentioned (on fedora-devel) that they weren't following upstream guidelines for whatever reason. Maybe jspaleta has some links or such handy? ;)

The unveiling of kdbus

Posted Jan 15, 2014 17:16 UTC (Wed) by paulj (subscriber, #341) [Link] (14 responses)

Current example:

I fired up an old CPC emulator the other day, to play an old game I like. It used to play sound last time, via /dev/dsp. It doesn't today. Pulseaudio keeps /dev/dsp open, preventing others using it, even when not playing anything. The pulseaudio wrapper binary causes the whole thing to segfault somewhere.

Re the "Those weren't my bugs" attitude of earlier pulseaudio days, that might have been technically correct at some deep engineering level, but it wasn't at all what the end-user considered correct behaviour.

The unveiling of kdbus

Posted Jan 15, 2014 17:19 UTC (Wed) by Cyberax (✭ supporter ✭, #52523) [Link] (5 responses)

/dev/dsp is OSS. There are no OSS drivers for many new audiochips at all (including the popular Intel HD), so you'd still be out of luck.

The unveiling of kdbus

Posted Jan 15, 2014 17:24 UTC (Wed) by paulj (subscriber, #341) [Link] (4 responses)

Not so. ALSA supports the OSS interfaces.

The OSS → ALSA transition was fairly pain-free. ALSA → Pulse not so. IME.

The unveiling of kdbus

Posted Jan 15, 2014 18:01 UTC (Wed) by Cyberax (✭ supporter ✭, #52523) [Link] (3 responses)

Nope. ALSA dropped OSS compatibility shims in favor of a CUSE-based driver long time ago, they never worked correctly and nobody wanted to maintain them.

The unveiling of kdbus

Posted Jan 15, 2014 18:06 UTC (Wed) by paulj (subscriber, #341) [Link] (2 responses)

That's news to me.

# ls /dev/dsp*
/dev/dsp /dev/dsp1
# lsmod |grep oss
snd_seq_oss 38268 0
snd_seq_midi_event 14437 1 snd_seq_oss
snd_pcm_oss 53613 0
<etc>

The unveiling of kdbus

Posted Jan 16, 2014 13:18 UTC (Thu) by cortana (subscriber, #24596) [Link] (1 responses)

I'd not go as far to say snd-pcm-oss and friends are dropped, but of the two distributions I have in front of me, Debian hasn't loaded them by default since 2008, and Ubuntu doesn't even build them any more.

The major shortcoming with the snd-pcm-oss module is precisely the problem you observe; unless your sound card has hardware mixing, the kernel will only permit one process to open either /dev/snd/pcm/pcm* or /dev/dsp at a time. The last such card I had the displeasure to use was a SoundBlaster Live! almost a decade ago.

You should look in to the CUSE solution (Debian package: osspd) if you still need /dev/dsp; if it's not available for your distro and you don't feel like packaging it yourself then you can always run your OSS-using program via pasuspender, which politely tells pulseaudio to get out of the way while your program runs.

The unveiling of kdbus

Posted Jan 16, 2014 22:13 UTC (Thu) by ms-tg (subscriber, #89231) [Link]

(applause for gently and politely introducing a solution to his problem)

The unveiling of kdbus

Posted Jan 15, 2014 18:00 UTC (Wed) by mathstuf (subscriber, #69389) [Link] (5 responses)

This is how it always worked on Linux (AFAIK): only one thing could output audio. Hence using things like aRts and (today) PulseAudio. Now I can have audio streaming through mplayer and mute it to play something else. Before, the second program wouldn't be able to use audio because the first had a hold on it. I don't know what multi-seat does these days (system-wide Pulse?).

I don't know if there's a way to get OSS programs to use PulseAudio. If not, kill PulseAudio and use the CPC emulator then. PulseAudio tends to get started on-demand (and will block if the emulator is running), so getting back to normal is implict there.

The unveiling of kdbus

Posted Jan 15, 2014 18:11 UTC (Wed) by paulj (subscriber, #341) [Link] (4 responses)

Yes indeed, OSS only ever supported one user. Apps back in the day used to be good about relinquishing sound devices when not using them precisely for that reason. :) And yes I can and did kill pulseaudio - though that sometimes leads to hard to pin down oddness later in the session with volume and stuff, so I generally prefer not to.

The unveiling of kdbus

Posted Jan 15, 2014 19:14 UTC (Wed) by nybble41 (subscriber, #55106) [Link] (1 responses)

Rather than killing PulseAudio, you can run your program through pasuspend, which will cause PulseAudio to relinquish the audio device while the program is running. If you have CUSE[1] enabled in your kernel, you can also use OSSProxy[2] to route audio from /dev/dsp to PulseAudio rather than using ALSA's OSS emulation layer.

[1] "Character devices in user space" <http://lwn.net/Articles/308445/>
[2] <https://fedoraproject.org/wiki/Features/OSSProxy>

The unveiling of kdbus

Posted Jan 16, 2014 9:32 UTC (Thu) by paulj (subscriber, #341) [Link]

Ah, pasuspend. Very interesting. I ran "pasuspender sleep 100d", then ran my CPC emulator and it still crashes, so that strongly suggests the problem is in the OSS ALSA emulation not being what the emulator expects. I'll look into why that is.

Thanks!

The unveiling of kdbus

Posted Jan 16, 2014 16:00 UTC (Thu) by ThinkRob (guest, #64513) [Link] (1 responses)

Yes indeed, OSS only ever supported one user.
Just as clarification: Linux's built-in implementation of OSS only ever supported one user. Other implementations (such as 4Front's OSS4 for Linux) did and do support multiple concurrent applications producing sound.

The unveiling of kdbus

Posted Jan 16, 2014 18:33 UTC (Thu) by pizza (subscriber, #46) [Link]

> Just as clarification: Linux's built-in implementation of OSS only ever supported one user. Other implementations (such as 4Front's OSS4 for Linux) did and do support multiple concurrent applications producing sound.

...and OSS4 wasn't free, in both meanings of the term.

...that is, until long after ALSA had come to dominate.

The unveiling of kdbus

Posted Jan 15, 2014 18:54 UTC (Wed) by smurf (subscriber, #17840) [Link] (1 responses)

It's rather easy to tell pulseaudio to release the audio device. The reason nobody does that out of the bix is very simple: many audio drivers produce loud and/or ugly-sounding klicks when you open and/or close them.

Did you try the padsp wrapper?

The unveiling of kdbus

Posted Jan 15, 2014 20:25 UTC (Wed) by nix (subscriber, #2304) [Link]

He said that caused it to segfault somewhere. I bet the thing was mmap()ping /dev/dsp, which is nearly impossible to virtualize (you need CUSE and the like, anyway padsp doesn't and can't do it).

The unveiling of kdbus

Posted Jan 25, 2014 0:01 UTC (Sat) by makomk (guest, #51493) [Link] (8 responses)

PulseAudio now, in 2014, is still bad enough that I'm seriously considering switching back to Windows after almost a decade of primarily running Linux just so that I don't have to suffer through dealing with it anymore. If anything, it's managed to develop new forms of brokenness over the years. For example I have all kinds of fun issues with it crashing randomly or using 100% CPU or randomly mangling audio output until I kill and restart it which weren't there a few years ago. (I'm 80% sure the code in the PulseAudio daemon that supports volume meters is plain wrong in a way that causes random crashes, but all the comments are missing and the variable names misleading so it's impossible to tell - and that's after reverting an optimisation in the latest official release that was included despite being literally incomplete and breaking it further.) Oh, and naturally restarting PulseAudio for any reason randomly kills all sound output in many applications until they're restarted.

Likewise, flat volumes breaks in random and amusing new ways with every version, and I've never encountered any of the mythical hardware it actually works on without annoying pops and glitches and random bursts of excessively loud audio when an app starts or exits. Hell, I've even tried it on hardware with no hardware volume control at all and somehow it still managed to screw that up by trying to adjust the non-existent hardware volume control - so lowering the application volume level had no effect until suddenly it muted the output entirely. So far as I can tell, the entire feature relies on hardware behaving in ways that isn't part of any specification and cannot ever be relied on. Though at least that can be disabled if you edit the right obscure configuration file as root.

The unveiling of kdbus

Posted Jan 25, 2014 1:07 UTC (Sat) by pizza (subscriber, #46) [Link] (6 responses)

> PulseAudio now, in 2014, is still bad enough that I'm seriously considering switching back to Windows after almost a decade of primarily running Linux just so that I don't have to suffer through dealing with it anymore.

I counter your anectdote with one of my own; half a dozen or so systems over as many years, all working without an audio-related hitch. All using bog-standard onboard AC97 or HD Audio codecs.

So, what applications are having problems? What were already streaming? What pulseaudio version? What hardware? Have you filed any bug reports?

The unveiling of kdbus

Posted Jan 27, 2014 22:50 UTC (Mon) by nix (subscriber, #2304) [Link] (5 responses)

I do have one problem, and it's an annoying one. When programs try to adjust the master volume themselves, PA automatically tweaks all the per-application volumes to compensate -- but when you try to move the master volume back down (in e.g. pavucontrol) the per-application volumes are all reduced, so you have to tweak them up by hand: system boots restore the master volume to a consistent level, but do not change the per-application volumes. The net effect is that every system reboot followed by e.g. a QEMU startup halves the volume of every application playing sound at that time. This is not sane behaviour :(

The unveiling of kdbus

Posted Jan 28, 2014 1:22 UTC (Tue) by paulj (subscriber, #341) [Link]

Ah, this behaviour of PA drives me batty - so it's not just me? I'm never quite sure what is going to happen with the volume when I adjust it. :(

The unveiling of kdbus

Posted Jan 28, 2014 2:19 UTC (Tue) by mathstuf (subscriber, #69389) [Link] (3 responses)

This sounds like flat-volumes. I have this in my .config/pulse/daemon.conf:

> flat-volumes = no

Try and see if that fixes it.

The unveiling of kdbus

Posted Jan 29, 2014 23:35 UTC (Wed) by nix (subscriber, #2304) [Link] (2 responses)

The thing is, I *like* flat volumes in all other respects. It's just that I wish programs that modified the master volume could be faked into adjusting only their own per-app volume instead. The master volume is the user's, and no app should be allowed to fiddle with it.

The unveiling of kdbus

Posted Jan 29, 2014 23:55 UTC (Wed) by mathstuf (subscriber, #69389) [Link] (1 responses)

I wonder if an option in PulseAudio to enforce that behavior would be accepted by upstream. It doesn't sound like an awful plan. The question, I guess, is how do you change the master volume then? pacmd?

The unveiling of kdbus

Posted Jan 30, 2014 0:49 UTC (Thu) by nix (subscriber, #2304) [Link]

I'm using pavucontrol... but in general whatever the desktop environment uses to control the master volume should change it: random programs shouldn't futz about with it, particularly not if there's no easy way for the user to reverse what they did. (If I as a user change the master volume in pavucontrol, everything changes volume -- i.e. it does *not* automatically shift the volume of everything else to compensate. So errant programs can do things I cannot reverse.)

The unveiling of kdbus

Posted Jan 25, 2014 4:18 UTC (Sat) by raven667 (subscriber, #5198) [Link]

PA has been stable for a long time now, I would guess there is something interesting about your hardware or your config and the PA developers would grateful if you worked with them to figure out what it is.

The unveiling of kdbus

Posted Jan 21, 2014 22:10 UTC (Tue) by pgoetz (subscriber, #4931) [Link]

Are we really still talking about PulseAudio ... in a kdbus comment section? Seriously? Lennart's !fanboys have become white noise point sources.

The unveiling of kdbus

Posted Jan 23, 2014 18:06 UTC (Thu) by Wol (subscriber, #4433) [Link] (6 responses)

The problem with Lennart is that he is intolerant of other peoples' bugs.

"Be conservative in what you send, and liberal with what you accept" just doesn't fit his way of working. If the spec says "when you do X, then Y should happen" then Lennart assumes that Y will happen. Far too much software is far too accepting when Y doesn't happen - Lennart just says "your software is broken, FIX IT!"

I gather that's why PulseAudio was such a mess when it first appeared - it kept tickling *other* *peoples* bugs. And Lennart insisted they fix their bugs, rather than him work around them.

Looked at at a technical level, that's the only approach that makes sense. But it does rather ruffle a lot of feathers.

That seems to have been one major reason for writing SystemD - SysVInit just contains too many design flaws to be even fixable ...

Cheers,
Wol

The unveiling of kdbus

Posted Jan 24, 2014 12:55 UTC (Fri) by josh (subscriber, #17465) [Link] (5 responses)

We need more people who are intolerant of bugs in other software. The danger of working around bugs is that they never get *fixed*, because the workarounds are good enough that users don't notice the bugs and complain until they get fixed.

The unveiling of kdbus

Posted Jan 24, 2014 13:40 UTC (Fri) by anselm (subscriber, #2796) [Link]

Working around other people's bugs basically gets you HTML. You have to figure out everybody else's workarounds to put those in your code, too, and it never stops.

The unveiling of kdbus

Posted Jan 24, 2014 19:26 UTC (Fri) by dlang (guest, #313) [Link] (3 responses)

what software that is completely intolerant of any bugs in other implementations has every become significant?

In theory you are correct, in practice being intolerant of bugs in other people's code just doesn't work very well and causes your users a LOT of pain.

unless you are really able to force your users to use your code even when it's a worse experience than what you are replacing, (by getting a major distro to remove the old option and ship yours for example), you are really not likely to gain a lot of users. You will definitely earn your users ire and distrust. This distrust will take a LONG time to go away, if it ever does.

As this subthread is showing with the complaints years later about PulseAudio

The unveiling of kdbus

Posted Jan 24, 2014 20:33 UTC (Fri) by smurf (subscriber, #17840) [Link]

Workarounds for other people's bugs are OK if you don't lose your core features that way. If Pulse had tolerated higher latency to work around the bugs it managed to trigger, nobody would have wanted to use it in the first place.

Plus, you really cannot blame the distros. The features pulseaudio offered were too compelling. Remember that there basically was no hotplugging of audio devices at the time. Today I can pair up my Bluetooth headphones and immediately switch over my background soundtrack without even hearing an audio glitch.

Likewise, some of the things systemd does are somewhat annoying, but once you start taking even a third of its features for granted you won't ever switch back. (IMHO.) I suspect it'll be much the same with kdbus.

The unveiling of kdbus

Posted Jan 24, 2014 20:38 UTC (Fri) by anselm (subscriber, #2796) [Link]

»Be strict when you send and tolerant when you receive« wasn't such a great idea in the first place. It serves more as an excuse for sloppy implementations than it does improve interaction between programs. It is better to be just as strict when you're receiving stuff as when you're sending stuff so bugs can be found earlier. If everybody is being tolerant then the sloppy senders never get fixed, and if you write new receiving code to the specs you will have to figure out all the workarounds that are required to handle the entrenched sloppiness. (And of course the workarounds will be different in different implementations such that sloppy stuff leads to different results.) This sucks but fixing it can be an uphill battle – for example, the W3C came up with XHTML to get rid of the ingrown sloppiness in HTML, but we all know what became of that idea.

It is tough being the only strict person when all around you everyone is complacent about sloppy code – even if your code is a lot better, people won't like it if their stuff breaks, and they will make you the culprit even if they themselves are technically at fault. Nobody likes a stickler for the rules because those make their life more difficult. But that doesn't change the fact that the rules are there for a reason.

The unveiling of kdbus

Posted Jan 24, 2014 21:19 UTC (Fri) by khim (subscriber, #9252) [Link]

what software that is completely intolerant of any bugs in other implementations has every become significant?

Not software but a specification: XML. Violations of well-formedness constraints are fatal errors which means when you try to feed non-well-formed document to an application usually you see flat-out rejection.

Works pretty damn well in practice.

unless you are really able to force your users to use your code even when it's a worse experience than what you are replacing, (by getting a major distro to remove the old option and ship yours for example), you are really not likely to gain a lot of users. You will definitely earn your users ire and distrust. This distrust will take a LONG time to go away, if it ever does.
I think you've just justified Lennart's position. If you introduce a new software which does not tolerate mistakes (e.g. pulseaudio or expat) then people may adopt it or refuse it but they will be forced to keep everything straightened out. If you'll introduce “temporary” workarounds then you'll be forced to carry them more-or-less forever.

The unveiling of kdbus

Posted Jan 13, 2014 22:55 UTC (Mon) by error27 (subscriber, #8346) [Link]

Earlier this week, I was reviewing vmbus which is similar to dbus but used for talking to hyperv clients. If we had had kdbus in 2011, then vmbus would have been written as a frontend to kdbus. This seems like a useful thing to me.

Why?

Posted Jan 14, 2014 1:10 UTC (Tue) by dw (subscriber, #12017) [Link] (7 responses)

I find it shockingly hard to believe that this needs to go into the kernel – to say D-bus needs to live in the kernel is to say that there are no existing efficient userspace<->userspace IPC interfaces, which is obviously nonsense.

There is little preventing an ABI-compatible libdbus that does little but coordinate a directory held in shared memory or similarly stashed elsewhere, having just enough logic to setup mappings or socket pairs between peers, with all validation done by the library code at the receiver. There is even no requirement for the filesystem to be present thanks to e.g. the SO_UNIX abstract namespace that's been around since forever.

For similar reasons I've never understood the value of the DBUS daemon – does it manage some super secret policy that its clients aren't allowed to peruse directly?

Reminds me a lot of devfs

Why?

Posted Jan 14, 2014 1:40 UTC (Tue) by smurf (subscriber, #17840) [Link]

We don't have multicast Unix sockets.

I strongly suspect that by the time you implemented that, then write the userspace library to coordinate everything so that it presents roughly the same interface as userspace dbus, you'd have more code with less security than what kdbus will offer.

For instance, proper message marshalling can be checked once - by the kernel - or by every recipient. Guess which is going to be more efficient.

Why?

Posted Jan 14, 2014 2:49 UTC (Tue) by hp (guest, #5220) [Link]

When something is as widely adopted and used as dbus it's obviously solving some problem, so why not work to understand what it is?

Not everything called "IPC" is the same thing with the same properties and requirements.

Why?

Posted Jan 14, 2014 3:36 UTC (Tue) by mezcalero (subscriber, #45103) [Link] (4 responses)

What dbus does, that naked AF_UNIX doesn't is this: broadcasting, introspectability, policy, activation, synchronization, method call transactions, signals, properties, OO, type-safe marshalling, monitoring, global ordering, ...

The difference between kdbus and dbus-daemon otoh are: performance, support for exchanging extensive payload not just control, timestamping, more credentials, kernel-side hookup with LSMs, race-free deactivation for services, ... -- The big one however is certainly the first mentioned: performance.

Lennart

Why?

Posted Jan 14, 2014 7:50 UTC (Tue) by edomaur (subscriber, #14520) [Link] (2 responses)

I really like the idea. The only thing I am a bit cautious is : what will happens to integration of D-BUS in other platforms than Linux ?

I know that's not your problem and I even agree to your point of view regarding other platforms, but desktop environments are not for Linux only, and D-BUS must be working the same way everywhere it is ported. How kdbus is working and how its new protocol addons must be documented in a way abstracted from the code.

(Anyway, I'm not a coder anymore, so I will not take the task.)

Why?

Posted Jan 15, 2014 9:18 UTC (Wed) by pbonzini (subscriber, #60935) [Link]

Other platforms can keep using the old AF_UNIX protocol with the system dbus daemon.

Why?

Posted Jan 15, 2014 19:29 UTC (Wed) by mezcalero (subscriber, #45103) [Link]

Other platforms can continue to use the old implementation, and we are pretty much compatible to that, with minor exceptions which shouldn't matter much. That is of course, unless apps start making use of kdbus features directly or indirectly. For example, an app that starts to send huge amounts of data across kdbus will work great and fast, but if you replace the backend by dbus-daemon, then it will still work, but very slowly.

So, there's basically going to be a dbus "baseline", which includes certain features and perfomance expectations. If people stick to that (and a lot probably will) then things stay perfectly portable.

Why?

Posted Jan 14, 2014 11:58 UTC (Tue) by bokr (guest, #58369) [Link]

I am wondering how kdbus will play with a hypervisor and its guests.

E.g., imagine that you have built a signed (by yourself) UEFI-bootable kernel that can serve as a jailhouse[1] hypervisor.
[1] http://lwn.net/Articles/574273/

Then imagine that you can trigger a Secure Attention signal by pushing a button with tamper-evident direct path to a NMI that the hypervisor sees. (Ok, for now, trust the hypervisor kernel to detect Ctl-Alt-Del in kb input ;-)

Imagine that the hypervisor loads a signed trusted login process image into a separate jailhouse, and you log in. Now you are in a user shell sort of like bash after Alt-F2 plus login, only you are a self-contained booted hypervisor guest process in a jailhouse cell.

How would kdbus support secure communication with other on-the-metal guests in other cells? I am visualizing a truly paranoid system where all apps and kernel services are signed bootable monolith images that need to communicate securely.

Yielding CPU time to destination

Posted Jan 14, 2014 6:22 UTC (Tue) by mitchskin (subscriber, #32405) [Link] (10 responses)

Lennart didn't have time for it in the talk, but I'm interested in hearing more about the "Yielding CPU time to destination" part. I vaguely recall reading (probably on an LWN comment thread) that another system's IPC mechanism (QNX's?) was hooked into the scheduler this way. Sending and receiving messages without having to wait for the scheduler to run seems like a nice win, at least for some loads.

I'm not sure how much sense that makes if you have an async API, though. Context switching on a blocking call seems fairly straightforward, but it's not clear to me how the CPU-yielding would work in the async case.

Yielding CPU time to destination

Posted Jan 14, 2014 6:33 UTC (Tue) by jonabbey (guest, #2736) [Link] (1 responses)

I believe it was some Windows API.

Yielding CPU time to destination

Posted Jan 14, 2014 7:31 UTC (Tue) by wahern (subscriber, #37304) [Link]

Yeah, I believe the Windows completion API can execute an asynchronous callback in the process, not unlike Unix signals. This can be very performant in some scenarios, but also ridiculously ugly, bug prone, difficult to compose (i.e. hard to create transparent components which don't leak the low-level details), and forces you to use particular threading design patterns which may not be optimal or desirable.

Yielding CPU time to destination

Posted Jan 14, 2014 7:37 UTC (Tue) by Cyberax (✭ supporter ✭, #52523) [Link] (1 responses)

Lots of IPCs can do this. QNX naturally has it, Solaris Doors can do this and even Windows LPC (which is used to implement most of Win32 API, btw)

Yielding CPU time to destination

Posted Jan 14, 2014 11:39 UTC (Tue) by pbonzini (subscriber, #60935) [Link]

Windows LPC was used to implement the GUI in userspace in NT 3.5 times. That was moved to kernel space (together with all the TOCTTOU bugs it had) in NT 4.0.

Nowadays, the LPC implementation is still used by some system processes, and under the hood by DCOM RPC when the source and destination reside on the same host.

Yielding CPU time to destination

Posted Jan 14, 2014 16:59 UTC (Tue) by gregkh (subscriber, #8) [Link] (4 responses)

The Android binder code works this way, it yields the CPU to the destination, which is one big reason why binder will not be able to be easily replaced with kdbus.

Yielding CPU time to destination

Posted Jan 14, 2014 19:56 UTC (Tue) by smurf (subscriber, #17840) [Link] (1 responses)

Why not? Seems to me it'd be rather trivial to add that feature.

Also, I wonder whether we need it in the first place. Today's phones have multiple CPUs, presumably one of them is idle; besides, the source task will probably go to sleep, waiting for the reply, within a msec or two.

Yielding CPU time to destination

Posted Jan 14, 2014 20:16 UTC (Tue) by gregkh (subscriber, #8) [Link]

> Why not? Seems to me it'd be rather trivial to add that feature.

Patches gladly accepted :)

> Also, I wonder whether we need it in the first place

The Binder interface relies on this process flow for how it works. If you want to, just change the kernel binder code and see if anything breaks in your Android system...

Yielding CPU time to destination

Posted Jan 15, 2014 5:21 UTC (Wed) by mitchskin (subscriber, #32405) [Link] (1 responses)

Could you expand on specifically why it's hard to replace binder with kdbus, and why you designed kdbus in a way that makes it difficult?

Yielding CPU time to destination

Posted Jan 15, 2014 14:48 UTC (Wed) by gregkh (subscriber, #8) [Link]

The models are totally different, I'll write up a blog post about all of the reasons why later on, it's a non-trivial thing.

And Kay and Lennard really did try to be able to replace binder with kdbus, but everyone agrees, the binder developers included, that this just will not work, so no one involved is unhappy or upset about it at all.

Just remember, never use binder for any code outside of an Android-only system, it is very dangerous to do so, and you get to own the pieces of your kernel if you happen to do so.

Yielding CPU time to destination

Posted Jan 16, 2014 9:54 UTC (Thu) by renox (guest, #23785) [Link]

> but I'm interested in hearing more about the "Yielding CPU time to destination" part.

Last time I read about it is here: http://lwn.net/Articles/576691/

> but it's not clear to me how the CPU-yielding would work in the async case.
It wouldn't, otherwise it's not async.. That said, if you fill the buffer an async IPC "degenerate to synchronous" (if you see what I mean), so it could still be interesting to yield the CPU if/when this happen.

kdbus, for dbus only?

Posted Jan 14, 2014 8:02 UTC (Tue) by nhippi (subscriber, #34640) [Link] (1 responses)

So, from the article and slides, it seems kdbus and memfd aren't designed to provide building blocks that can be used by binder and ashmem? Kernel developers wouldn't accept new drivers that are inspired by other drivers but don't share any code/functionality. But here it seems a new userspace api is being proposed that is tailored for dbus and dbus only.

kdbus, for dbus only?

Posted Jan 14, 2014 8:16 UTC (Tue) by Cyberax (✭ supporter ✭, #52523) [Link]

As I understand the last attempt to make a generic API resulted in network subsystem maintainer flatly refusing it.

The unveiling of kdbus

Posted Jan 14, 2014 8:30 UTC (Tue) by djc (subscriber, #56880) [Link] (1 responses)

I'm hoping the kdbus guys will communicate with Martin Sustrik (the inventor of the pretty successful ZeroMQ) on what kind of thing he would need for e.g. nanomsg. nanomsg is basically a rewrite (in the good sense!) of ZeroMQ, and pretty awesome. IIRC Martin has proposed patches for kernel-level support for nanomsg, but that hasn't gone anywhere so far.

http://www.slideshare.net/jamesskillsmatter/martin-sustri...

The unveiling of kdbus

Posted Jan 14, 2014 10:55 UTC (Tue) by ms (subscriber, #41272) [Link]

Well, there are plenty of interesting messaging products on the market from the closed source SonicMQ and friends, to the open source (and extremely widely used) RabbitMQ (disclaimer: which I co-wrote), Kafka and ZeroMQ. Different products focus on different things; for example Rabbit's never focussed on speed outright, always more on reliability and offering guarantees about message loss/preservation. ZeroMQ certainly takes a different approach. But yes, I would hope the kdbus designers have spent some time looking at what other people need and use - DBus is a rather small part of the picture. That said, my reading so far (albeit very brief) is that kdbus is really focussed on IPC, and not in the distributed sense. But I may be wrong.

The unveiling of kdbus

Posted Jan 14, 2014 13:43 UTC (Tue) by jspaleta (subscriber, #50639) [Link] (11 responses)

Greetings from the southpole,

So reading through the thread in full, and I'm only seeing one really interesting point of contention. It appears that the app sandbox model being used for Unity treads into a bit of a grey area with regard to security policy enforcement. The functionality they are relying on appears to be an implementation detail of dbus-daemon and not part of the D-Bus spec which all daemons are expected to provide.
Quoting the spec:
http://dbus.freedesktop.org/doc/dbus-specification.html
"Message bus implementations may impose a security policy which prevents certain messages from being sent or received"

Up till now its not really come up, because we haven't had a second implementation of the spec for the "may" clause to come into effect. But now, kdbus as a second implementation of the spec, doesn't include that optional security policy check. It doesn't have to, as the D-Bus spec allows this to be an implementation by implementation choice to make.

And so the concern is, the sandbox model Ubuntu is using is layered over dbus-daemon in Ubuntu isn't going to work with kdbus as designed. Noone is at fault here. Decisions were made to rely on optional implementation functionality not covered by the protocal spec. And the kdbus design decisions preclude the optional security policy check.

The only salient question is this. Will Ubuntu's sandbox model continue to require the reference dbus-daemon implementation, or can modifications be done to either Ubuntu's user space or to kdbus design so Ubuntu can take advantage of kdbus performance benefits in later releases? The irony of course is that Ubuntu's mobile push would probably benefit the most from kdbus's performance gains, but at the same time its also where their sandbox model is most useful as well.

-jef

The unveiling of kdbus

Posted Jan 14, 2014 15:41 UTC (Tue) by paulj (subscriber, #341) [Link] (10 responses)

Wow, you're trying to turn even a kdbus article into a discussion on Unity/Ubuntu. Please try harder to control this obsessive behaviour of yours. :)

The unveiling of kdbus

Posted Jan 14, 2014 16:56 UTC (Tue) by ovitters (guest, #27950) [Link] (9 responses)

Someone else mentioned that email thread, suggesting all kinds of inaccuracies. E.g. that within 6 posts it was bad. Jef seems to pretty accurately describe the concerns that were raised in this email thread IMO. I find it fairly important to highlight such concerns.

Also quite interesting is the difference between the how Ubuntu app sandboxing will work and the one envisioned for kdbus/gnome/whatever to call it. You'll note that both sides tried to work together, though didn't pan out in the end.

Then you have tidbits about Samsung already using an old version of kdbus. Further, that kdbus won't be used easily by Binder (the Android thing). I thought it would be able to be used for Binder as well, so interesting to read. It makes me wonder what Samsung is using it for (guessing Tizen, but would be nice to know for sure).

The unveiling of kdbus

Posted Jan 14, 2014 19:25 UTC (Tue) by smurf (subscriber, #17840) [Link]

I just read through part of the discussion started by Lennart's announcement at http://thread.gmane.org/gmane.comp.freedesktop.dbus/15499

As far as I understand, if somebody (Ted Gould in this case) says to Lennart that

>> I see you as delivering an ultimatum to the DBus community about how they've been replaced.

then I guess I can understand why Lennart doesn't want to continue that kind of "discussion". The responsibility to keep a discussion civil and factual is shared by both sides of a debate; blaming Lennart for that subthread's ultimate failure to commuicate is unfair.

The unveiling of kdbus

Posted Jan 14, 2014 21:14 UTC (Tue) by tanuk (guest, #71154) [Link]

> It makes me wonder what Samsung is using it for (guessing Tizen, but would be nice to know for sure).

Yes, Tizen, judging from this message (Tizen git repo referenced): http://thread.gmane.org/gmane.comp.freedesktop.dbus/15499...

The unveiling of kdbus

Posted Jan 15, 2014 11:31 UTC (Wed) by jspaleta (subscriber, #50639) [Link] (6 responses)

I think the idea is that kdbus can replace Binder and binder-native semantics entirely. The idea I think is to be able to make kdbus be functionally equivalent to what Binder does. Not drop-in compatible, but functionally equivalent, using D-Bus semantics. So eventually...if Google buys in to kdbus, they can retool their userspace to use D-Bus semantics and Binder goes away. Eventually..Android, and everyone else, can use D-Bus semantics to get the job done.

Here's a good article from May 2013 to recap the dev thinking on this from the kernel-side: http://lwn.net/Articles/551969/

Note the brief discussion about Binder's security issues. I think that's very interesting. I would think Google would want in the long term to have both ChromeOS and Android being able to use the same IPC securely. kdbus might be that long term solution for them, on some timescale. But who knows.. Google will cross that bridge or not in due time. The point I think is a transition to kdbus from binder is not out of the question for Google. Google won't have to completely changing the design of their intents system.

-jef

The unveiling of kdbus

Posted Jan 15, 2014 19:24 UTC (Wed) by mezcalero (subscriber, #45103) [Link]

kdbus cannot replace the binder kernel bits for android. The semantics are too different. Binder's name registry works entirely different. It has more a topology of direct connections rather than a true bus. It's more focussed on "pubsub" rather then multicasting the way kdbus does.

Binder doesn't really queue things so much, it's synchronous by default, and its backend is dispatched by worker threads (i.e. fully unordered), while dbus is more focussed on async stuff, and gives global ordering guarantees.

Maybe some lower-level work can be shared between binder and kdbus, but kdbus itself is not suitable as a backend for binder, and won't be.

Lennart

The unveiling of kdbus

Posted Jan 15, 2014 23:04 UTC (Wed) by ovitters (guest, #27950) [Link] (4 responses)

I assume you already saw it, but this blog by Greg explains it clearly: http://kroah.com/log/blog/2014/01/15/kdbus-details/

The unveiling of kdbus

Posted Jan 15, 2014 23:12 UTC (Wed) by jspaleta (subscriber, #50639) [Link] (3 responses)

no i hadn't seen that yet... I'm not able to cover the same ground in terms of resource material while I'm at the pole. So thanks for that. It clears up the evolving thinking nicely.

-jef

Waiting for Da BUS at South Pole

Posted Jan 16, 2014 10:18 UTC (Thu) by sdalley (subscriber, #18550) [Link] (2 responses)

So, you're at the south pole? Awesome...

Any nice pix you'd fancy sharing? What do they do for internet service down there?

Just curious.

Wishing you a pleasant summer holiday.

Simon

Waiting for Da BUS at South Pole

Posted Jan 16, 2014 10:48 UTC (Thu) by jspaleta (subscriber, #50639) [Link] (1 responses)

Internet is entirely polar orbitting sats. There is effectively about a half days coverage in chunks that range from 1 hour blocks to about 4 hour blocks. Though the bandwidth varies depend on the particular sat, though none of it is good enough band to enjoy watching embedded vids or animated gifs. Most enriched websites...like facebook or even gmail's default interface..are too heavy to load fully. Forget about doing anything like a google hangout. LWN being particular devoid of the web equivalent of JJ Abrams cinematic lens flare, is one of the things I can get to reliably and I am grateful for it.

Waiting for Da BUS at South Pole

Posted Jan 16, 2014 15:37 UTC (Thu) by raven667 (subscriber, #5198) [Link]

> LWN [...] is one of the things I can get to reliably and I am grateful for it.

Ha ha, that explains why you are here so much but what excuse do the rest of us have 8-)

The unveiling of kdbus

Posted Jan 14, 2014 20:04 UTC (Tue) by jonabbey (guest, #2736) [Link]

The video is up now:

http://mirror.linux.org.au/pub/linux.conf.au/2014/Friday/104-D-Bus_in_the_kernel_-_Lennart_Poettering.mp4

The unveiling of kdbus

Posted Jan 16, 2014 11:20 UTC (Thu) by lainfinity (guest, #94972) [Link] (2 responses)

The fundamental question of kdbus is how to convert monolithic linux kernel to a microkernel architecture.

Linux is Linux because of its monolithic architecture, even though less secure Linux microkernel is no longer Linux may be it will eventually be transformed to Lennarix.

Android vs GNU/Linux even though both is based on Linux kernel, there is a big difference in terms of stability. I prefer a less secure and stable monolithic than more secure microkernel.

History always repeats (Monolithic vs Microkernel).

The unveiling of kdbus

Posted Jan 16, 2014 12:47 UTC (Thu) by alexl (subscriber, #19068) [Link] (1 responses)

kdbus is fundamentally a userspace<->userspace IPC mechanism, similar (on a very very high level) to unix domain sockets or shared memory. It is not a kernel<->kernel ipc mechanism, and thus it is completely irrelevant to whether linux is a microkernel or not.

The unveiling of kdbus

Posted Jan 16, 2014 14:41 UTC (Thu) by lainfinity (guest, #94972) [Link]

The kdbus is very similar in architecture to Android Binder except for more bandwidth, complexity and ram based.The model of Binder was created for a microkernel-like device.

http://kroah.com/log/blog/2014/01/15/kdbus-details/

Eventually because of the compexity and functional capabilities of the IPC like kdbus Linux will tend to behave more like a microkernel in the long run.


Copyright © 2014, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds