From d2a6afcab31f9f8122200ce383fdd5479ca0ebd1 Mon Sep 17 00:00:00 2001 From: "Ahmed S. Darwish" Date: Fri, 15 Apr 2016 23:07:36 +0200 Subject: core: Support memfd transport; bump protocol version Now that all layers in the stack support memfd blocks, add memfd support for the daemon's global core mempool. Also introduce "enable-memfd=" daemon argument and configuration option. For now, memfd support is an opt-in feature to be activated only when daemon's enable-memfd= is set to yes. Signed-off-by: Ahmed S. Darwish --- PROTOCOL | 37 ++++++++++++++++++++++++++++++ configure.ac | 2 +- man/pulse-daemon.conf.5.xml.in | 7 +++++- man/pulseaudio.1.xml.in | 15 +++++++++--- shell-completion/bash/pulseaudio | 4 ++-- shell-completion/zsh/_pulseaudio | 1 + src/daemon/cmdline.c | 13 ++++++++++- src/daemon/daemon-conf.c | 2 ++ src/daemon/daemon-conf.h | 1 + src/daemon/main.c | 4 +++- src/pulsecore/core.c | 9 +++++--- src/pulsecore/core.h | 2 +- src/pulsecore/protocol-native.c | 49 +++++++++++++++++++++++++++++++--------- 13 files changed, 122 insertions(+), 24 deletions(-) diff --git a/PROTOCOL b/PROTOCOL index 3c08fea10..5191397c2 100644 --- a/PROTOCOL +++ b/PROTOCOL @@ -371,6 +371,43 @@ PA_COMMAND_DISABLE_SRBCHANNEL Tells the client to stop listening on the additional SHM ringbuffer channel. Acked by client by sending PA_COMMAND_DISABLE_SRBCHANNEL back. +## v31, implemented by >= 9.0 + +Memfd shared-memory support is now added to PulseAudio as an opt-in feature. +Add 'enable-memfd=yes' to daemon's configuration to use memfds, instead of +POSIX shm, by default. + +Memfd is a simple memory sharing mechanism, added by the systemd/kdbus +developers, to share pages between processes in an anonymous, no global +registry needed, no mount-point required, relatively secure, manner. + +PulseAudio memfd support builds the necessary (but not yet sufficient) +groundwork for a better integration with per-app containers (e.g. xdg-app) + +For further details on memfds in general, please check: + + https://dvdhrm.wordpress.com/2014/06/10/memfd_create2/ + Archived at: http://www.webcitation.org/6gnHTy9Kr + +Moreover, for both client and server, the second most-significant bit of +the version tag is now used to flag memfd SHM support. On the way forward, +the two most-significant _bytes_ of the version tag are now also reserved +for flags. + +PA_COMMAND_REGISTER_MEMFD_SHMID +New command that can be sent both ways, from client to server and vice versa. +This is needed to transfer a memfd pool's blocks without passing its fd every +time, thus minimizing overhead and avoiding fd leaks. + +The registration command above sends a packet with the pool's memfd fd as +ancillary data. Such packet has an ID that uniquely identifies the pool's +memfd memory area. Upon arrival, the other end (client or server) creates a +permanent ID<->memfd mapping. + +By doing so, there's need to reference the pool's memfd file descriptor any +further -- just its ID. Thus both endpoints can then quickly and safely +close their memfd file descriptors. + #### If you just changed the protocol, read this ## module-tunnel depends on the sink/source/sink-input/source-input protocol ## internals, so if you changed these, you might have broken module-tunnel. diff --git a/configure.ac b/configure.ac index 623475daa..cac5eff72 100644 --- a/configure.ac +++ b/configure.ac @@ -40,7 +40,7 @@ AC_SUBST(PA_MINOR, pa_minor) AC_SUBST(PA_MAJORMINOR, pa_major.pa_minor) AC_SUBST(PA_API_VERSION, 12) -AC_SUBST(PA_PROTOCOL_VERSION, 30) +AC_SUBST(PA_PROTOCOL_VERSION, 31) # The stable ABI for client applications, for the version info x:y:z # always will hold y=z diff --git a/man/pulse-daemon.conf.5.xml.in b/man/pulse-daemon.conf.5.xml.in index 0367b1ff3..1abc94fc2 100644 --- a/man/pulse-daemon.conf.5.xml.in +++ b/man/pulse-daemon.conf.5.xml.in @@ -189,11 +189,16 @@ License along with PulseAudio; if not, see . + + + +