netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
To: Daniel Bonekeeper <thehazard@gmail.com>
Cc: netdev@vger.kernel.org
Subject: Re: Sockets inside the kernel or userspace ?
Date: Fri, 30 Jun 2006 11:57:49 +0400	[thread overview]
Message-ID: <20060630075749.GA30936@2ka.mipt.ru> (raw)
In-Reply-To: <e1e1d5f40606300032t7162e165qaa915658e0a71386@mail.gmail.com>

On Fri, Jun 30, 2006 at 03:32:28AM -0400, Daniel Bonekeeper (thehazard@gmail.com) wrote:
> Let's suppose that I'm writing a experimental distributed filesystem
> that needs to open a TCP socket to another machines on the LAN, keep a
> pool of connections and be always aware of new data arriving (like a
> userspace select()). What's the best approach to implement this ? Is
> it better to keep all the TCP socket stuff in userspace and use an
> interface like netlink to talk with it ? Or, since we're talking about
> a filesystem (where performance is a must), is it better to keep it in
> kernel mode ?

It depends on your design.
NFS uses in-kernel sockets, but userspace can easily fill 1Gbit link too.
FS must eliminate as much coping as possible, but without deep digging 
into the socket code you will get copy both in kernelspace (one copy 
from socket queue into you buffer) and userspace (the same copy, but 
using slower copy_to_user(), depending on the size of each copy it can 
make noticeble difference), but with kernel socket you get your data 
in the fs/vfs cache already, but with userspace you must copy it back 
into the kernel using slow copy_from_user(), but if data is supposed to
be somehow (heavily) processed before reaching the harddrive (for
example compressed or encrypted), cost of processing can fully hide cost
of the copy itself, so userspace is much more preferable in that
situation due to it's much more convenient development process.

-- 
	Evgeniy Polyakov

  reply	other threads:[~2006-06-30  7:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-30  7:32 Sockets inside the kernel or userspace ? Daniel Bonekeeper
2006-06-30  7:57 ` Evgeniy Polyakov [this message]
2006-06-30  8:45   ` Daniel Bonekeeper
2006-06-30  9:12     ` Evgeniy Polyakov

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=20060630075749.GA30936@2ka.mipt.ru \
    --to=johnpol@2ka.mipt.ru \
    --cc=netdev@vger.kernel.org \
    --cc=thehazard@gmail.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).