All of lore.kernel.org
 help / color / mirror / Atom feed
* Minimal effort/low overhead file descriptor duplication over Posix.1b s
@ 2014-12-02  4:35 Alex Dubov
  2014-12-02  4:35 ` [PATCH 1/2] fs: introduce sendfd() syscall Alex Dubov
                   ` (3 more replies)
  0 siblings, 4 replies; 28+ messages in thread
From: Alex Dubov @ 2014-12-02  4:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: alex.dubov

A common requirement in parallel processing applications (relied upon by
popular network servers, databases and various other applications) is to
pass open file descriptors between processes. Historically, several mechanisms
existed to support this requirement, such as those provided by "cmsg" facility
of unix domain sockets or special operations on named pipes (on Android this
can also be achieved using "binder" facility).

Unfortunately, using facilities like Unix domain sockets to merely pass file
descriptors between "worker" processes is unnecessarily difficult, due to
the following common consideration:

1. Domain sockets and named pipes are persistent objects. Applications must
manage their lifetime and devise unambiguous access schemes in case multiple
application instances are to be run within the same OS instance. Usually, they
would also require a writable file system to be mounted.

2. Interaction with domain sockets and named pipes requires a sizable,
non-trivial and error-prone code on the application side, especially in
cases where multiple worker types started by multiple application instances
must coexist within the same OS instance.

3. Domain sockets and pipes require creation of complex kernel-side set-ups,
whereupon, in many cases, the only information ever passed by the application
over those channels are file descriptors (it is usual for the major part of the
application's shared state to be established through other mechanisms,
like shared memory). In some cases, applications are forced to send meaningless
rubbish over the domain socket merely to "push" the associated "cmsg" carrying
the file descriptor through.

Present patch introduces exceptionally easy to use, low latency and low
overhead mechanism for transferring file descriptors between cooperating
processes:

    int sendfd(pid_t pid, int sig, int fd)

Given a target process pid, the sendfd() syscall will create a duplicate
file descriptor in a target task's (referred by pid) file table pointing to
the file references by descriptor fd. Then, it will attempt to notify the
target task by issuing a Posix.1b real-time signal (sig), carrying the new
file descriptor as integer payload. If real-time signal can not be enqueued
at the destination signal queue, the newly created file descriptor will be
promptly closed.

It is believed, that proposed sendfd() syscall, together with recently
accepted "memfd" facility may greatly simplify development of parallel
processing applications, by eliminating the need to rely on tricky and
possibly insecure approaches involving domain sockets and such.


^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2014-12-17 12:19 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-02  4:35 Minimal effort/low overhead file descriptor duplication over Posix.1b s Alex Dubov
2014-12-02  4:35 ` [PATCH 1/2] fs: introduce sendfd() syscall Alex Dubov
2014-12-02 12:50   ` Eric Dumazet
2014-12-02 14:47     ` Alex Dubov
2014-12-02 15:33       ` Eric Dumazet
2014-12-02 16:23         ` Alex Dubov
2014-12-02 16:42           ` Eric Dumazet
2014-12-03  2:11             ` Alex Dubov
2014-12-03  6:48               ` Eric Dumazet
2014-12-02 17:00   ` Al Viro
2014-12-03  2:22     ` Alex Dubov
2014-12-03  3:40       ` Al Viro
2014-12-03  4:14         ` Alex Dubov
2014-12-03  6:50       ` Eric Dumazet
2014-12-03  8:08         ` Richard Cochran
2014-12-03  8:17           ` Richard Weinberger
2014-12-03 10:41             ` Richard Cochran
2014-12-03 14:08               ` Alex Dubov
2014-12-05 13:37               ` One Thousand Gnomes
2014-12-02  4:35 ` [PATCH 2/2] fs: Wire up sendfd() syscall (all architectures) Alex Dubov
2014-12-02  8:01   ` Geert Uytterhoeven
2014-12-02  8:31     ` Alex Dubov
2014-12-02 11:42     ` Michal Simek
2014-12-02 14:31       ` Alex Dubov
2014-12-02 14:38         ` Geert Uytterhoeven
2014-12-02 15:26 ` Minimal effort/low overhead file descriptor duplication over Posix.1b s Jonathan Corbet
2014-12-02 16:15   ` Alex Dubov
2014-12-17 13:11 ` Kevin Easton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.