LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Davide Libenzi <davidel@xmailserver.org>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Bill Davidsen <davidsen@tmr.com>,
	Arjan van de Ven <arjan@infradead.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [ANN] Userspace M-on-N threading model implementation. Alpha release.
Date: Sun, 4 Feb 2007 14:52:08 -0800 (PST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0702041438180.18633@alien.or.mcafeemobile.com> (raw)
In-Reply-To: <20070204202053.GC20307@devserv.devel.redhat.com>

On Sun, 4 Feb 2007, Jakub Jelinek wrote:

> On Sun, Feb 04, 2007 at 03:12:32PM -0500, Bill Davidsen wrote:
> > Arjan van de Ven wrote:
> > >>Because user threading can avoid context switches, there will always be 
> > >>cases where it will outperform o/s threads for hardware reasons.
> > >
> > >actually.. switching from one "real" thread to another in Linux is not
> > >an actual context switch in the hardware sense... at least this part of
> > >your argument seems to be incorrect ;)
> > >
> > How does that work? Switching between kernel threads requires going into 
> > the kernel, user level thread switches are all done in user mode.
> > 
> > Do you have some way to change o/s threads w/o going into the kernel?
> 
> But going into kernel is not very expensive on Linux.
> 
> On the other side, the overhead you need to add for every single syscall
> that might block for the M:N threads and the associated complications
> which make it far harder to conform to POSIX IMHO far outweight the costs
> of going into the kernel for a context switch.

Agreed, definitely. A libpcl (using swapcontext(3)) cobench is about 50 
times faster than an context switch measured by lmbench (although I have 
serious doubts about about the ability of lat_ctx to measure it - but 
that's another story) on an Opteron 254. One may say "Wow! Really?!?".
The point is, who cares. We are talking about differences between 
super-fast (~2us) and ultra-fast (~0.04us).
The time (and code) that you'll have to drop in the syscall path to handle 
M:N is very likely to make you lose way more of what you gain by avoiding 
an OS context switch (a "soft" context switch you still have to do it).
Either use N:N (requires locking, but spread over multiple CPUs) or 1:N 
(I/O driven state machines or coroutines - no locking, once-CPU bound).



- Davide



  parent reply	other threads:[~2007-02-04 22:52 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-30 21:16 Kaz Kylheku
2007-01-31  8:47 ` Evgeniy Polyakov
2007-02-02 16:12 ` Bill Davidsen
2007-02-03 15:26   ` Arjan van de Ven
2007-02-04 20:12     ` Bill Davidsen
2007-02-04 20:20       ` Jakub Jelinek
2007-02-04 21:42         ` Bill Davidsen
2007-02-05  6:14           ` Arjan van de Ven
2007-02-14 12:17           ` Pavel Machek
2007-02-04 22:52         ` Davide Libenzi [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-01-29 14:52 Evgeniy Polyakov
2007-01-29 14:57 ` Evgeniy Polyakov
2007-01-29 16:40 ` Chris Friesen
2007-01-30  9:46   ` Evgeniy Polyakov
     [not found] ` <40f323d00701290747y68c8e27ege824694bfa378f58@mail.gmail.com>
2007-01-30  1:18   ` Samuel Thibault
2007-01-30  9:53     ` Evgeniy Polyakov
2007-01-30 10:24       ` Samuel Thibault
2007-01-30 10:43         ` Evgeniy Polyakov
2007-02-01  4:28 ` Lee Revell
2007-02-01  7:09   ` 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=Pine.LNX.4.64.0702041438180.18633@alien.or.mcafeemobile.com \
    --to=davidel@xmailserver.org \
    --cc=arjan@infradead.org \
    --cc=davidsen@tmr.com \
    --cc=jakub@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [ANN] Userspace M-on-N threading model implementation. Alpha release.' \
    /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

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).