News for hackers. Stuff that matters.
Re:Bus1: a new Linux interprocess communication proposal by qwertyuiop924 on Thursday August 18, 2016 @07:24AM (#12311614)
No. Nonononononononono. We were ALMOST FREE! Just get these high-level abstractions out of my effing kernel. They don't belong there. Linus said as much himself. The only reason kdbus, this thing's predecessor, got so much as a glance is that Linus trusts Greg KH. A trust I would now consider somewhat misplaced. This is yet another piece of crap that was tacked on by systemd nonsense. It's non-portable, and they want us to use it upstack.

Have these people lost their effing minds? Do they think we don't care about compatability? Just because Lennart said "screw POSIX" doesn't mean you should do it.

Re:Bus1: a new Linux interprocess communication proposal by IshKebab on Thursday August 18, 2016 @07:35AM (#12311659)
I agree. I can't see any real reason for this to be in the kernel. Is it faster? Does it need access to memory in some way you can't do in userspace? The only practical reason I can think is if it is in the kernel you can 100% rely on it being present and available. Userspace processes can be killed.

So perhaps the real solution is to provide some kind of mechanism for userspace processes that act like kernel drivers, in that they are definitely running all the time, but actually run in userspace.

Re:Bus1: a new Linux interprocess communication proposal by lathiat on Thursday August 18, 2016 @07:38AM (#12311675)
The two main reasons I know/care about (there may be more) are that it can be much faster (zero copy, reduced context switches) and also guarantee the message isn't changed while reading (by sealing the originating buffer).

The last is something you need kernel help to enforce.

Re:Bus1: a new Linux interprocess communication proposal by saynsedit on Thursday August 18, 2016 @08:51AM (#12312079)
There's no case for this usually marginal speed benefit.

Most programs are dealing with vastly slower bottlenecks. Like network or disk latency. IPC latency is so far down the list of priorities in terms of things to optimize.

Not to mention that regular user-kernel-user buffer copying is plenty fast now, especially since the buffers will likely be cache-resident. Zero-copy is mostly hype without performance numbers to back it up. Don't need this complex message sealing mechanism.

Re:Bus1: a new Linux interprocess communication proposal by dooglius on Thursday August 18, 2016 @10:46AM (#12312862)
I don't see anything described that can't be done in a userspace library through shared memory. Maybe security is a concern, where we don't trust some nodes that might be exploited not to be able to screw with the shared memory? But then zero-copy would be off the table for the same reasons, no?
Re:Bus1: a new Linux interprocess communication proposal by qwertyuiop924 on Thursday August 18, 2016 @07:49AM (#12311717)
Yeah, but is it worth the cost? I would say no.
Re:Bus1: a new Linux interprocess communication proposal by qwertyuiop924 on Thursday August 18, 2016 @07:38AM (#12311672)
That's just a daemon.

The reason this is in the kernel is that DBus is slow (according to Linus, because it could have been written better by monkeys with typewriters), and Lennart wanted it in the kernel/systemd, and Greg KH agreed, and Linus trusts Greg.

Re:Bus1: a new Linux interprocess communication proposal by sjellis on Thursday August 18, 2016 @07:41AM (#12311684)
The announcement email from David Herrmann explains that they did consider a user-space implementation, and lists the reasons why they decided that it had to be in-kernel:

https://lists.linuxfoundation.org/pipermail/ksummit-discuss/...

Re:Bus1: a new Linux interprocess communication proposal by saynsedit on Thursday August 18, 2016 @08:57AM (#12312119)
The reasons are mostly performance reasons. As I said in my other post, IPC latency is way down in the priority list of things to optimize (relatively to network and disk latency).

Unless the application is a HPC parallel computation that is IPC bound, Bus1 has no performance justification. If the main justification for a modern kernel IPC mechanism is performance, I'd much much much more trust a proposal coming out of the HPC community than the desktop experience community.

Re:Bus1: a new Linux interprocess communication proposal by deno on Thursday August 18, 2016 @10:13AM (#12312588)
You’re ignoring the fact that Bus1 is based on binder, not dbus, so performance (mostly power efficiency) apparently was an issue—on Android.

So now you have two ends of the spectrum where this effort does matter, performance wise.

This only leaves the middle (desktop), but there are other reasons why that evil desktop crowd wants IPC in kernel, however high on a ‘priority list’ they might be.

Re:Bus1: a new Linux interprocess communication proposal by saynsedit on Thursday August 18, 2016 @10:35AM (#12312781)
My point still stands. I don't think it's very likely that the main power hog in a mobile phone is the IPC mechanism. Unless IPC is happening in a tight loop, on the order of millions if times per second, it's just not common enough to really make a dent.

You have wifi, screen brightness, CPU-hungry background apps, etc. to fix first.

Re:Bus1: a new Linux interprocess communication proposal by deno on Thursday August 18, 2016 @10:49AM (#12312886)
http://lwn.net/Articles/504984/ #Priority Inversion #Latency

It’s not about tight loops.

Also this idea that you have to fix wifi chip or screen before you can add anything to the kernel doesn’t seem to be founded in any kind of logic.

Re:Bus1: a new Linux interprocess communication proposal by saynsedit on Thursday August 18, 2016 @11:09AM (#12313059)
I don't buy these arguments...

For priority inversion it seems dbus-daemon is at fault here, not user-space message routing in general. It's just as easy to have two message routing processes, one for low priority messages and one for high priority messages.

As far as 4 context switches versus 2 with regards to latency. A context switch takes microseconds... This is vastly smaller than the 250ms UI response time.

Again, this looks like a solution looking for a problem.

Fixing wifi or screen before working on micro-problems in the kernel for the sake of global power efficiency is founded in every kind of logic. It's literally Amdahl's Law: reducing power usage in a component that already has the most minimal power usage is a waste of effort for no noticeable effect. The cost-benefit ratio is indefensible. This is insanity.

Re:Bus1: a new Linux interprocess communication proposal by deno on Thursday August 18, 2016 @02:39PM (#12315213)
You seem to be fixated on this idea that this is purely a performance optimization. You’ve made it your strawman. But that is in fact only one minor point.

Linux is lacking a coherent IPC system and the necessary primitives to build one. That’s the bottom line.

Re:Bus1: a new Linux interprocess communication proposal by saynsedit on Thursday August 18, 2016 @03:20PM (#12315563)
No I very much did not make it my strawman. Look at the original announcement email, they themselves list performance as their main motivation.

Please, I can argue down any allegedly rationale for creating Bus1. Try me. You have yet to put forth any convincing argument.

The real bottom line is Linux already has a coherent IPC system but third parties don't like it and are irrationally fixated with an in-kernel solution that reflects their grand idea of what a coherent IPC system should look like. It's childish, it's bad engineering, and it's a waste of effort.

Re:Bus1: a new Linux interprocess communication proposal by qwertyuiop924 on Thursday August 18, 2016 @09:09PM (#12317368)
>The real bottom line is Linux already has a coherent IPC system but third parties don't like it and are irrationally fixated with an in-kernel solution that reflects their grand idea of what a coherent IPC system should look like. It's childish, it's bad engineering, and it's a waste of effort.

Finally, He said what we're all thinking!

Re:Bus1: a new Linux interprocess communication proposal by tomegun on Thursday August 18, 2016 @09:08PM (#12317366)
Did you read the ksummit email? There were eight reasons given, performance was one of them (the third one). Not the only one. Not the main one.
Re:Bus1: a new Linux interprocess communication proposal by saynsedit on Friday August 19, 2016 @08:43AM (#12319595)
What would you say is the main driving rationale for bus1?
Re:Bus1: a new Linux interprocess communication proposal by tomegun on Friday August 19, 2016 @10:27AM (#12320216)
I would say it is to create the primitives needed for a multicast-capable (n-to-n) local IPC system. Obviously in such a way that it is safe, reliable, predictable, scalable, fast and lightweight.
Re:Bus1: a new Linux interprocess communication proposal by saynsedit on Friday August 19, 2016 @04:59PM (#12323426)
You can create a multicast-capable (n-to-n) IPC system in such a way that is safe, reliable, predictable, scalable, fast and lightweight in user-space. Kernel is not required!
Re:Bus1: a new Linux interprocess communication proposal by tomegun on Friday August 19, 2016 @09:40PM (#12324652)
How? We give a list of issues in the email.
Re:Bus1: a new Linux interprocess communication proposal by saynsedit on Saturday August 20, 2016 @02:01AM (#12325423)
* I don't see a time-slice accounting for the bus broker as an issue. If it's a system daemon, you can define away the problem. What's the use case for doing time-slice accounting where ignoring the system daemon's usage matters?

* for priority inheritance, have multiple daemons for each message priority level. Only privileges processes can use the high-priority message router, but can optionally use the low-priority message router when they want to inherit the priority of their sender.

* like I said, context switching is irrelevant since context switching is not the bottleneck in event latency nor in power usage.

* if FD accounting is important, move it out of the broker and make it p2p with broker coordination.

* kernel and LSM hooking feels like a feature looking for a use-case. If anyone really wants to do that, I'm sure the specific use case can be accommodated. Not every user space program need be trackable via LSM.

* for side channel and message ordering, why is this a core feature of the transport layer? I don't think all applications need this and if they do, something simpler and more specific to the application protocol could be developed. Generalized message ordering guarantees as part of the transport layer seems like it violates end-to-end design. A robust application protocol will end up ensuring this on its own anyway.

There you have it. I'm sorry but you don't have a strong case. Linus is even more opposed to this than I am and is probably better about system design than I am as well.

Re:Bus1: a new Linux interprocess communication proposal by tomegun on Saturday August 20, 2016 @10:04AM (#12326649)
I don't get what you are trying to achieve with this discussion. You didn't provide any serious alternative, you just say that the issues don't matter to you.

Obviously, if you do not care about any of the features, then you should not be using bus1. But that does not mean that others don't care, so why are you objecting so strongly to us providing a solution to these problems?

Firstly, if you don't want a bus IPC with multicast messaging, then use something else. But if you DO want that, then you cannot ignore message ordering, that is the whole point (otherwise you could just use repeated unicast instead).

If you want message ordering you cannot split things into several daemons, or you break the order (unless you add some more communication on top). Same with p2p (side-channel) communication for FDs.

The broker is basically doing work on behalf of the sender, but without proper time-slice accounting it is not accounted accordingly. Obviously in many cases that does not matter, but you cannot simply ignore the problem if you want a general, lasting solution.

It is true that performance is not the main feature, but that is not to say that it does not matter at all (to anyone, ever), so you cannot simply brush it aside, proposing a solution that would have (almost by definition) hundreds of percent worse performance (as you are just doing more round-trips, even ignoring the context switching). To say that IPC latency is "not the bottle neck" only makes sense if you have a specific use-case in mind. With sufficiently low latency, we open up the possibility of using IPC for things that could only be done in-process today. This is not the MAIN purpose, but ignoring it is short-sighted.

I just got an email today from people asking about the LSM hooks, so there certainly is interest, and this (like the message order) is not something you can bolt on top.

I have not seen Linus comment on this, please give a link if you have. Whatever reservations he had about kdbus should not apply to bus1.

Look, there are plenty of things that could be improved on bus1, and I'm sure some careful review will find things we could and should do differently, but please at least spend more than five seconds looking into what we did and thinking about the problem. We want a multicast IPC system, but we want one done properly. You cannot simply say that doing one that is several times slower, doesn't do proper resource accounting, gets the message order wrong and cannot integrate with LSM is "good enough for me" and expect that to be the end of it.

Re:Bus1: a new Linux interprocess communication proposal by saynsedit on Saturday August 20, 2016 @02:31PM (#12327761)
The original point is that this doesn't have to be a kernel. None of the current rationale gives any use-cases for the features you're offering, you're just saying "this feature requires kernel support" well what is the use case for that feature? Maybe there is another way that doesn't require kernel support.

Multicast messaging as your main motivation for a message ordering layer when that layer has drastic effects on performance and operational characteristics is a strange proposition. I'm willing to argue that 99% of application protocols will have no use for baked-in multicast as you've implemented it. What exactly is the killer use case for multicast messaging with side-channel aware causal message ordering? What prevents an application that cares about this from ordering incoming messages according to a lamport clock itself?

I see no downside to these features in general, it's just that the justification for putting it in the kernel is weak. Kernel code has an infinitely high maintenance cost and it's not clear bus1 is the end-all messaging layer you want it to be. There are lots of past failed examples, inotify, dnotify, and fanotify come to mind...

Re:Bus1: a new Linux interprocess communication proposal by gpderetta on Friday August 19, 2016 @09:19AM (#12319737)
> o guarantee a global message order [...]

> o scale with the number of CPUs available [...]

It seems to me that these two goals are conflicting. If they give up the first goal then suddenly the need of a broker disappear.

edit: quoting from the message linked by parent.

edit2: by reading the description of the ordering guarantees, it seems that they actually only guarantee partial ordering.

Re:Bus1: a new Linux interprocess communication proposal by tomegun on Friday August 19, 2016 @02:00PM (#12321983)
One should think the goals are conflicting, but they are not. The secret is that the order is partial, as you say, but from userspace's point of view it is indistinguishable from a total order. The only messages that are not well ordered are messages that can never interact, so it is not possible to observe the lack of order from userspace. I wrote up how it works here: https://github.com/bus1/bus1/wiki/Message-ordering
Re:Bus1: a new Linux interprocess communication proposal by gpderetta on Monday August 22, 2016 @10:21AM (#12336499)
As long as processes communicate only via Bus1, yes, it is not possible, but there are plenty of other IPC systems on unix that can make the lack of total order manifest. Advertising it as a total order doesn't seems like a great idea.
Re:Bus1: a new Linux interprocess communication proposal by tomegun on Tuesday August 23, 2016 @11:15AM (#12344367)
I don't see how. We should handle side-channel communication just fine. Care to give an example?
Re:Bus1: a new Linux interprocess communication proposal by gpderetta on Friday August 26, 2016 @10:26AM (#12366486)
proc1 sends a message to proc2 via bus1, then sends a signal to proc3 via a shared memory channel by incrementing a counter in shared memory; proc3 sees the message and signals proc4 via bus2;

There is no partial ordering between proc1->proc2 and proc3->proc4 as the memory channels are invisible to bus1, but Proc2 and proc4 can detect the total ordering violation by using another counter in shared memory.

Re:Bus1: a new Linux interprocess communication proposal by tomegun on Monday August 29, 2016 @10:40AM (#12382123)
Right, we only enforce the _order_ of message delivery, not the _time_ of deliver. I.e., consider the sequence of messages received on each peer, these sequences each respect a global, total order on all messages. But there are no timestamps on them, and no way to compare sequences from separate peers.
Re:Bus1: a new Linux interprocess communication proposal by qwertyuiop924 on Thursday August 18, 2016 @07:47AM (#12311711)
I was talking about KDbus, the predecessor to this.
Re:Bus1: a new Linux interprocess communication proposal by tomegun on Thursday August 18, 2016 @01:34PM (#12314603)
See the ksummit announcement elsewhere in this thread. The list of issues is given there. We could get 95% of the way in userspace, but not all the way (the issues are by no means obvious or trivial, so take a look at the announcement).
Re:Bus1: a new Linux interprocess communication proposal by tomegun on Thursday August 18, 2016 @01:31PM (#12314573)
What's high-level about bus1? This has nothing to do with systemd, and very little (apart from history) to do with kdbus.

As to portability, this is a linux kernel module, but there is nothing really inherent to linux about it, so porting it to another kernel should not be a lot of work if that is interesting to anyone.

Re:Bus1: a new Linux interprocess communication proposal by qwertyuiop924 on Thursday August 18, 2016 @02:46PM (#12315260)
What's high level? They're providing a message bus. That's not an IPC primitive. That's very high-level.

As for systemd, I gathered there was a connection to kdbus, which was Lennart's baby. Thusly, I gathered it needed init to cooperate, the same way kdbus did, and any non-bus1-aware init just wouldn't work with apps that used bus1.

As for portability, what other OS will implement this muck? None of them. It's portable the same way systemd is: "apps that depend on us are portable, so long as every os copies all our stuff, and re-implements all our APIs"

Forcing other OS's to implement your stuff isn't portability.

Re:Bus1: a new Linux interprocess communication proposal by the_why_of_y on Thursday August 18, 2016 @04:01PM (#12315890)
None of QNX IPC, Mach IPC, Minix3 IPC, Solaris Doors, NT LPC or Android Binder is portable, and all of them are used by low-level user-space on their respective platform. But if Linux developers add a new IPC mechanism for similar purposes, it must be useless "muck"?
Re:Bus1: a new Linux interprocess communication proposal by qwertyuiop924 on Thursday August 18, 2016 @04:38PM (#12316153)
NT doesn't have to worry about compat. Neither do Android apps. QNX, Mach, and Minix3 are microkernels, and that IPC isn't used by high-level userland in the UNIX compatible systems. Doors is something I have similar objections to.

But if bus1 is a successor to kdbus, it's not intended to be used by low-level userland, it's built for highlevel userspace. Like systemd, this is trying to coax high-level userland to be incompatible with other unixes.

The fact that no unixes other than the originating one, if the orginator was a unix, has picked up any of these systems speaks volumes about why you shouldn't use it in highlevel userland.

Re:Bus1: a new Linux interprocess communication proposal by tomegun on Thursday August 18, 2016 @08:47PM (#12317295)
Please look at the code. bus1 is no more high-level than UDS.

You 'gather' a lot about how this works, please look at the code/docs before writing things. 'kdbus' was Lennart's baby? Look at who wrote the code, who submitted it upstream, etc.

bus1 needs init's cooperation in the same way UDS does. It is simply a nonsensical statement, bus1 is simply a transport, what apps do on top is a different topic.

When I said that bus1 should be reasonably portable, I meant exactly that: the code of bus1 itself should be easy to port to other OSs. Whether apps that use bus1 are easy to port to systems without bus1 depends on how what they do and what is available on the other systems in question...

Re:Bus1: a new Linux interprocess communication proposal by qwertyuiop924 on Thursday August 18, 2016 @09:17PM (#12317404)
Well, that's not what you said, but portability, I'll accept.

The fact that Bus1 doesn't need init cooperation is good.

However, Bus1 is MUCH higher level than UDS. UDS is a two-way bytestream between two processes. Bus1 as much more complicated system, designed to send structured binary messages, and includes a permissions system, sealing, and a lot of other complexity. It doesn't belong in the Kernel any more than DBUS.

As for kdbus not being Lennart's baby, and that I should look at who wrote the code, I did. I direct you to https://lwn.net/Articles/580194/, where Lennart not only takes credit for KDBus, but also says it's application-level, implying it is intended to be used in high-level userland.

High-level abstractions for applications don't belong in the kernel.

Re:Bus1: a new Linux interprocess communication proposal by tomegun on Friday August 19, 2016 @05:41AM (#12318899)
There is not really a permission system in bus1 any more than fd passing is a permission system. What bus1 gives you is the primitives to build a permission system though.

There is no sealing in bus1.

The payload of a bus1 message is exactly the same as the payload of a UDS message: unstructured binary data. bus1 is (like UDS) just a transport, it would be up to the consumer to add structured payload if they wish.

kdbus is higher level than bus1, don't confuse the two. kdbus is still not at the application level though, there would have to be a userspace component inbetween.

High-level abstractions for applications don't belong in the kernel, I agree. But that is a strawman, bus1 is not doing that at all.

Re:Bus1: a new Linux interprocess communication proposal by qwertyuiop924 on Friday August 19, 2016 @08:22AM (#12319514)
Thanks. Sorry. I'm still not convinced that bus1 is a good idea, but at least that's been cleared up.
Re:Bus1: a new Linux interprocess communication proposal by the_why_of_y on Friday August 19, 2016 @06:52AM (#12319148)
> ... and includes a permissions system ...

The whole point of capability based security is that there is no permission system, because permissions are implicit in the capabilities. So this is much simpler than e.g. SysV message queues.

Re:Bus1: a new Linux interprocess communication proposal by rwmj on Thursday August 18, 2016 @09:29AM (#12312306)
I thought the interesting part of kdbus was the "memory sealing" - you could take a shared memory buffer, write to it, then "seal" it (so no further changes were allowed) and share it with another process. I believe you cannot efficiently do that in userspace. That doesn't seem to be part of this proposal.
Re:Bus1: a new Linux interprocess communication proposal by bluetech on Thursday August 18, 2016 @10:02AM (#12312507)
There is memfd_create(2) (see discussion under "File sealing" and the related fcntls).
Re:Bus1: a new Linux interprocess communication proposal by tomegun on Thursday August 18, 2016 @08:48PM (#12317298)
memory sealing can be used by anything that can do fd passing, which bus1 does (as does UDS). That code is already upstream and was not really tied to kdbus.
Re:Bus1: a new Linux interprocess communication proposal by the_why_of_y on Thursday August 18, 2016 @09:04AM (#12312164)
Exactly! They should just use the Android Binder IPC that was merged some years ago and was widely heralded as a pinnacle of open development, good design and especially security. (Getting Binder standardized in the next revision of POSIX is surely a mere formality.)
Re:Bus1: a new Linux interprocess communication proposal by qwertyuiop924 on Thursday August 18, 2016 @09:24AM (#12312273)
No, it's not. Binder was designed for Java, and the rest of the Unix family doesn't support it.