> > If it's really an optimization depends IMHO on how much bhs are on the
> > queue, as testing bit1 for each of them might actually make things
> > worse...
>
> I don't think so. A spin_lock() could lead to many CPU stuck on the same
> spinlock even if they was adding task queue to different task queue *list.
> Using a bit in the bh->sync will allow SMP to scale very better. And we
Hmm, it was just short-term spinlock, I don't think there is much
real contention.
> avoided a __cli() in every run_task_queue().
Well, this might be considered as a win.
> Here the latest update:
And what about this (maybe I got the memory barriers wrong, it's just to
show the idea):
--- tqueue.h.arca Tue Feb 2 09:41:47 1999
+++ tqueue.h.prak Tue Feb 2 09:57:50 1999
@@ -70,9 +70,11 @@
/*
* bh_pointer->sync description:
* - BIT0 set indicate that a bh function is just in the queue.
- * - BIT1 set indicate that the bh_pointer->next is not ready to be read.
+ * bh_pointer->next == PTR_BUSY means that the bh_pointer->next is not ready to be read yet.
*/
+#define PTR_BUSY ((void*)(-1))
+
extern __inline__ void queue_task(struct tq_struct *bh_pointer,
task_queue *bh_list)
{
@@ -80,20 +82,16 @@
unsigned long flags;
#ifdef __SMP__
- bh_pointer->sync |= 2;
+ bh_pointer->next = PTR_BUSY;
wmb();
#endif
/*
* Disable local interrupt to avoid the CPU to run a nested
- * run_task_queue() while bit1 is set. -arca
+ * run_task_queue() while bh_pointer->next is not ready. -arca
*/
__save_flags(flags);
__cli();
bh_pointer->next = xchg(bh_list,bh_pointer);
-#ifdef __SMP__
- clear_bit(1,&bh_pointer->sync); /* see run_task */
- wmb();
-#endif
__restore_flags(flags);
}
}
@@ -120,11 +118,11 @@
* but not yet glued the rest of the list
* back onto p
*/
- while(test_bit(1,&save_p->sync));
- rmb();
+ do {
#endif
- p = p -> next;
+ p = save_p -> next;
#ifdef __SMP__
+ } while(p == PTR_BUSY);
wmb();
#endif
save_p -> sync = 0;
Patrik
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/