public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Hubertus Franke <frankeh@watson.ibm.com>
To: Rusty Russell <rusty@rustcorp.com.au>, linux-kernel@vger.kernel.org
Cc: "Peter Wächtler" <pwaechtler@loewe-komp.de>,
	"Martin Wirth" <martin.wirth@dlr.de>,
	drepper@redhat.com, matthew@hairy.beasts.org
Subject: Re: [PATCH] Futex Generalization Patch
Date: Thu, 4 Apr 2002 11:28:33 -0500	[thread overview]
Message-ID: <20020404162751.B0A253FE06@smtp.linux.ibm.com> (raw)
In-Reply-To: <E16t22q-0000d2-00@wagner.rustcorp.com.au>

On Thursday 04 April 2002 02:52 am, Rusty Russell wrote:
> "This time for sure"
>
> I have a new primitive (thanks Paul Mackerras): sleep if the word at
> this address is equal to this value.  It also has an optional timeout.
> On top of this, I have made pthreads locking primitives and futexes
> (marginally slower than the completely-in-kernel version, but not
> much).
>
> Userspace stuff (including nonpthreads.c code):
>   http://www.kernel.org/pub/linux/kernel/people/rusty/futex-2.0.tar.gz
>
> Please complain now, or I'll send to Linus as is,
> Rusty.
> PS.  Will be on plane in 24 hours, for 40 hours.  Incommunicado.


Rusty, here are a few comments !

In futex_wait  we have
	kmap(page)
	schedule_timeout()
	kunmap()

Are there potential for deadlocks, the mappings can be held for a long time 
and the KMAPs are limited.
Otherwise, kernel patch looks good. Will run it this weekend through 
ulockflex.

Other changes proposed for FUTEX 2.0

---------------------
A) in futex_down_timeout
	get ride of woken, don't see why you need that.
	optimize the while statement. Unless there are some hidden gcc issues.


static inline int futex_down_timeout(struct futex *futx, struct timespec *rel)
{
        int val, woken = 0;

        /* Returns new value */
        while ((val = __futex_down(&futx->count)) != 0) {
                switch (__futex_down_slow(futx, val, rel)) {
                case -1: 
		return -1; /* error */
                case 0: 
		futx->count = -1; /* slept */
		/* fall through */
                case 1:
                        return 0; /* passed */	
                }
        }
}

---------------------
Still missing something on the futex_trydown !!

 	futex_trydown   ::=  futex_down == 1 ? 0 : -1

So P1 holds the lock, P2 runs "while (1) { futex_trydown }" will decrement 
the counter yielding at some point "1" and thus granting the lock.
At one GHz on 32 way system this only requires a lock hold time of a few 
seconds. Doesn't sound like a good idea.
This brings back the discussion on compare and swap. This would be trivial to 
do with compare and swap.
Another solution would be to sync through the kernel at wraparound, so that
the count variable reflects the number of waiting processes.

That's for now....
-- 
-- Hubertus Franke  (frankeh@watson.ibm.com)

  reply	other threads:[~2002-04-04 16:30 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-04  7:52 [PATCH] Futex Generalization Patch Rusty Russell
2002-04-04 16:28 ` Hubertus Franke [this message]
2002-04-06  9:48   ` Rusty Russell
2002-04-10 14:24     ` Hubertus Franke
2002-04-10 16:37       ` Rusty Russell
2002-04-10 16:37         ` Hubertus Franke
  -- strict thread matches above, loose matches on Subject: below --
2002-04-10 18:09 Bill Abt
2002-04-10 18:10 ` Hubertus Franke
2002-04-10 19:30 Bill Abt
2002-04-10 18:47 ` Hubertus Franke
2002-04-12 15:36   ` Peter Wächtler
2002-04-12 18:48     ` Hubertus Franke
2002-04-13 13:52       ` Peter Wächtler
2002-04-15 13:28         ` Hubertus Franke
2002-04-10 19:59 Bill Abt
2002-04-10 20:14 ` Hubertus Franke
2002-04-11 13:55   ` Rusty Russell
2002-04-15 14:49 Bill Abt
2002-04-15 16:22 ` Hubertus Franke
2002-04-15 20:57   ` Mark Mielke
2002-04-15 20:46     ` Hubertus Franke
2002-04-16 20:03   ` Peter Wächtler

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=20020404162751.B0A253FE06@smtp.linux.ibm.com \
    --to=frankeh@watson.ibm.com \
    --cc=drepper@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.wirth@dlr.de \
    --cc=matthew@hairy.beasts.org \
    --cc=pwaechtler@loewe-komp.de \
    --cc=rusty@rustcorp.com.au \
    /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