[SSI] openssi/kernel/kernel pid.c,1.11,1.12

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

Modified Files:
      Tag: OPENSSI-FC
	pid.c 
Log Message:
- Disable Linux pidmap_array[] since it is not used in OpenSSI. Reduce memory usage by 512 KBytes + one page as calculated from PID_MAX_LIMIT of 0x7fffffff.


Index: pid.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/kernel/pid.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- pid.c	2 Feb 2010 04:59:19 -0000	1.11
+++ pid.c	25 Oct 2010 04:40:35 -0000	1.12
@@ -48,6 +48,7 @@
 int pid_max_min = RESERVED_PIDS + 1;
 int pid_max_max = PID_MAX_LIMIT;
 
+#ifndef CONFIG_SSI
 #define PIDMAP_ENTRIES		((PID_MAX_LIMIT + 8*PAGE_SIZE - 1)/PAGE_SIZE/8)
 #define BITS_PER_PAGE		(PAGE_SIZE*8)
 #define BITS_PER_PAGE_MASK	(BITS_PER_PAGE-1)
@@ -85,49 +86,6 @@
 	atomic_inc(&map->nr_free);
 }
 
-
-#ifdef CONFIG_SSI
-/*
- * Allocate a pid composed of node # and a pid value on the local node.
- * This algorithm is a simple sequential hunt for a free pid
- * between LAST_DAEMON_PID and PID_MAX.  It takes advantage of
- * pid caching.
- */
-int ssi_get_pid(void)
-{
-	pid_t start_pid = RESERVED_PIDS;
-	pid_t try_pid;
-static DEFINE_SPINLOCK(lastpid_lock);
-
-	/* Handle proc 1 */
-	if (!(current->pid)) {
-		try_pid = 2 | PID_DATA;
-		return try_pid;
-	}
-
-next_pid:
-	spin_lock(&lastpid_lock);
-	last_pid++;
-
-	/* if at end, recycle */
-	if (last_pid == MAXLOCPID)
-		last_pid = start_pid;
-
-	try_pid = last_pid | PID_DATA;
-
-	/* If pid in use, try the next one */
-	spin_unlock(&lastpid_lock);
-#ifdef VPROC_RELEASE__REFCNT_RACE_FIX
-	if (VPROCPTR_NOHOLD(try_pid) != NULL)
-#else
-	if (VPROCPTR(try_pid) != NULL)
-#endif
-		goto next_pid;
-
-	return try_pid;
-}
-#endif
-
 int alloc_pidmap(void)
 {
 	int i, offset, max_scan, pid, last = last_pid;
@@ -190,6 +148,46 @@
 	}
 	return -1;
 }
+#else /* !CONFIG_SSI */
+
+/*
+ * Allocate a pid composed of node # and a pid value on the local node.
+ * This algorithm is a simple sequential hunt for a free pid
+ * between LAST_DAEMON_PID and PID_MAX.  It takes advantage of
+ * pid caching.
+ */
+int ssi_get_pid(void)
+{
+	pid_t try_pid;
+static __cacheline_aligned_in_smp DEFINE_SPINLOCK(lastpid_lock);
+
+	/* Handle proc 1 */
+	if (unlikely(!(current->pid))) {
+		try_pid = 2 | PID_DATA;
+		return try_pid;
+	}
+
+	do {
+		spin_lock(&lastpid_lock);
+		last_pid++;
+
+		/* if at end, recycle */
+		if (last_pid == MAXLOCPID)
+			last_pid = RESERVED_PIDS;
+
+		try_pid = last_pid | PID_DATA;
+
+		spin_unlock(&lastpid_lock);
+		/* If pid in use, try the next one */
+#ifdef VPROC_RELEASE__REFCNT_RACE_FIX
+	} while (VPROCPTR_NOHOLD(try_pid) != NULL);
+#else
+	} while (VPROCPTR(try_pid) != NULL);
+#endif
+
+	return try_pid;
+}
+#endif /* CONFIG_SSI */
 
 struct pid * fastcall find_pid(enum pid_type type, int nr)
 {
@@ -360,9 +358,11 @@
 {
 	int i;
 
+#ifndef CONFIG_SSI
 	pidmap_array->page = (void *)get_zeroed_page(GFP_KERNEL);
 	set_bit(0, pidmap_array->page);
 	atomic_dec(&pidmap_array->nr_free);
+#endif
 
 	/*
 	 * Allocate PID 0, and hash it via all PID types:


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