2.1.111 SMP fix in sys_wait4()

Eric PAIRE (e.paire@opengroup.org)
Tue, 28 Jul 1998 07:59:15 +0200


Hi Linus,

I am about to look carefully at debugging in SMP systems (since I noticed that
the patches I did in gdb for debugging multithreaded applications do not work
correctly in Linux2.1.11 SMP systems). I have already noticed the following
problem (I guess) in kernel/fork.c:sys_wait4():

The p_[o]pptr links are modified without any lock held when a debugged ZOMBIE
task status is got by the debugger task. I think that the links should be
modified with tasklist_lock exclusively help since they can be modified in
parallel by forget_original_parent(). I suggest the enclosed patch for 2.1.111
to fix this potential (and extremely unfrequent :-) SMP problem.

Best regards,
-Eric
+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ Eric PAIRE
Email : e.paire@gr.opengroup.org | THE Open GROUP - Grenoble Research Institute
Phone : +33 (0) 476 63 48 71 | 2, avenue de Vignate
Fax : +33 (0) 476 51 05 32 | F-38610 Gieres FRANCE
------ Cut Here ------ Cut Here ------ Cut Here ------ Cut Here ------
--- kernel/exit.c.OLD Thu Jun 18 10:22:23 1998
+++ kernel/exit.c Tue Jul 28 07:50:43 1998
@@ -455,13 +455,20 @@
if (stat_addr)
__put_user(p->exit_code, stat_addr);
retval = p->pid;
+ /* No SMP locking is needed for this test since
+ p->p_opptr will always be != from p->p_pptr
+ whatever value is given to p_opptr in
+ forget_original_parent().
+ */
if (p->p_opptr != p->p_pptr) {
/* Note this grabs tasklist_lock
* as a writer... (twice!)
*/
+ write_lock_irq(&tasklist_lock);
REMOVE_LINKS(p);
p->p_pptr = p->p_opptr;
SET_LINKS(p);
+ write_unlock_irq(&tasklist_lock);
notify_parent(p, SIGCHLD);
} else
release(p);

-
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.altern.org/andrebalsa/doc/lkml-faq.html