diff mbox

[libcilkrts] Fix 64-bit SPARC/Linux port

Message ID 1587620.v97RmY0WqK@polaris
State New
Headers show

Commit Message

Eric Botcazou June 23, 2017, 5:34 p.m. UTC
Since libcilkrts was ported to the SPARC architecture by Rainer, running the 
testsuite on SPARC/Linux in 64-bit mode with sufficiently high parallelim has 
resulted in an almost guaranteed kernel panic.

Fixed thusly, tested on SPARC64/Linux and SPARC/Solaris., applied to mainline 
and 7 branch.  Rainer kindly agreed to submit a copy of the fix to the master 
repository when he gets a chance.

	* runtime/config/sparc/os-unix-sysdep.c (__cilkrts_getticks): Adjust
	preprocessor test for SPARC/Linux.
	* runtime/jmpbuf.h (CILK_[UN]ADJUST_SP): Likewise.

Comments

David Miller June 23, 2017, 6:44 p.m. UTC | #1
From: Eric Botcazou <ebotcazou@libertysurf.fr>
Date: Fri, 23 Jun 2017 19:34:54 +0200

> Since libcilkrts was ported to the SPARC architecture by Rainer, running the 
> testsuite on SPARC/Linux in 64-bit mode with sufficiently high parallelim has 
> resulted in an almost guaranteed kernel panic.
> 
> Fixed thusly, tested on SPARC64/Linux and SPARC/Solaris., applied to mainline 
> and 7 branch.  Rainer kindly agreed to submit a copy of the fix to the master 
> repository when he gets a chance.

Ok, but the kernel shouldn't crash because of a bad stack pointer.

The fact that an unaligned stack access causes the problem is a good
clue.  Thanks, I'll try to look into this.
diff mbox

Patch

Index: runtime/config/sparc/os-unix-sysdep.c
===================================================================
--- runtime/config/sparc/os-unix-sysdep.c	(revision 249451)
+++ runtime/config/sparc/os-unix-sysdep.c	(working copy)
@@ -47,7 +47,7 @@ 
  *  for your assistance in helping us improve Cilk Plus.
  *************************************************************************
  *
- * This file contains system-specific code for sparc-based systems
+ * This file contains system-specific code for SPARC-based systems
  */
 
 #include "os.h"
@@ -60,7 +60,7 @@ 
 COMMON_SYSDEP unsigned long long __cilkrts_getticks(void)
 {
     unsigned long long tick;
-#ifdef __sparcv9
+#if defined(__sparcv9) || defined(__arch64__)
     __asm__ volatile("rd %%tick, %0" : "=r"(tick));
 #else
     __asm__ volatile("rd %%tick, %L0\n"
Index: runtime/jmpbuf.h
===================================================================
--- runtime/jmpbuf.h	(revision 249451)
+++ runtime/jmpbuf.h	(working copy)
@@ -110,8 +110,8 @@ 
 /**
  * @brief Some architecture-dependent stack adjustment.
  */
-#if defined(__sparcv9)
-    // Subtract sparc v9 stack bias so the actual stack starts at the
+#if defined(__sparcv9) || (defined(__sparc__) && defined(__arch64__))
+    // Subtract SPARC V9 stack bias so the actual stack starts at the
     // allocated area.
 #   define CILK_ADJUST_SP(SP) ((SP) - 2047)
 #   define CILK_UNADJUST_SP(SP) ((SP) + 2047)