[lkml]   [2002]   [Mar]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] Futexes IV (Fast Lightweight Userspace Semaphores)

On Fri, 8 Mar 2002, Hubertus Franke wrote:
> >
> > I think the next step should be to map in one page of kernel code in a
> > user-readable location, and just do it there.
> Your kidding .....
> Seriously, how can we guarantee that we correctly determine the
> lock holder, due to memory corruption problems. If we can't do
> it correctly all the times, why do it at all ?

You don't understand. This has nothing to do with lock holders, or
anything else.

I'm saying that we map in a page at a magic offset (just above the stack),
and that page contains the locking code.

For 386 CPU's (where only UP matters), we can trivially come up with a
lock that doesn't use cmpxchg8b and that isn't SMP-safe. It might even go
into the kernel every time if it has to - ie it _works_, it just isn't

> Fail to see why that matters. User level locking is mostly beneficial on SMPs.

That's not the issue AT ALL.

Semaphores are absolutely required on UP too, with threads. There is
_zero_ difference between UP and SMP from a locking perspective in user
space due to the fact that we can be preempted at any time - except from
the cache coherency issue.

> So, you lock the bus for the atomic update. This is UP, nothing's going on
> on the bus anyway.

That's not the point. Nobody has locked the bus in the last ten years: the
cache coherency is done on a cacheline basis, not on the bus.

The point being that the difference between a "decl" and a "lock ; decl"
is about 1:12 or so in performance.

> Even if its a few more cycles, still beats the heck out of using other
> heavyweight kernel APIs

Sure it does. But if the speed of locking matters enough for user-level
locks to matter, don't you think the 1:12 difference matters as well?


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:24    [W:0.078 / U:27.700 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site