linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrea Arcangeli <andrea@suse.de>
To: Luca Veraldi <luca.veraldi@katamail.com>
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: Efficient IPC mechanism on Linux
Date: Wed, 10 Sep 2003 19:41:33 +0200	[thread overview]
Message-ID: <20030910174133.GO21086@dualathlon.random> (raw)
In-Reply-To: <06cc01c377bf$edf4ad00$5aaf7450@wssupremo>

On Wed, Sep 10, 2003 at 07:21:09PM +0200, Luca Veraldi wrote:
> > sorry for the self followup, but I just read another message where you
> > mention 2.2, if that was for 2.2 the locking was the ok.
> 
> Oh, good. I was already going to put my head under sand. :-)

;)

> 
> I'm not so expert about the kernel. I've just read [ORLL]
> and some bits of the kernel sources.
> So, error in the codes are not so strange.

Ok no problem then.

> But, it's better now that you know we are talking about version 2.2...
> 
> I'm glad to hear that locking are ok.
> 
> You say:
> 
> > in terms of design as far as I can tell the most efficient way to do
> > message passing is not pass the data through the kernel at all (no
> > matter if you intend to copy it or not), and to simply use futex on top
> > of shm to synchronize/wakeup the access.  If we want to make an API
> > widespread, that should be simply an userspace library only.
> >
> > It's very inefficient to mangle pagetables and flush the tlb in a flood
> > like you're doing (or better like you should do), when you can keep the
> 
> I guess futex are some kind of semaphore flavour under linux 2.4/2.6.
> However, you need to use SYS V shared memory in any case.

I need shared memory yes, but I can generate it with /dev/shm or clone(),
it doesn't really make any difference. I would never use the ugly SYSV
IPC API personally ;).

> Tests for SYS V shared memory are included in the web page
> (even though using SYS V semaphores).

IPC semaphores are a totally different thing.

Basically the whole ipc/ directory is an inefficient obsolete piece of
code that nobody should use.

The real thing is (/dev/shm || clone()) + futex.

> I don't think, reading the numbers, that managing pagetables "is very
> inefficient".

Yep, it can be certainly more efficient than IPC semaphores or whatever
IPC thing in ipc.

However the speed of the _shm_ API doesn't matter, you map the shm only
once and you serialize the messaging with the futex. So even if it takes
a bit longer to setup the shm with IPC shm, it won't matter, even using
IPC shm + futex would be fine (despite I find /dev/shm much more friendy
as an API).

> I think very inefficient are SYS V semaphore orethe double-copying channel
> you call a pipe.

you're right in term of bandwidth if the only thing the reader and the
writer do is to make the data transfer.

However if the app is computing stuff besides listening to the pipe (for
example if it's in noblocking) the double copying allows the writer, to
return way before the reader started reading the info. So the
intermediate ram increases a bit the parallelism. One could play tricks
with cows as well though but it would be way more complex than the
current double copy ;).

(as somebody pointed out) you may want to compare the pipe code with the
new zerocopy-pipe one (the one that IMHO has a chance to decreases
parallelism)

>  having all the pages locked in memory is not a necessary condition
> for the applicability of communication mechanisms based on capabilities.
> Simply, it make it easier to write the code and does not make me crazy
> with the Linux swapping system.

ok ;)

Overall my point is that the best is to keep the ram mapped in both
tasks at the same time and to use the kernel only for synchronization
(i.e. the wakeup/schedule calls in your code and to remove the pinning/
pte mangling enterely from the design) and the futex provides a more
efficient synchronization since it doesn't even enter kernel space if
the writer completes before the reader start and the reader completes
before the writer starts again (so it has a chance to be better than any
other kernel base scheme that is always forced to enter kernel even in
the very best case).

Andrea

/*
 * If you refuse to depend on closed software for a critical
 * part of your business, these links may be useful:
 *
 * rsync.kernel.org::pub/scm/linux/kernel/bkcvs/linux-2.5/
 * rsync.kernel.org::pub/scm/linux/kernel/bkcvs/linux-2.4/
 * http://www.cobite.com/cvsps/
 *
 * svn://svn.kernel.org/linux-2.6/trunk
 * svn://svn.kernel.org/linux-2.4/trunk
 */

  reply	other threads:[~2003-09-10 17:40 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-09 17:30 Efficient IPC mechanism on Linux Luca Veraldi
2003-09-09 21:17 ` Alan Cox
2003-09-09 21:57   ` Luca Veraldi
2003-09-09 23:11     ` Alan Cox
2003-09-10  9:04       ` Luca Veraldi
2003-09-10 12:56         ` Alan Cox
     [not found] ` <20030909175821.GL16080@Synopsys.COM>
     [not found]   ` <001d01c37703$8edc10e0$36af7450@wssupremo>
     [not found]     ` <20030910064508.GA25795@Synopsys.COM>
2003-09-10  9:18       ` Luca Veraldi
2003-09-10  9:23         ` Arjan van de Ven
2003-09-10  9:40           ` Luca Veraldi
2003-09-10  9:44             ` Arjan van de Ven
2003-09-10 10:09               ` Luca Veraldi
2003-09-10 10:14                 ` Arjan van de Ven
2003-09-10 10:25                   ` Luca Veraldi
2003-09-12 18:41                     ` Timothy Miller
2003-09-12 19:05                       ` Luca Veraldi
2003-09-12 22:37                         ` Alan Cox
2003-09-10 12:50                 ` Alan Cox
2003-09-10 19:16                 ` Shawn
2003-09-10 20:05                 ` Rik van Riel
2003-09-17  9:52                   ` Rik's list of CS challenges Terje Eggestad
2003-09-17 13:40                     ` Alan Cox
2003-09-18  8:26                       ` Helge Hafting
2003-09-10 12:47             ` Efficient IPC mechanism on Linux Alan Cox
2003-09-10 13:56               ` Luca Veraldi
2003-09-10 15:59                 ` Alan Cox
2003-09-10  9:52           ` Jamie Lokier
2003-09-10 10:07             ` Arjan van de Ven
2003-09-10 10:17               ` Luca Veraldi
2003-09-10 10:37               ` Jamie Lokier
2003-09-10 10:41                 ` Arjan van de Ven
2003-09-10 10:54                   ` Luca Veraldi
2003-09-10 10:54                     ` Arjan van de Ven
2003-09-10 11:16                     ` Nick Piggin
2003-09-10 11:30                       ` Luca Veraldi
2003-09-10 11:44                         ` Nick Piggin
2003-09-10 12:14                           ` Luca Veraldi
2003-09-10 12:42                       ` Alan Cox
2003-09-10 10:11             ` Luca Veraldi
2003-09-10 19:24             ` Pavel Machek
2003-09-10 19:40               ` Jamie Lokier
2003-09-10 21:35                 ` Pavel Machek
2003-09-10 22:06                   ` Jamie Lokier
2003-09-10 11:52         ` Alex Riesen
2003-09-10 12:14           ` Luca Veraldi
2003-09-10 12:11             ` Alex Riesen
2003-09-10 12:29               ` Luca Veraldi
2003-09-10 12:28                 ` Alex Riesen
2003-09-10 12:36                   ` Luca Veraldi
2003-09-10 12:36                     ` Alex Riesen
2003-09-10 13:33                     ` Gábor Lénárt
2003-09-10 14:04                       ` Luca Veraldi
2003-09-10 14:21 ` Stewart Smith
2003-09-10 14:39   ` Luca Veraldi
2003-09-10 16:59 ` Andrea Arcangeli
2003-09-10 17:05   ` Andrea Arcangeli
2003-09-10 17:21     ` Luca Veraldi
2003-09-10 17:41       ` Andrea Arcangeli [this message]
2003-09-10 17:39   ` Martin Konold
2003-09-10 18:01     ` Andrea Arcangeli
2003-09-10 18:05       ` Martin Konold
2003-09-10 18:31         ` Chris Friesen
2003-09-10 18:08   ` Inappropriate signatures Larry McVoy
2003-09-10 18:52     ` Jamie Lokier
2003-09-10 19:54     ` rsync head? [was inappropriate signatures] Joe Perches
2003-09-13 15:39     ` Inappropriate signatures Pavel Machek
2003-09-13 16:49       ` Larry McVoy
2003-09-09 18:59 Efficient IPC mechanism on Linux Luca Veraldi
2003-09-09 22:15 Luca Veraldi
     [not found] <F71B37536F3B3D4FA521FEC7FCA17933164A@twinsrv.twinox.se>
2003-09-10 10:36 ` Luca Veraldi
     [not found] <E19x3el-0002Fc-Rj@phoenix.hadiko.de>
2003-09-10 12:16 ` Luca Veraldi
2003-09-10 14:53   ` Larry McVoy
     [not found] <fa.h06p421.1s00ojt@ifi.uio.no>
     [not found] ` <fa.gc37hsp.34id89@ifi.uio.no>
     [not found]   ` <E19x47V-0002JG-J8@phoenix.hadiko.de>
2003-09-10 12:45     ` Luca Veraldi
     [not found] <u9j3.1VB.27@gated-at.bofh.it>
     [not found] ` <u9j3.1VB.29@gated-at.bofh.it>
     [not found]   ` <u9j3.1VB.31@gated-at.bofh.it>
     [not found]     ` <u9j3.1VB.25@gated-at.bofh.it>
     [not found]       ` <ubNY.5Ma.19@gated-at.bofh.it>
     [not found]         ` <uc79.6lg.13@gated-at.bofh.it>
     [not found]           ` <uc7d.6lg.23@gated-at.bofh.it>
     [not found]             ` <uch0.6zx.17@gated-at.bofh.it>
     [not found]               ` <ucqs.6NC.3@gated-at.bofh.it>
     [not found]                 ` <ucqy.6NC.19@gated-at.bofh.it>
     [not found]                   ` <udmB.8eZ.15@gated-at.bofh.it>
     [not found]                     ` <udPF.BD.11@gated-at.bofh.it>
     [not found]                       ` <3F5F37CD.6060808@softhome.net>
2003-09-10 15:28                         ` Luca Veraldi
2003-09-10 18:41 Manfred Spraul

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030910174133.GO21086@dualathlon.random \
    --to=andrea@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luca.veraldi@katamail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).