[SSI] openssi/kernel/ipc shm.c,1.32,1.33

Roger Tsang <[email protected]> Sun, 21 Mar 2010 05:33:52 +0000
Newsgroups gmane.linux.cluster.ssic.cvs
Message-ID <[email protected]>
Update of /cvsroot/ssic-linux/openssi/kernel/ipc
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv21204/kernel/ipc

Modified Files:
      Tag: OPENSSI-FC
	shm.c 
Log Message:
IPC (#ifdef IPC_SHM_RACE_FIX):
- Fix livelock in do_ssi_shm_noclients() in svr_ripc_shm_cleanup() path due to deadlock with icssvr_nodedown_svc_wait() in ipc_shm_nodedown(). In do_ssi_shm_noclients() when RIPC_SHM_GET_NATTCHS() fails shm_nodelist in shmid_kernel_svr structure is re-read before retrying. It retries indefinitely. There is no livelock as long as down nodes are promptly removed from shm_nodelist, but the down node is not removed from shm_nodelist until after icssvr_nodedown_svc_wait() completes in ipc_shm_nodedown(). A deadlock occurs because icssvr_nodedown_svr_wait() waits for svr_ripc_shm_cleanup() to complete.
- Remove shm_sem_owned(). No longer used.
- Fix bug introduced in CVS tag OPENSSI-FC-1-9-6-PRE20. Remote SHM client stuck in shm_destroy(). cli_ripc_shm_cleanup() deadlock with ripc_shm_get_nattchs(). shm_ids.sem mutex is held during cli_ripc_shm_cleanup() which is a blocking RPC and triggers ripc_shm_get_nattchs() callback. A deadlock occurs when the callback waits for shm_ids.sem already held prior the RPC.
- ssi_shm_cleanup() at remote client no longer handles -EREMOTE (aka. node down); SHM segment is cleaned up during nodedown. Now ripc_shm_rmid() drops shm_ids.sem for caller since there is no longer need to return with shm_ids.sem held.
- Make abort_rmid() more robust during low memory.
- Fix RIPC_SHMCTL() in sys_shmctl(SHM_INFO) path deadlock with remote RIPC_SHM_GET_NATTCHS() in ssi_shm_cleanup() path.  Both callers hold shm_ids.sem at their node during RPC.

 cluster/ssi/ipc/ipcshm_svr.c  |   88 ++++++++++++++++++++--------------
 include/cluster/ssi/ipc/shm.h |    1 
 ipc/shm.c                     |   22 +++++---
 3 files changed, 67 insertions(+), 44 deletions(-)


Index: shm.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/ipc/shm.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- shm.c	15 Mar 2010 06:22:37 -0000	1.32
+++ shm.c	21 Mar 2010 05:33:50 -0000	1.33
@@ -97,10 +97,6 @@
 {
 	ipc_unlock(&(svp)->shm_perm);
 }
-int shm_sem_owned(void)
-{
-	return sem_owned(&shm_ids.sem);
-}
 #else /* IPC_SHM_RACE_FIX */
 inline struct shmid_kernel_svr *shm_svr_get(int id)
 {
@@ -208,11 +204,11 @@
 static void shm_destroy (struct shmid_kernel *shp)
 {
 #ifdef CONFIG_SSI
-	clusternode_t svrnode = shp->shm_node;
 	int sz = 0;
 
-	if (svrnode) {
-		(void)ssi_shm_cleanup(svrnode, shp->id, this_node);
+	if (shp->shm_node) {
+		(void) ssi_shm_cleanup((clusternode_t) shp->shm_node,
+						shp->id, this_node);
 		return;
 	}
 
@@ -692,8 +688,14 @@
 			return err;
 
 		memset(&shm_info,0,sizeof(shm_info));
-		down(&shm_ids.sem);
 #ifdef CONFIG_SSI
+#ifndef IPC_SHM_RACE_FIX
+		/* SSI_XXX: RIPC_SHMCTL() could deadlock with another incoming
+		 * RPC from destination node such as RIPC_SHM_GET_NATTCHS()
+		 * which holds shm_ids.sem in ssi_shm_cleanup() path.
+		 */
+		down(&shm_ids.sem);
+#endif
 		svrnode = 0;
 		if (!ssi_get_localview() && (remote_cmd == FALSE))
 		{
@@ -719,6 +721,9 @@
 			}
 			NSC_NODELIST_FREE(nl);
 			memset(buf,0,sizeof(shm_info));
+#ifdef IPC_SHM_RACE_FIX
+			down(&shm_ids.sem);
+#endif
 			shm_info.used_ids += shm_ids.in_use;
 			shm_get_stat (&(((struct shm_info *)buf)->shm_rss), &(((struct shm_info *)buf)->shm_swp));
 			shm_info.shm_rss += ((struct shm_info *)buf)->shm_rss;
@@ -730,6 +735,7 @@
 			goto out_unlockall;
 		}
 #endif /* CONFIG_SSI */
+		down(&shm_ids.sem);
 		shm_info.used_ids = shm_ids.in_use;
 		shm_get_stat (&shm_info.shm_rss, &shm_info.shm_swp);
 		shm_info.shm_tot = shm_tot;


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev