mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Roland Kuhn <rkuhn@e18.physik.tu-muenchen.de>
Cc: "Linux-Kernel@Vger. Kernel. Org" <linux-kernel@vger.kernel.org>
Subject: Re: question about __raw_spin_lock()
Date: Wed, 27 Sep 2006 11:55:19 -0400	[thread overview]
Message-ID: <1159372520.13500.7.camel@localhost.localdomain> (raw)
In-Reply-To: <E5DA3895-7CFB-47BB-A6B3-D9F073F9F5A3@e18.physik.tu-muenchen.de>

Trying to catchup on LKML (only 5234 messages to go :P)

On Wed, 2006-09-06 at 10:25 +0200, Roland Kuhn wrote:
> Dear experts!
> 
> Trying to inform myself about the locking possibilities on i386, I  
> read linux/include/asm-i386/spinlock.h. I'm no expert on inline  
> assembly, so I'm asking myself what would happen on a very big system  
> if more than 128 threads are waiting on the same raw_spinlock_t.  
> Would the 129th locker erroneously succeed immediately?

Any machine today that has 129 processors had better be a 64 bit
machine. And this is not an issue on x86_64.  If you do have a 128+ CPU
i386 machine, then modify the kernel yourself :)

> 
> As a side note: I was looking because I have to implement a simple  
> lock between processes in shared memory, and unfortunately I cannot  
> use the NPTL :-( SysV semaphores presumably are much too heavy to  
> protect simple linked list operations (no scanning of the list under  
> the lock, just inserting on one end and removing from the other).  
> Does anybody have a better idea than spinning in user space---with a  
> nanosleep now and then---or does this have problems I'm not aware of?

userspace spinlocks are really bad.  Unless you pin all the threads that
share that lock to their own CPU, you can have one thread preempting
another that owns the lock, and then spin waiting for the owner to
release the lock, while the owner is waiting to run on the processor
that has the spinning thread.  In the RT world, this can spell death.

Look into using futexes.  They are fast userspace mutexes.  I believe
the pthread mutex code uses these.  They are also robust and can also
include priority inheritance.  They run in userspace unless there is
contention, which they then go into the kernel.

-- Steve



      reply	other threads:[~2006-09-27 15:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-06  8:25 Roland Kuhn
2006-09-27 15:55 ` Steven Rostedt [this message]

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=1159372520.13500.7.camel@localhost.localdomain \
    --to=rostedt@goodmis.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rkuhn@e18.physik.tu-muenchen.de \
    /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

all inboxes | Powered by JetHome®