Changeset a8667ab for libcfa/src/concurrency/kernel
- Timestamp:
- Mar 2, 2023, 4:47:52 PM (21 months ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 13f066d
- Parents:
- 397c4392
- Location:
- libcfa/src/concurrency/kernel
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel/cluster.cfa
r397c4392 ra8667ab 69 69 } 70 70 71 #if defined(CFA_HAVE_LINUX_LIBRSEQ)72 // No forward declaration needed73 #define __kernel_rseq_register rseq_register_current_thread74 #define __kernel_rseq_unregister rseq_unregister_current_thread75 #elif defined(CFA_HAVE_LINUX_RSEQ_H)76 static void __kernel_raw_rseq_register (void);77 static void __kernel_raw_rseq_unregister(void);78 79 #define __kernel_rseq_register __kernel_raw_rseq_register80 #define __kernel_rseq_unregister __kernel_raw_rseq_unregister81 #else82 // No forward declaration needed83 // No initialization needed84 static inline void noop(void) {}85 86 #define __kernel_rseq_register noop87 #define __kernel_rseq_unregister noop88 #endif89 90 71 //======================================================================= 91 72 // Cluster wide reader-writer lock … … 110 91 // Lock-Free registering/unregistering of threads 111 92 unsigned register_proc_id( void ) with(__scheduler_lock.lock) { 112 __kernel_rseq_register();113 114 93 bool * handle = (bool *)&kernelTLS().sched_lock; 115 94 … … 161 140 162 141 __atomic_store_n(cell, 0p, __ATOMIC_RELEASE); 163 164 __kernel_rseq_unregister();165 142 } 166 143 … … 504 481 /* paranoid */ verify( mock_head(this) == this.l.prev ); 505 482 } 506 507 #if defined(CFA_HAVE_LINUX_LIBRSEQ)508 // No definition needed509 #elif defined(CFA_HAVE_LINUX_RSEQ_H)510 511 #if defined( __x86_64 ) || defined( __i386 )512 #define RSEQ_SIG 0x53053053513 #elif defined( __ARM_ARCH )514 #ifdef __ARMEB__515 #define RSEQ_SIG 0xf3def5e7 /* udf #24035 ; 0x5de3 (ARMv6+) */516 #else517 #define RSEQ_SIG 0xe7f5def3 /* udf #24035 ; 0x5de3 */518 #endif519 #endif520 521 extern void __disable_interrupts_hard();522 extern void __enable_interrupts_hard();523 524 static void __kernel_raw_rseq_register (void) {525 /* paranoid */ verify( __cfaabi_rseq.cpu_id == RSEQ_CPU_ID_UNINITIALIZED );526 527 // int ret = syscall(__NR_rseq, &__cfaabi_rseq, sizeof(struct rseq), 0, (sigset_t *)0p, _NSIG / 8);528 int ret = syscall(__NR_rseq, &__cfaabi_rseq, sizeof(struct rseq), 0, RSEQ_SIG);529 if(ret != 0) {530 int e = errno;531 switch(e) {532 case EINVAL: abort("KERNEL ERROR: rseq register invalid argument");533 case ENOSYS: abort("KERNEL ERROR: rseq register no supported");534 case EFAULT: abort("KERNEL ERROR: rseq register with invalid argument");535 case EBUSY : abort("KERNEL ERROR: rseq register already registered");536 case EPERM : abort("KERNEL ERROR: rseq register sig argument on unregistration does not match the signature received on registration");537 default: abort("KERNEL ERROR: rseq register unexpected return %d", e);538 }539 }540 }541 542 static void __kernel_raw_rseq_unregister(void) {543 /* paranoid */ verify( __cfaabi_rseq.cpu_id >= 0 );544 545 // int ret = syscall(__NR_rseq, &__cfaabi_rseq, sizeof(struct rseq), RSEQ_FLAG_UNREGISTER, (sigset_t *)0p, _NSIG / 8);546 int ret = syscall(__NR_rseq, &__cfaabi_rseq, sizeof(struct rseq), RSEQ_FLAG_UNREGISTER, RSEQ_SIG);547 if(ret != 0) {548 int e = errno;549 switch(e) {550 case EINVAL: abort("KERNEL ERROR: rseq unregister invalid argument");551 case ENOSYS: abort("KERNEL ERROR: rseq unregister no supported");552 case EFAULT: abort("KERNEL ERROR: rseq unregister with invalid argument");553 case EBUSY : abort("KERNEL ERROR: rseq unregister already registered");554 case EPERM : abort("KERNEL ERROR: rseq unregister sig argument on unregistration does not match the signature received on registration");555 default: abort("KERNEL ERROR: rseq unregisteunexpected return %d", e);556 }557 }558 }559 #else560 // No definition needed561 #endif -
libcfa/src/concurrency/kernel/private.hfa
r397c4392 ra8667ab 10 10 // Created On : Mon Feb 13 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 12 08:21:33 202013 // Update Count : 912 // Last Modified On : Thu Mar 2 16:04:46 2023 13 // Update Count : 11 14 14 // 15 15 … … 29 29 30 30 extern "C" { 31 #if defined(CFA_HAVE_LINUX_LIBRSEQ)32 #include <rseq/rseq.h>33 #elif defined(CFA_HAVE_LINUX_RSEQ_H)34 #include <linux/rseq.h>35 #else36 #ifndef _GNU_SOURCE37 #error kernel/private requires gnu_source38 #endif39 31 #include <sched.h> 40 #endif41 32 } 42 33 … … 110 101 // Hardware 111 102 112 #if defined(CFA_HAVE_LINUX_LIBRSEQ)113 // No data needed114 #elif defined(CFA_HAVE_LINUX_RSEQ_H)115 extern "Cforall" {116 extern __attribute__((aligned(64))) __thread volatile struct rseq __cfaabi_rseq;117 }118 #else119 // No data needed120 #endif121 122 103 static inline int __kernel_getcpu() { 123 104 /* paranoid */ verify( ! __preemption_enabled() ); 124 #if defined(CFA_HAVE_LINUX_LIBRSEQ)125 return rseq_current_cpu();126 #elif defined(CFA_HAVE_LINUX_RSEQ_H)127 int r = __cfaabi_rseq.cpu_id;128 /* paranoid */ verify( r >= 0 );129 return r;130 #else131 105 return sched_getcpu(); 132 #endif133 106 } 134 107 -
libcfa/src/concurrency/kernel/startup.cfa
r397c4392 ra8667ab 147 147 __scheduler_RWLock_t __scheduler_lock @= { 0 }; 148 148 149 #if defined(CFA_HAVE_LINUX_LIBRSEQ)150 // No data needed151 #elif defined(CFA_HAVE_LINUX_RSEQ_H)152 extern "Cforall" {153 __attribute__((aligned(64))) __thread volatile struct rseq __cfaabi_rseq @= {154 .cpu_id : RSEQ_CPU_ID_UNINITIALIZED,155 };156 }157 #else158 // No data needed159 #endif160 161 149 //----------------------------------------------------------------------------- 162 150 // Struct to steal stack
Note: See TracChangeset
for help on using the changeset viewer.