[SSI] openssi/kernel/fs exec.c,1.12,1.13

Roger Tsang <[email protected]>
Newsgroups gmane.linux.cluster.ssic.cvs
Message-ID <[email protected]>
Update of /cvsroot/ssic-linux/openssi/kernel/fs
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv23888/fs

Modified Files:
      Tag: OPENSSI-FC
	exec.c 
Log Message:
VPROC:
- Fix select_bad_process() NULL p_vproc pointer dereference.
- Fix de_thread() related issues:
  - Fix de_thread() calling VPOP_RECLAIM_CHILD() while holding spin_lock(task->p
roc_lock). Code path might sleep.
  - Fix NULL p_vproc pointer dereference when thread group leader is exiting, ha
s PF_FORKNOEXEC flag, and has lost race with de_thread(). Affects exit_notify(),
 forget_original_parent(), and will_become_orphaned_pgrp(). When p_vproc is NULL
 the exiting process reaps itself.
  - Fix dpvproc_nocldwait_async_handler() NULL pointer dereference due to failed
 lookup for vproc of new parent when lost race with de_thread(). (#ifdef RELEASE
_TASK_LEADER_GONE__VPROC_FIX)
  - New PVPOP_SWITCH_PID() to switch VProc PID of process doing de_thread().
  - New PV_DETHREAD_REAP flag is set during de_thread() to indicate to child rea
per to reap thread group leader without delay.
  - Fix oops in do_notify_resume() path due to NULL pointer dereference. p_vproc
 is NULL after bad fork.

VPROC (#ifdef VPROC_RELEASE__REFCNT_RACE_FIX):
- Fix extra VPROC_RELE() on PVPOP_RMV_PGRP_LIST() -ESRCH error.
- Fix PVPOP_REAP() extra dpvproc_remove_pgrp_leader_member_care() on PVPOP_RMV_P
GRP_LIST() -EBUSY error; was typo in if-test.
- PVPOP_REAP() no longer does async PVPOP_RMV_PGRP_LIST(); now sync. Don't see h
ow reaping parent can hold PGRP LOCK in PVPOP_REAP() path.
- Fix exit_vproc() did not decrement vproc reference for process group leader on
 member node. This is in do_fork() error path.

VPROC (#ifdef VPROC_CONTINUE):
- Fix dpvproc_nocldwait_async_handler() deadlock on PVPOP_REAP() -EBUSY due to d
elay_group_leader(). PV_REAPER_RETRY flag is set and group leader is re-inserted
 into the queue so that the remaining threads in thread group can be reaped by t
his handler to remove the delay_group_leader() condition.
- Regression:
  - Fix pproc_reap() should succeed, but returns -EBUSY when process is a thread
 group leader in non-empty thread group and is already in EXIT_DEAD state.


Index: exec.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/fs/exec.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- exec.c	27 Oct 2009 03:18:30 -0000	1.12
+++ exec.c	17 Dec 2009 05:46:50 -0000	1.13
@@ -56,8 +56,12 @@
 
 #ifdef CONFIG_SSI
 #include <cluster/nsc.h>		/* for PID_DATA */
-#include <linux/vproc.h>
 #include <cluster/ssi/load_level.h>
+#ifdef VPROC_RCU_LIST
+#include <linux/dpvproc.h>
+#else
+#include <linux/vproc.h>
+#endif
 #endif
 
 int core_uses_pid;
@@ -761,15 +765,7 @@
 
 		ptrace_unlink(current);
 		ptrace_unlink(leader);
-#ifdef CONFIG_VPROC
-		write_unlock_irq(&tasklist_lock);
-		if (VPOP_RECLAIM_CHILD(current->p_vproc, leader->ppid,0,0) < 0)
-			printk("de_thread: failed to reclaim child \n");
-
-		if (VPOP_RECLAIM_CHILD(leader->p_vproc, 2, 0, 0) < 0)
-			printk("de_thread: failed to reclaim leader \n");
-		write_lock_irq(&tasklist_lock);
-#else
+#ifndef CONFIG_VPROC
 		remove_parent(current);
 		remove_parent(leader);
 #endif
@@ -807,6 +803,37 @@
 		if (exit_state != EXIT_ZOMBIE)
 			BUG();
 #ifdef CONFIG_VPROC
+		/*
+		 * CPU0			CPU1
+		 * parent do_wait()	new program de_thread()
+		 *
+		 * read_lock(&tasklist_lock)
+		 * delay_group_leader(leader) == TRUE
+		 * read_unlock(&tasklist_lock)
+		 * not eligible for reap
+		 *			write_lock_irq(&tasklist_lock)
+		 *			switch_exec_pids()
+		 *			write_unlock_irq(&tasklist_lock)
+		 */
+
+		/* SSI: We cannot reclaim before switch_exec_pids() above
+		 * due to spin_lock(task->proc_lock).
+		 */
+		if (VPOP_RECLAIM_CHILD(current->p_vproc, leader->ppid,0,0) < 0)
+			printk("de_thread: failed to reclaim child \n");
+
+		/* SSI: Could race with VPOP_CLEANUP_VPROC_RELATIONS() */
+		if ((count = VPOP_RECLAIM_CHILD(leader->p_vproc, 2, 0, 0)) < 0)
+			printk("de_thread: failed to reclaim leader %d\n", count);
+
+#ifdef VPROC_CONTINUE
+		/* Set the flag so child reaper will ignore result of
+		 * delay_group_leader(leader) and reap leader immediately.
+		 */
+		VPROC_LOCK_FLAG(vl, "de_thread");
+		PVP(vl)->pvp_flag |=  PV_DETHREAD_REAP;
+		VPROC_UNLOCK_FLAG(vl, "de_thread");
+#endif
 		do_notify_parent(leader, SIGCHLD, 0, 0);
 #ifdef VPROC_RELEASE__REFCNT_RACE_FIX
 #ifdef TASK_HOLD_VPROC
@@ -814,10 +841,8 @@
 #else
 		VPROC_RELE(parent->p_vproc, "temp de_thread(parent of leader)");
 #endif
-#ifdef VPROC_HOLD_ZERO_GET_TASK
-		VPROC_RELE(vl, "de_thread(leader)");
-#endif
 #endif
+#ifdef SSI_SKIP
 #ifdef DE_THREAD__OOPS_FIX
 		/* [ ssic-linux-Bugs-2000692 ]
 		 * Wait for leader to get reaped.
@@ -826,6 +851,22 @@
 		while (atomic_read(&sig->count) > 1)
 			yield();
 #endif
+#endif /* SSI_SKIP */
+#ifdef VPROC_RCU_LIST
+#ifdef TASK_HOLD_VPROC
+		/* Wait for leader to remove self from process group */
+		while (atomic_read(&vl->vp_ref_cnt) > 5 ||
+				PVP(current->p_vproc)->pvp_pgrpl == vl)
+			yield();
+		/* Could possibly just wait for PV_WAITED ? */
+		SSI_ASSERT(PVP(vl)->pvp_flag & PV_WAITED);
+#ifdef VPROC_HOLD_ZERO_GET_TASK
+		VPROC_RELE(vl, "de_thread(leader)");
+#endif
+#endif
+		/* Now that the leader is reaped switch vproc pid */
+		PVPOP_SWITCH_PID(current->p_vproc, current->pid);
+#endif /* VPROC_RCU_LIST */
 #else
 		release_task(leader);
 #endif /* !VPROC */


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.