|
|
Subscribe / Log in / New account

Bus1: a new Linux interprocess communication proposal

Bus1: a new Linux interprocess communication proposal

Posted Aug 21, 2016 4:08 UTC (Sun) by alison (subscriber, #63752)
Parent article: Bus1: a new Linux interprocess communication proposal

Thanks for another great explanation, neilbrown. The famous inefficiency of D-Bus stems both from the many context switches and associated data copies. The article clearly explains how context switches can be reduced by establishing peer-to-peer communication subsequent to a first in-kernel capability check. What's less clear on reading the article is whether large data structures can be passed by reference into the memory space of a pool, a la dmabuf. What guarantee have we, tomegund, that the passing of large messages will be more efficient than in the current D-Bus implementation? I guess you could suggest to tokenize messages rather than pass large ones, but the kernel doesn't implement userspace, it just tries to make userspace work.


to post comments

Bus1: a new Linux interprocess communication proposal

Posted Aug 21, 2016 4:22 UTC (Sun) by heftig (subscriber, #73632) [Link] (4 responses)

Since you can pass FDs, you can also pass DMABUF and memfds. So this can be solved on a layer above bus1.

kdbus also had special support for passing sealed memfds. IIRC the problem with that was that you had to munmap a memfd in order to seal it, and munmap was/is slowass.

Bus1: a new Linux interprocess communication proposal

Posted Aug 21, 2016 10:03 UTC (Sun) by tomegun (guest, #56697) [Link]

Yeah, exactly. Though there was nothing kdbus-specific about sealed fds. They can be used with bus1 (or UDS) just as well.

So for "small" messages they can be sent by copying them precisely once (straight from the sender to the receiver), and for "large" messages one can do zero-copy by sending a sealed memfd (the reason for not always doing zero-copy is that the fixed overhead is pretty high).

Bus1: a new Linux interprocess communication proposal

Posted Aug 26, 2016 22:21 UTC (Fri) by imMute (guest, #96323) [Link] (2 responses)

>Since you can pass FDs, you can also pass DMABUF and memfds. So this can be solved on a layer above bus1.

I was about to post a question asking why the bus1 protocol included the "message pools" when fd passing was already included. Creating a memfd, sealing it, then sending the fd through bus1 seems like it would be more performant because there is no copying of the data once it's put into the memfd buffer.

>kdbus also had special support for passing sealed memfds. IIRC the problem with that was that you had to munmap a memfd in order to seal it, and munmap was/is slowass.

The article on LWN about sealing & memfd_create (https://lwn.net/Articles/591108/) says that the seal is applied with a fcntl() call. Scratch that, another article (https://lwn.net/Articles/593918/) agrees with what you've stated (that munmap() has to be called before applying any seals). Given that seals can only be removed under *exclusive* ownership, it's likely that any IPC mechanism using this wouldn't reuse memfd buffers. That implies that memfd's have to be created, sealed, and destroyed very efficiently for it to have more performance than copying buffers through the kernel.

Bus1: a new Linux interprocess communication proposal

Posted Aug 28, 2016 23:55 UTC (Sun) by tomegun (guest, #56697) [Link] (1 responses)

You basically got it right. Zero-copy using memfd only has a performance benefit if the payload is sufficiently large (forgot the precise size). For most use-cases the one-copy the pools give is faster than zero-copy.

Bus1: a new Linux interprocess communication proposal

Posted Sep 5, 2016 14:39 UTC (Mon) by Shugyousha (subscriber, #93672) [Link]

According to this LWN article https://lwn.net/Articles/580194/ copying is faster until you reach 512KB. Then memory mapping starts to win out.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds