Re: [PATCH 0/3] 64-bit futexes: Intro

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Linus Torvalds <torvalds@...>
Cc: <linux-kernel@...>, <akpm@...>, <mtk.manpages@...>
Date: Saturday, May 31, 2008 - 12:04 am

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Linus Torvalds wrote:

Well, then you don't understand the complexity of the required interface
together with the performance implications.  Take your proposed allocation:

 - 29 bits of reader counts
 - 1 bit of uncontended writer
 - 1 bit of "contention" (ie a mark for requiring fairness)
 - 1 bit for a spinlock so that you can do all the fairness without
   doing any extra locked ops


Ask yourself this:

- - How do you know when there is no more writer waiting?  You cannot
  reset a "writer waiting" bit after you wake up one writer without
  waking every single thread waiting for the rwlock and letting them
  fight for it

- - How do you handle the difference between reader-preferred rwlocks
  and writer-preferred rwlocks?  In the latter, if a rwlock is locked
  for reading, future readers must be delayed until all writers are
  gone

- - How do you do the accounting for the *timedlock variants?  In the
  case of those a functions, if the threads wake due to a timeout,
  you have the decrement the waiter count.  But you have only one bit...


I don't say you cannot implement rwlocks this way.  Sure, it definitely
is possible.  But this implementation would in the contended case like
10x as slow as the current code because you constantly have to wake up
every single thread.

If you want, I'll give you a libpthread.so with the new code.  Then you
can test your code.  I bet you whatever you want that you cannot achieve
the performance with your puny 32-bit futex without limiting the number
of threads to a ridiculously low number.  The implementation I have
allows for 2^23 (possibly recursively locked) readers, 2^18 readers or
writers waiting.

When I was writing "you need more than 32 bits" I didn't even imagine
that somebody would suggest using such a primitive scheme which cannot
possibly work efficiently in a userlevel implementation.

- --
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkhAzlEACgkQ2ijCOnn/RHQ+bgCcDDmhSvbKdboyqa21smzlSt75
zHUAn2rr3NKns4Kb78Woas3NP5hbwkOU
=p6z6
-----END PGP SIGNATURE-----
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/3] 64-bit futexes: Intro, Ulrich Drepper, (Fri May 30, 9:27 pm)
Re: [PATCH 0/3] 64-bit futexes: Intro, Linus Torvalds, (Fri May 30, 10:13 pm)
Re: [PATCH 0/3] 64-bit futexes: Intro, Ulrich Drepper, (Fri May 30, 11:14 pm)
Re: [PATCH 0/3] 64-bit futexes: Intro, Linus Torvalds, (Fri May 30, 11:44 pm)
Re: [PATCH 0/3] 64-bit futexes: Intro, Ulrich Drepper, (Sat May 31, 12:04 am)
Re: [PATCH 0/3] 64-bit futexes: Intro, Linus Torvalds, (Sat May 31, 12:16 am)
Re: [PATCH 0/3] 64-bit futexes: Intro, Linus Torvalds, (Sat May 31, 12:23 am)
Re: [PATCH 0/3] 64-bit futexes: Intro, Ulrich Drepper, (Sat May 31, 12:38 am)
Re: [PATCH 0/3] 64-bit futexes: Intro, Linus Torvalds, (Sat May 31, 6:25 pm)
Re: [PATCH 0/3] 64-bit futexes: Intro, Ingo Molnar, (Mon Jun 2, 2:54 pm)
Re: [PATCH 0/3] 64-bit futexes: Intro, Linus Torvalds, (Mon Jun 2, 4:22 pm)
Re: [PATCH 0/3] 64-bit futexes: Intro, Nick Piggin, (Thu Jun 5, 9:27 pm)
Re: [PATCH 0/3] 64-bit futexes: Intro, Linus Torvalds, (Thu Jun 5, 11:37 pm)
Re: [PATCH 0/3] 64-bit futexes: Intro, Nick Piggin, (Fri Jun 6, 7:53 am)
Re: [PATCH 0/3] 64-bit futexes: Intro, Linus Torvalds, (Fri Jun 6, 11:01 am)
Re: [PATCH 0/3] 64-bit futexes: Intro, Ingo Molnar, (Mon Jun 2, 7:03 pm)
Re: [PATCH 0/3] 64-bit futexes: Intro, Nick Piggin, (Mon Jun 2, 11:24 pm)
Re: [PATCH 0/3] 64-bit futexes: Intro, Linus Torvalds, (Wed Jun 4, 3:57 pm)
Re: [PATCH 0/3] 64-bit futexes: Intro, Nick Piggin, (Wed Jun 4, 9:45 pm)
Re: [PATCH 0/3] 64-bit futexes: Intro, Linus Torvalds, (Wed Jun 4, 4:38 pm)
Re: [PATCH 0/3] 64-bit futexes: Intro, Nick Piggin, (Wed Jun 4, 9:56 pm)
Re: [PATCH 0/3] 64-bit futexes: Intro, Linus Torvalds, (Wed Jun 4, 11:08 pm)
Re: [PATCH 0/3] 64-bit futexes: Intro, Nick Piggin, (Thu Jun 5, 12:29 am)
Re: [PATCH 0/3] 64-bit futexes: Intro, Nick Piggin, (Wed Jun 4, 9:58 pm)
Re: [PATCH 0/3] 64-bit futexes: Intro, Linus Torvalds, (Sat May 31, 6:32 pm)
Re: [PATCH 0/3] 64-bit futexes: Intro, Linus Torvalds, (Sat May 31, 12:58 am)