Re: OpenSSI preview on Debian Lenny (on x86_64)

John Hughes <[email protected]> Tue, 20 Apr 2010 11:04:01 +0200
Newsgroups gmane.linux.cluster.ssic.devel
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------050202080307000201080306
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

John Hughes wrote:
> Looks like a whole bunch of stuff is missing from  
> linux/arch/x86_64/kernel/signal.c
>   
Quickly hacking in some stuff copied from the i386 version gets me to 
the point where my test program is segfaulting on the destination node.

Needs some more debugging.  Maybe I need to merge in Rogers latest 
changes from CVS.

node1$ ./test 2

node2$
test[68412]: segfault at 00002aaaab2226f8 rip 00002aaaaaab8198 rsp 
00007fffffa9d2a0 error 4


--------------050202080307000201080306
Content-Type: text/x-patch;
 name="x86_64.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="x86_64.patch"

Index: arch/x86_64/ia32/ia32_signal.c
===================================================================
RCS file: /usr/local/lib/cvs-repo/openssi-future/arch/x86_64/ia32/ia32_signal.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 ia32_signal.c
--- arch/x86_64/ia32/ia32_signal.c	17 Jun 2005 19:48:29 -0000	1.1.1.2
+++ arch/x86_64/ia32/ia32_signal.c	19 Apr 2010 16:12:46 -0000
@@ -119,6 +119,9 @@
 		 struct pt_regs *regs)
 {
 	sigset_t saveset;
+#ifdef CONFIG_SSI
+	unsigned long orig_rip = regs->rip;
+#endif
 
 	mask &= _BLOCKABLE;
 	spin_lock_irq(&current->sighand->siglock);
@@ -131,8 +134,24 @@
 	while (1) {
 		current->state = TASK_INTERRUPTIBLE;
 		schedule();
+#ifdef CONFIG_SSI
+		/*
+		 * If a signal is processed, the value in eax will be changed
+		 * from -ERESTARTNOHAND to -EINTR before the sigcontext is
+		 * set up and the instruction pointer will not be changed;
+		 * if a signal is not processed, then the instruction pointer
+		 * will have been changed to restart the system call and we
+		 * must fix it if we don't migrate. (We don't care about the
+		 * value in eax in that case.) On i386, we will not return to
+		 * here if we successfully migrate.
+		 */
+		regs->rax = -ERESTARTNOHAND;
+#endif
 		if (do_signal(regs, &saveset))
 			return -EINTR;
+#ifdef CONFIG_SSI
+		regs->rip = orig_rip;
+#endif
 	}
 }
 
Index: arch/x86_64/kernel/signal.c
===================================================================
RCS file: /usr/local/lib/cvs-repo/openssi-future/arch/x86_64/kernel/signal.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 signal.c
--- arch/x86_64/kernel/signal.c	17 Jun 2005 19:48:29 -0000	1.1.1.2
+++ arch/x86_64/kernel/signal.c	19 Apr 2010 16:12:46 -0000
@@ -30,6 +30,10 @@
 #include <asm/proto.h>
 #include <asm/ia32_unistd.h>
 
+#ifdef CONFIG_SSI
+#include <linux/vproc.h>
+#endif
+
 /* #define DEBUG_SIG 1 */
 
 #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
@@ -43,6 +47,9 @@
 sys_rt_sigsuspend(sigset_t __user *unewset, size_t sigsetsize, struct pt_regs *regs)
 {
 	sigset_t saveset, newset;
+#ifdef CONFIG_SSI
+	unsigned long orig_rip = regs->rip;
+#endif
 
 	/* XXX: Don't preclude handling different sized sigset_t's.  */
 	if (sigsetsize != sizeof(sigset_t))
@@ -65,8 +72,25 @@
 	while (1) {
 		current->state = TASK_INTERRUPTIBLE;
 		schedule();
+#ifdef CONFIG_SSI
+		/*
+		 * If a signal is processed, the value in eax will be changed
+		 * from -ERESTARTNOHAND to -EINTR before the sigcontext is
+		 * set up and the instruction pointer will not be changed;
+		 * if a signal is not processed, then the instruction pointer
+		 * will have been changed to restart the system call and we
+		 * must fix it if we don't migrate. (We don't care about the
+		 * value in eax.) On i386, we will not return to here if
+		 * we successfully migrate.
+		 */
+		regs->rax = -ERESTARTNOHAND;
+#endif
+
 		if (do_signal(regs, &saveset))
 			return -EINTR;
+#ifdef CONFIG_SSI
+		regs->rip = orig_rip;
+#endif
 	}
 }
 
@@ -459,6 +483,11 @@
 			regs->rip -= 2;
 		}
 	}
+#ifdef CONFIG_SSI
+	if (test_and_clear_thread_flag(TIF_MIGPENDING))
+		ssi_quiesce_movement((void *)regs, 1);
+#endif
+
 	return 0;
 }
 
@@ -476,8 +505,24 @@
 	}
 
 	/* deal with pending signal delivery */
+#ifdef CONFIG_SSI
+	if (thread_info_flags & (_TIF_SIGPENDING|_TIF_MIGPENDING))
+#else
 	if (thread_info_flags & _TIF_SIGPENDING)
+#endif
 		do_signal(regs,oldset);
+
+#ifdef CONFIG_SSI
+	if (thread_info_flags & _TIF_MIGSTRESS) {
+		local_irq_enable();
+		if (!check_stress_mig_done()) {
+			if (check_stress_mig()) {
+				ssi_quiesce_movement((void *)regs, 1);
+				reset_stress_mig();
+			}
+		}
+	}
+#endif
 }
 
 void signal_fault(struct pt_regs *regs, void __user *frame, char *where)
Index: include/asm-x86_64/thread_info.h
===================================================================
RCS file: /usr/local/lib/cvs-repo/openssi-future/include/asm-x86_64/thread_info.h,v
retrieving revision 1.1.1.2.2.1
diff -u -r1.1.1.2.2.1 thread_info.h
--- include/asm-x86_64/thread_info.h	15 Feb 2010 19:34:27 -0000	1.1.1.2.2.1
+++ include/asm-x86_64/thread_info.h	19 Apr 2010 16:13:16 -0000
@@ -103,17 +103,16 @@
 #define TIF_IRET		5	/* force IRET */
 #define TIF_SYSCALL_AUDIT	7	/* syscall auditing active */
 #define TIF_SECCOMP		8	/* secure computing */
+#ifdef CONFIG_SSI
+#define TIF_MIGPENDING          9       /* process migration pending */
+#define TIF_MIGSTRESS           10      /* process stress migration */
+#endif
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
 #define TIF_IA32		17	/* 32bit process */ 
 #define TIF_FORK		18	/* ret_from_fork */
 #define TIF_ABI_PENDING		19
 #define TIF_MEMDIE		20
 
-#ifdef CONFIG_SSI
-#define TIF_MIGPENDING          9       /* process migration pending */
-#define TIF_MIGSTRESS           10      /* process stress migration */
-#endif
-
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
@@ -122,6 +121,10 @@
 #define _TIF_IRET		(1<<TIF_IRET)
 #define _TIF_SYSCALL_AUDIT	(1<<TIF_SYSCALL_AUDIT)
 #define _TIF_SECCOMP		(1<<TIF_SECCOMP)
+#ifdef CONFIG_SSI
+#define _TIF_MIGPENDING		(1<<TIF_MIGPENDING)
+#define _TIF_MIGSTRESS		(1<<TIF_MIGSTRESS)
+#endif
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_IA32		(1<<TIF_IA32)
 #define _TIF_FORK		(1<<TIF_FORK)

--------------050202080307000201080306
Content-Type: text/x-csrc;
 name="test.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="test.c"

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>

int where () {
	FILE * f = fopen ("/proc/self/where", "r");
	int node;
	fscanf (f, "%d", &node);
	fclose (f);
	return node;
}

void go_to (int node) {
#if 0
	FILE *f = fopen ("/proc/self/goto", "w");
	fprintf (f, "%d\n", node);
	fclose (f);
#else
	char buf [80];
	int fd = open ("/proc/self/goto", O_WRONLY);
	int len = sprintf (buf, "%d\n", node);
	write (fd, buf, len);
	close (fd);
#endif
}

int main (int argc, char **argv) {
	int node;
	setvbuf (stdout, NULL, _IOLBF, 0);
	printf ("I'm on node %d\n", where ());
	if (argc < 2 || (node = atoi (argv[1])) <= 0) return 0;
	printf ("Moving to node %d\n", node);
	go_to (node);
	printf ("Now I'm on node %d\n", where ());
	return 0;
}

--------------050202080307000201080306
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
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
--------------050202080307000201080306
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ssic-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ssic-linux-devel

--------------050202080307000201080306--