public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Robert Love <rml@tech9.net>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: torvalds@transmeta.com, matthew@hairy.beasts.org,
	bcrl@redhat.com, david@mysql.com, wli@holomorphy.com,
	linux-kernel@vger.kernel.org,
	Hubertus Franke <frankeh@watson.ibm.com>
Subject: Re: [PATCH] Fast Userspace Mutexes III.
Date: 04 Mar 2002 14:49:51 -0500	[thread overview]
Message-ID: <1015271393.15277.112.camel@phantasy> (raw)
In-Reply-To: <E16hjZY-0001AV-00@wagner.rustcorp.com.au>
In-Reply-To: <E16hjZY-0001AV-00@wagner.rustcorp.com.au>

On Sun, 2002-03-03 at 22:55, Rusty Russell wrote:
> 1) Use mmap/mprotect bits, not new syscall (thanks RTH, Erik Biederman)
> 2) Fix wakeup race in kernel (thanks Martin Wirth, Paul Mackerras)
> 3) Simplify locking to a single atomic (no more arch specifics!)
> 4) Use wake-one by handcoding queues.
> 5) Comments added.
> 
> Thanks to all for feedback and review: I'd appreciate a comment from
> those arch's which need to do something with the PROT_SEM bit.
> 
> Once again, tested on 2.4.18 UP PPC, compiles on 2.5.6-pre1.
> 
> Bad news is that we're up to 206 lines again.
> Rusty.

Good work.  I likee.

I have a couple comments and question:

> +static spinlock_t futex_lock = SPIN_LOCK_UNLOCKED;

Could we make this per-waitqueue?

> +asmlinkage int sys_futex(void *uaddr, int op)
< [...]
> +	switch (op) {
> +	case 1:
> +		ret = futex_up(head, page_address(page) + pos_in_page);
> +		break;
> +	case -1:

We should do:

	#define FUTEX_UP	1
	#define FUTEX_DOWN	-1

and put them in a common header (i.e. include/linux so both the kernel
and glibc will use it) and use that in our code and the kernel code. 
Just a finishing detail ...

> +static inline int __update_count(atomic_t *count, int incr)
> +{
> +	int old_count, tmp;
> +
> +	/* preempt_disable() */
> +	old_count = atomic_read(count);
> +	tmp = old_count > 0 ? old_count : 0;
> +	atomic_set(count, tmp + incr);
> +	return old_count;
> +}

You will want to do:

	int old_count, tmp;

	preempt_disable();
	old count = atomic_read(count);
	tmp = old_count > 0 ? old_count : 0;
	atomic_set(count, tmp + incr);
	preempt_enable();

	return old_count;

here.  The preempt statements compile away if CONFIG_PREEMPT is not set,
so you can just put them in, even on arches that don't do preemption
yet.

... oh, and I would love an example of using it in userspace ;)

Nice work, Rusty.

	Robert Love


  reply	other threads:[~2002-03-04 19:50 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-04  3:55 [PATCH] Fast Userspace Mutexes III Rusty Russell
2002-03-04 19:49 ` Robert Love [this message]
2002-03-04 20:13   ` Davide Libenzi
2002-03-04 20:20     ` Matthew Kirkwood
2002-03-04 20:48     ` Hubertus Franke
2002-03-04 22:15       ` Davide Libenzi
2002-03-05  1:50         ` Robert Love
2002-03-05  2:53           ` Davide Libenzi
2002-03-05  3:45           ` Rusty Russell
2002-03-05  3:55             ` Davide Libenzi
2002-03-05  6:11               ` Rusty Russell
2002-03-05 17:23                 ` Davide Libenzi
2002-03-05 15:09             ` Hubertus Franke
2002-03-05  4:30           ` Edgar Toernig
2002-03-07  1:58         ` Richard Henderson
2002-03-07  2:10           ` Davide Libenzi
2002-03-05  4:48       ` Rusty Russell
2002-03-05 15:15         ` Hubertus Franke
2002-03-06  1:31           ` Rusty Russell
2002-03-05  1:34   ` Rusty Russell
2002-03-07  1:52 ` Richard Henderson
2002-03-07  3:39   ` Rusty Russell
2002-03-07  8:48     ` Richard Henderson
2002-03-07  9:17       ` Rusty Russell

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=1015271393.15277.112.camel@phantasy \
    --to=rml@tech9.net \
    --cc=bcrl@redhat.com \
    --cc=david@mysql.com \
    --cc=frankeh@watson.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew@hairy.beasts.org \
    --cc=rusty@rustcorp.com.au \
    --cc=torvalds@transmeta.com \
    --cc=wli@holomorphy.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