lkml.org 
[lkml]   [2000]   [Aug]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH] tight spin loop in release()
Date
From
While debugging a problem on an SMP Alpha, I noticed that one process was
always in a tight loop in release(), waiting for its child to give up the
cpu. This was the cause of a significant amount of cache line "ping-ponging"
between the CPUs. It seems that the loop was rewritten between 2.2 and
2.4 whereas the 2.2 version would wait for the has_cpu flag to be cleared
outside of the lock. This patch restores the loop to the 2.2 version to
avoid the problem described above.

Thanks,

Pat

--
Patrick O'Rourke
orourke@missioncriticallinux.com

--- linux-2.4.0-test6-pre1/kernel/exit.c Wed Aug 2 09:58:43 2000
+++ sbox/linux-2.4.0-test6-pre1/kernel/exit.c Fri Aug 4 17:47:57 2000
@@ -26,17 +26,21 @@
{
if (p != current) {
#ifdef CONFIG_SMP
- int has_cpu;
-
/*
* Wait to make sure the process isn't on the
* runqueue (active on some other CPU still)
*/
- do {
+ for (;;) {
+ int has_cpu;
spin_lock_irq(&runqueue_lock);
has_cpu = p->has_cpu;
spin_unlock_irq(&runqueue_lock);
- } while (has_cpu);
+ if (!has_cpu)
+ break;
+ do {
+ barrier();
+ } while (p->has_cpu);
+ }
#endif
atomic_dec(&p->user->processes);
free_uid(p->user);



-
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/

\
 
 \ /
  Last update: 2005-03-22 13:58    [W:0.023 / U:2.968 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site