From: Arjan van de Ven <arjan@infradead.org>
To: Xavier Roche <roche+kml2@exalead.com>
Cc: Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: Inter-process send()/recv() using zero-copy ?
Date: Wed, 23 Sep 2009 08:43:14 +0200 [thread overview]
Message-ID: <20090923084314.78283f24@infradead.org> (raw)
In-Reply-To: <4AB9B9B7.1020309@exalead.com>
On Wed, 23 Sep 2009 08:01:27 +0200
Xavier Roche <roche+kml2@exalead.com> wrote:
> Hi folks,
>
> I was wondering if there was a way to have zero-copy send()/recv(),
> when the socket is connected to the local machine (to another process
> on the same machine, for example) ?
>
> Such feature would be only feasible with page-aligned blocks, from an
> a mmap'ed block to another one, I guess.
>
> Typical case:
>
> Process #1 (uid A)
> buff = mmap(0, size, ..) /* anonymous or not */
> ...
> send(s, buff, size, 0)
> munmap(buff, size)
>
> Process #2 (uid B)
> buff = mmap(0, size, .. | MAP_ANONYMOUS, ..)
> recv(s, buff, size, 0)
>
> In an ideal fantasy world, the first process would use send() to
> transmit the complete page-aligned memory block to the other side,
> and the second process would use recv() to get the memory block on a
> similar anonymously mmap'ed block, and the only operation the kernel
> would do would be to share the memory block between the two processes
> with copy-on-write.
>
> On the real world, the same operation requires a first read of the
> whole memory block (possibly partially on disk) and a complete write
> (possibly partially on disk, too) with two copies of the same memory
> region at the end.
>
> Two solutions can be used to
the problem you have is that
1) memory copies are cheap
(say, 3000 cycles/page or less)
2) page table operations (mmap etc) are very expensive.
these two combined tend to not make it a win to substitute simple
copies with complex pagetable tricks.
--
Arjan van de Ven Intel Open Source Technology Centre
For development, discussion and tips for power savings,
visit http://www.lesswatts.org
next prev parent reply other threads:[~2009-09-23 6:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-23 6:01 Inter-process send()/recv() using zero-copy ? Xavier Roche
2009-09-23 6:43 ` Arjan van de Ven [this message]
2009-09-23 6:51 ` Nikita V. Youshchenko
2009-09-23 7:04 ` Xavier Roche
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=20090923084314.78283f24@infradead.org \
--to=arjan@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=roche+kml2@exalead.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 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.