Re: Poor thread performance on Linux vs. Solaris
Jakub Jelinek <[email protected]>
| Newsgroups | gmane.comp.lib.phil |
|---|---|
| Message-ID | <[email protected]> |
On Mon, Sep 08, 2003 at 03:34:28PM +0800, Hu, Boris wrote: > You could try this patch. It is against linux-2.6.0-test4. :) > @@ -231,9 +240,13 @@ > if (!page2) > goto out; > > - head1 = hash_futex(page1, offset1); > - head2 = hash_futex(page2, offset2); > - > + bh1 = hash_futex(page1, offset1); > + bh2 = hash_futex(page2, offset2); > + spin_lock(&bh1->lock); > + spin_lock(&bh2->lock); > + head1 = &bh1->chain; > + head2 = &bh2->chain; > + What if bh1 == bh2? spin_lock is not recursive. Also, if one thread calls requeue with futex bucket A for offset1 and futex bucket B for offset2 and another thread at the same time calls requeue with futex bucket B for offset1 and futex bucket A for offset2, you deadlock. So the code at least should be comparing the bucket addresses, if they are equal lock just once and otherwise lock say bucket with smaller address first or something. Jakub