[SSI] openssi/kernel/cluster/ssi/vproc rproc_cli_vproc.c, 1.11, 1.12 rproc_server.c, 1.10, 1.11 rproc_server_pproc.c, 1.14, 1.15 rproc_svr_vproc.c, 1.17, 1.18 vp_subr.c, 1.25, 1.26

Roger Tsang <[email protected]> Mon, 25 Oct 2010 06:00:59 +0000
Newsgroups gmane.linux.cluster.ssic.cvs
Message-ID <[email protected]>
Update of /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/vproc
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv13817/cluster/ssi/vproc

Modified Files:
      Tag: OPENSSI-FC
	rproc_cli_vproc.c rproc_server.c rproc_server_pproc.c 
	rproc_svr_vproc.c vp_subr.c 
Log Message:
- Fix BUG at rexecve_server_setup(). This can happen if the process was just migrated and is doing rexecve() for this node. Solution is set PV_MIGRATED pvp_flag so that vproc_giveback() knows delayed dealloc applies and wait for final put_task_struct to touch vp_relse before re-using vproc struct. (#ifdef TASK_HOLD_VPROC)
- Remove unnecessary use of write lock on tasklist_lock in migrate_server_setup() and rexecve_server_setup().

 cluster/ssi/util/load_level.c          |   26 +++++++++++------------
 cluster/ssi/vproc/rproc_cli_vproc.c    |   20 +++++++----------
 cluster/ssi/vproc/rproc_server.c       |   28 +++++++++++++++++++++++++
 cluster/ssi/vproc/rproc_server_pproc.c |    7 ------
 cluster/ssi/vproc/rproc_svr_vproc.c    |    6 -----
 cluster/ssi/vproc/vp_subr.c            |    2 -
 include/linux/dpvproc.h                |    3 ++
 include/linux/vproc.h                  |    2 -
 8 files changed, 55 insertions(+), 39 deletions(-)


Index: rproc_server_pproc.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/vproc/rproc_server_pproc.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- rproc_server_pproc.c	27 Oct 2009 03:18:30 -0000	1.14
+++ rproc_server_pproc.c	25 Oct 2010 06:00:57 -0000	1.15
@@ -154,10 +154,7 @@
 			get_task_struct(current);
 #endif
 		pve->pvp_pproc = current;
-
-		write_lock_irq(&tasklist_lock);
 		current->p_vproc = ve;
-		write_unlock_irq(&tasklist_lock);
 
 		/*
 		 * Wakeup the parent server process. Note that this is
@@ -215,17 +212,13 @@
 		pvm = PVP(vm);
 		pvm->pvp_pproc = NULL;
 #endif
-		write_lock_irq(&tasklist_lock);
 		p->clear_child_tid = NULL;
 		p->p_vproc = vm;
-		write_unlock_irq(&tasklist_lock);
 
 		pproc_remove_process();
 
-		write_lock_irq(&tasklist_lock);
 		p->exit_state = EXIT_ZOMBIE;
 		p->group_leader = p;	/* prevent report state */
-		write_unlock_irq(&tasklist_lock);
 
 		VPROC_RELE(vm, "perm svr_migrate()");
 		pproc_cleanup_process();

Index: vp_subr.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/vproc/vp_subr.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- vp_subr.c	5 Mar 2010 05:59:06 -0000	1.25
+++ vp_subr.c	25 Oct 2010 06:00:57 -0000	1.26
@@ -299,7 +299,7 @@
 	}
 	free_vproc(v);
 #else
-	if (!tsk) {
+	if (!tsk && !(PVP(v)->pvp_flag & PV_MIGRATED)) {
 		free_vproc(v);
 		return;
 	}

Index: rproc_server.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/vproc/rproc_server.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- rproc_server.c	27 Oct 2009 03:18:30 -0000	1.10
+++ rproc_server.c	25 Oct 2010 06:00:57 -0000	1.11
@@ -101,6 +101,20 @@
 		goto out;
 	}
 
+#ifdef TASK_HOLD_VPROC
+	/* If we are re-using the vproc structure of a task that
+	 * just migrated, that task's p_vproc points to this vproc.
+	 * Make sure old task has gone away before updating this vproc.
+	 */
+	if (PVP(ve)->pvp_flag & PV_MIGRATED) {
+		while (ve->vp_relse != VP_DEAD)
+			yield();
+		ve->vp_relse = 0;
+		PVP(ve)->pvp_flag &= ~PV_MIGRATED;
+		PVP(ve)->pvp_pproc = NULL;
+	}
+#endif
+
 	args = kmalloc(sizeof(*args), GFP_USER);
 	if (args == NULL) {
 		error = -ENOMEM;
@@ -168,6 +182,20 @@
 		goto out;
 	}
 
+#ifdef TASK_HOLD_VPROC
+	/* If we are re-using the vproc structure of a task that
+	 * just migrated, that task's p_vproc points to this vproc.
+	 * Make sure old task has gone away before updating this vproc.
+	 */
+	if (PVP(vm)->pvp_flag & PV_MIGRATED) {
+		while (vm->vp_relse != VP_DEAD)
+			yield();
+		vm->vp_relse = 0;
+		PVP(vm)->pvp_flag &= ~PV_MIGRATED;
+		PVP(vm)->pvp_pproc = NULL;
+	}
+#endif
+
 	args = kmalloc(sizeof(*args), GFP_USER);
 	if (args == NULL) {
 		error = -ENOMEM;

Index: rproc_cli_vproc.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/vproc/rproc_cli_vproc.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- rproc_cli_vproc.c	27 Oct 2009 03:18:30 -0000	1.11
+++ rproc_cli_vproc.c	25 Oct 2010 06:00:57 -0000	1.12
@@ -377,6 +377,9 @@
 			   PV_FGPGRP|
 			   PV_PROCESS|
 			   PV_NOCLDWAIT);
+#ifdef TASK_HOLD_VPROC
+	pve->pvp_flag |= PV_MIGRATED;
+#endif
 	VPROC_UNLOCK_FLAG(ve,"rexecve");
 
 	/*
@@ -465,14 +468,9 @@
 	 * that the process has been moved.
 	 */
 #ifdef TASK_HOLD_VPROC
-	/* No need to NULL out pvp_pproc since PV_PROCESS flag is disabled */
-	/* vproc_giveback() needs pvp_pproc for delayed vproc dealloc */
 	put_task_struct(pve->pvp_pproc);
-#else
-#ifndef VPROC_HOLD_ZERO_GET_TASK
-	pve->pvp_pproc = NULL;
-#endif
 #endif
+	pve->pvp_pproc = NULL;
 
 	/*
 	 * Remove the local incarnation of the process because
@@ -650,6 +648,9 @@
 			   PV_FGPGRP|
 			   PV_PROCESS|
 			   PV_NOCLDWAIT);
+#ifdef TASK_HOLD_VPROC
+	pvm->pvp_flag |= PV_MIGRATED;
+#endif
 	VPROC_UNLOCK_FLAG(vm,"migrate");
 
 	/*
@@ -739,14 +740,9 @@
 	 * that the process has been moved.
 	 */
 #ifdef TASK_HOLD_VPROC
-	/* No need to NULL out pvp_pproc since PV_PROCESS flag is disabled */
-	/* vproc_giveback() needs pvp_pproc for delayed vproc dealloc */
 	put_task_struct(pvm->pvp_pproc);
-#else
-#ifndef VPROC_HOLD_ZERO_GET_TASK
-	pvm->pvp_pproc = NULL;
-#endif
 #endif
+	pvm->pvp_pproc = NULL;
 
 	/*
 	 * Remove the local incarnation of the process because

Index: rproc_svr_vproc.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/vproc/rproc_svr_vproc.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- rproc_svr_vproc.c	27 Oct 2009 03:18:30 -0000	1.17
+++ rproc_svr_vproc.c	25 Oct 2010 06:00:57 -0000	1.18
@@ -302,9 +302,7 @@
 	/* Initialize p_vproc early for following path:
 	 * ssi_do_execve, dvp_set_exec
 	 */
-	write_lock_irq(&tasklist_lock);
 	procp->p_vproc = ve;
-	write_unlock_irq(&tasklist_lock);
 #endif
 	error = ssi_do_execve(fname, argv, envp, regs, 0);
 	/* Successful? */
@@ -325,9 +323,7 @@
 	 * structure.
 	 */
 #ifdef VPROC_HOLD_ZERO_GET_TASK
-#ifndef TASK_HOLD_VPROC
 	BUG_ON(pve->pvp_pproc);
-#endif
 	get_task_struct(procp);
 #endif
 	pve->pvp_pproc = procp;
@@ -634,8 +630,8 @@
 	 * node1 "pid 69315" (R) - migrate_server, __put_task_struct, free_task, BUG.
 	 */
 	/* Fixed. pvp_pproc is NULL'ed out after migration */
-	BUG_ON(pvm->pvp_pproc);
 #endif
+	BUG_ON(pvm->pvp_pproc);
 	get_task_struct(procp);
 #endif
 	pvm->pvp_pproc = procp;


------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev