[SSI] openssi/kernel/fs/proc internal.h,1.5,1.6

Roger Tsang <[email protected]> Mon, 17 Jan 2011 07:01:39 +0000
Newsgroups gmane.linux.cluster.ssic.cvs
Message-ID <[email protected]>
Update of /cvsroot/ssic-linux/openssi/kernel/fs/proc
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv1380/fs/proc

Modified Files:
      Tag: OPENSSI-FC
	internal.h 
Log Message:
- vproc_migrating: moved inline function from fs/proc/base.c here.

(#ifdef VPROC_HOLD_ZERO_GET_TASK)
- proc_ssi_task: borrow pvp_pproc's task_struct reference while PV_IS_LOCAL flag is set. there is no race with process migration because the client does not release pvp_pproc's task_struct reference until after atomically clearing the flag. there is no race with final put_task_struct() because the caller holds the reference to vproc struct which has the final task_struct reference unless the process has migrated.


Index: internal.h
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/fs/proc/internal.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- internal.h	27 Oct 2009 03:18:30 -0000	1.5
+++ internal.h	17 Jan 2011 07:01:37 -0000	1.6
@@ -65,7 +65,44 @@
 #endif
 	return task;
 }
-#endif /* !VPROC_HOLD_ZERO_GET_TASK */
+#else /* !VPROC_HOLD_ZERO_GET_TASK */
+/**
+ * proc_ssi_task - borrow pvp_pproc's task_struct reference
+ * @vp: vproc structure of the task
+ *
+ * SMP-safe. The vproc structure has final task_struct reference unless the
+ * process has migrated in which case during migration pvp_pproc's task_struct
+ * reference is released after clearing PV_IS_LOCAL flag.
+ *
+ * Acquires and releases VPROC FLAG LOCK.
+ */
+static inline task_t *proc_ssi_task(struct vproc *vp)
+{
+	task_t *task;
+
+	VPROC_LOCK_FLAG(vp, "proc_ssi_task");
+	if (PVP(vp)->pvp_flag & PV_IS_LOCAL) {
+		task = PVP(vp)->pvp_pproc;
+		get_task_struct(task);
+	} else
+		task = NULL;
+	VPROC_UNLOCK_FLAG(vp, "proc_ssi_task");
+	return task;
+}
+#endif /* VPROC_HOLD_ZERO_GET_TASK */
+
+/* Determine whether pid is migrating in */
+static inline int vproc_migrating(struct vproc *vp)
+{
+#ifdef TASK_HOLD_VPROC
+	return (current->ppid == 2 &&
+		current->epid != vp->vp_pid &&
+		current->pid == vp->vp_pid);
+#else
+	return (current->ppid == 2 && current->p_vproc->vp_pid != vp->vp_pid &&
+			current->pid == vp->vp_pid);
+#endif
+}
 #endif /* CONFIG_SSI */
 
 extern void create_seq_entry(char *name, mode_t mode, struct file_operations *f);


------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl