- Timestamp:
- Feb 9, 2022, 3:33:42 PM (4 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
- Children:
- 850aff1
- Parents:
- 21a99cc (diff), c4f81702 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- libcfa/src
- Files:
-
- 5 edited
-
concurrency/preemption.cfa (modified) (7 diffs)
-
concurrency/stats.cfa (modified) (3 diffs)
-
concurrency/stats.hfa (modified) (1 diff)
-
stdhdr/pthread.h (modified) (1 diff)
-
stdhdr/setjmp.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/preemption.cfa
r21a99cc ra554e5f4 251 251 bool enabled = __cfaabi_tls.preemption_state.enabled; 252 252 253 // Check if there is a pending preemption 254 processor * proc = __cfaabi_tls.this_processor; 255 bool pending = proc ? proc->pending_preemption : false; 256 if( enabled && pending ) proc->pending_preemption = false; 257 253 258 // create a assembler label after 254 259 // marked as clobber all to avoid movement 255 260 __cfaasm_label(check, after); 261 262 // If we can preempt and there is a pending one 263 // this is a good time to yield 264 if( enabled && pending ) { 265 force_yield( __POLL_PREEMPTION ); 266 } 256 267 return enabled; 257 268 } … … 282 293 // marked as clobber all to avoid movement 283 294 __cfaasm_label(get, after); 295 296 // This is used everywhere, to avoid cost, we DO NOT poll pending preemption 284 297 return val; 285 298 } … … 358 371 if(!ready) { abort("Preemption should be ready"); } 359 372 360 __cfaasm_label(debug, before); 361 362 sigset_t oldset; 363 int ret; 364 ret = pthread_sigmask(0, ( const sigset_t * ) 0p, &oldset); // workaround trac#208: cast should be unnecessary 365 if(ret != 0) { abort("ERROR sigprocmask returned %d", ret); } 366 367 ret = sigismember(&oldset, SIGUSR1); 368 if(ret < 0) { abort("ERROR sigismember returned %d", ret); } 369 if(ret == 1) { abort("ERROR SIGUSR1 is disabled"); } 370 371 ret = sigismember(&oldset, SIGALRM); 372 if(ret < 0) { abort("ERROR sigismember returned %d", ret); } 373 if(ret == 0) { abort("ERROR SIGALRM is enabled"); } 374 375 ret = sigismember(&oldset, SIGTERM); 376 if(ret < 0) { abort("ERROR sigismember returned %d", ret); } 377 if(ret == 1) { abort("ERROR SIGTERM is disabled"); } 378 379 __cfaasm_label(debug, after); 373 sigset_t oldset; 374 int ret; 375 ret = pthread_sigmask(0, ( const sigset_t * ) 0p, &oldset); // workaround trac#208: cast should be unnecessary 376 if(ret != 0) { abort("ERROR sigprocmask returned %d", ret); } 377 378 ret = sigismember(&oldset, SIGUSR1); 379 if(ret < 0) { abort("ERROR sigismember returned %d", ret); } 380 if(ret == 1) { abort("ERROR SIGUSR1 is disabled"); } 381 382 ret = sigismember(&oldset, SIGALRM); 383 if(ret < 0) { abort("ERROR sigismember returned %d", ret); } 384 if(ret == 0) { abort("ERROR SIGALRM is enabled"); } 385 386 ret = sigismember(&oldset, SIGTERM); 387 if(ret < 0) { abort("ERROR sigismember returned %d", ret); } 388 if(ret == 1) { abort("ERROR SIGTERM is disabled"); } 380 389 } 381 390 … … 548 557 __cfaasm_label( check ); 549 558 __cfaasm_label( dsable ); 550 __cfaasm_label( debug );559 // __cfaasm_label( debug ); 551 560 552 561 // Check if preemption is safe … … 555 564 if( __cfaasm_in( ip, check ) ) { ready = false; goto EXIT; }; 556 565 if( __cfaasm_in( ip, dsable ) ) { ready = false; goto EXIT; }; 557 if( __cfaasm_in( ip, debug ) ) { ready = false; goto EXIT; };566 // if( __cfaasm_in( ip, debug ) ) { ready = false; goto EXIT; }; 558 567 if( !__cfaabi_tls.preemption_state.enabled) { ready = false; goto EXIT; }; 559 568 if( __cfaabi_tls.preemption_state.in_progress ) { ready = false; goto EXIT; }; … … 661 670 662 671 // Check if it is safe to preempt here 663 if( !preemption_ready( ip ) ) { return; } 672 if( !preemption_ready( ip ) ) { 673 #if !defined(__CFA_NO_STATISTICS__) 674 __cfaabi_tls.this_stats->ready.threads.preempt.rllfwd++; 675 #endif 676 return; 677 } 664 678 665 679 __cfaabi_dbg_print_buffer_decl( " KERNEL: preempting core %p (%p @ %p).\n", __cfaabi_tls.this_processor, __cfaabi_tls.this_thread, (void *)(cxt->uc_mcontext.CFA_REG_IP) ); … … 680 694 681 695 // Preemption can occur here 696 697 #if !defined(__CFA_NO_STATISTICS__) 698 __cfaabi_tls.this_stats->ready.threads.preempt.yield++; 699 #endif 682 700 683 701 force_yield( __ALARM_PREEMPTION ); // Do the actual __cfactx_switch -
libcfa/src/concurrency/stats.cfa
r21a99cc ra554e5f4 29 29 stats->ready.threads.threads = 0; 30 30 stats->ready.threads.cthreads = 0; 31 stats->ready.threads.preempt.yield = 0; 32 stats->ready.threads.preempt.rllfwd = 0; 31 33 stats->ready.sleep.halts = 0; 32 34 stats->ready.sleep.cancels = 0; … … 77 79 78 80 void __tally_stats( struct __stats_t * cltr, struct __stats_t * proc ) { 79 tally_one( &cltr->ready.push.local.attempt, &proc->ready.push.local.attempt ); 80 tally_one( &cltr->ready.push.local.success, &proc->ready.push.local.success ); 81 tally_one( &cltr->ready.push.share.attempt, &proc->ready.push.share.attempt ); 82 tally_one( &cltr->ready.push.share.success, &proc->ready.push.share.success ); 83 tally_one( &cltr->ready.push.extrn.attempt, &proc->ready.push.extrn.attempt ); 84 tally_one( &cltr->ready.push.extrn.success, &proc->ready.push.extrn.success ); 85 tally_one( &cltr->ready.pop.local .attempt, &proc->ready.pop.local .attempt ); 86 tally_one( &cltr->ready.pop.local .success, &proc->ready.pop.local .success ); 87 tally_one( &cltr->ready.pop.help .attempt, &proc->ready.pop.help .attempt ); 88 tally_one( &cltr->ready.pop.help .success, &proc->ready.pop.help .success ); 89 tally_one( &cltr->ready.pop.steal .attempt, &proc->ready.pop.steal .attempt ); 90 tally_one( &cltr->ready.pop.steal .success, &proc->ready.pop.steal .success ); 91 tally_one( &cltr->ready.pop.search.attempt, &proc->ready.pop.search.attempt ); 92 tally_one( &cltr->ready.pop.search.success, &proc->ready.pop.search.success ); 93 tally_one( &cltr->ready.threads.migration , &proc->ready.threads.migration ); 94 tally_one( &cltr->ready.threads.extunpark , &proc->ready.threads.extunpark ); 95 tally_one( &cltr->ready.threads.threads , &proc->ready.threads.threads ); 96 tally_one( &cltr->ready.threads.cthreads , &proc->ready.threads.cthreads ); 97 tally_one( &cltr->ready.sleep.halts , &proc->ready.sleep.halts ); 98 tally_one( &cltr->ready.sleep.cancels , &proc->ready.sleep.cancels ); 99 tally_one( &cltr->ready.sleep.early , &proc->ready.sleep.early ); 100 tally_one( &cltr->ready.sleep.wakes , &proc->ready.sleep.wakes ); 101 tally_one( &cltr->ready.sleep.seen , &proc->ready.sleep.wakes ); 102 tally_one( &cltr->ready.sleep.exits , &proc->ready.sleep.exits ); 81 tally_one( &cltr->ready.push.local.attempt , &proc->ready.push.local.attempt ); 82 tally_one( &cltr->ready.push.local.success , &proc->ready.push.local.success ); 83 tally_one( &cltr->ready.push.share.attempt , &proc->ready.push.share.attempt ); 84 tally_one( &cltr->ready.push.share.success , &proc->ready.push.share.success ); 85 tally_one( &cltr->ready.push.extrn.attempt , &proc->ready.push.extrn.attempt ); 86 tally_one( &cltr->ready.push.extrn.success , &proc->ready.push.extrn.success ); 87 tally_one( &cltr->ready.pop.local .attempt , &proc->ready.pop.local .attempt ); 88 tally_one( &cltr->ready.pop.local .success , &proc->ready.pop.local .success ); 89 tally_one( &cltr->ready.pop.help .attempt , &proc->ready.pop.help .attempt ); 90 tally_one( &cltr->ready.pop.help .success , &proc->ready.pop.help .success ); 91 tally_one( &cltr->ready.pop.steal .attempt , &proc->ready.pop.steal .attempt ); 92 tally_one( &cltr->ready.pop.steal .success , &proc->ready.pop.steal .success ); 93 tally_one( &cltr->ready.pop.search.attempt , &proc->ready.pop.search.attempt ); 94 tally_one( &cltr->ready.pop.search.success , &proc->ready.pop.search.success ); 95 tally_one( &cltr->ready.threads.migration , &proc->ready.threads.migration ); 96 tally_one( &cltr->ready.threads.extunpark , &proc->ready.threads.extunpark ); 97 tally_one( &cltr->ready.threads.threads , &proc->ready.threads.threads ); 98 tally_one( &cltr->ready.threads.cthreads , &proc->ready.threads.cthreads ); 99 tally_one( &cltr->ready.threads.preempt.yield , &proc->ready.threads.preempt.yield ); 100 tally_one( &cltr->ready.threads.preempt.rllfwd, &proc->ready.threads.preempt.rllfwd ); 101 tally_one( &cltr->ready.sleep.halts , &proc->ready.sleep.halts ); 102 tally_one( &cltr->ready.sleep.cancels , &proc->ready.sleep.cancels ); 103 tally_one( &cltr->ready.sleep.early , &proc->ready.sleep.early ); 104 tally_one( &cltr->ready.sleep.wakes , &proc->ready.sleep.wakes ); 105 tally_one( &cltr->ready.sleep.seen , &proc->ready.sleep.wakes ); 106 tally_one( &cltr->ready.sleep.exits , &proc->ready.sleep.exits ); 103 107 104 108 #if defined(CFA_HAVE_LINUX_IO_URING_H) … … 168 172 | eng3(ready.sleep.wakes + ready.sleep.early) | '(' | eng3(ready.sleep.early) | ',' | eng3(ready.sleep.seen) | ')' | " wake(early, seen)," 169 173 | eng3(ready.sleep.exits) | "exit"; 174 sstr | "- Preemption : " | eng3(ready.threads.preempt.yield) | "yields," | eng3(ready.threads.preempt.rllfwd) | "delayed"; 170 175 sstr | nl; 171 176 } -
libcfa/src/concurrency/stats.hfa
r21a99cc ra554e5f4 65 65 volatile int64_t threads; // number of threads in the system, includes only local change 66 66 volatile int64_t cthreads; // number of threads in the system, includes only local change 67 struct { 68 volatile uint64_t yield; 69 volatile uint64_t rllfwd; 70 } preempt; 67 71 } threads; 68 72 struct { -
libcfa/src/stdhdr/pthread.h
r21a99cc ra554e5f4 10 10 // Created On : Wed Jun 16 13:39:06 2021 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jun 16 13:39:42 202113 // Update Count : 1 12 // Last Modified On : Thu Feb 3 21:53:26 2022 13 // Update Count : 13 14 14 // 15 15 16 // pthread.h and setjmp.h cannot agree on the type of __sigsetjmp: 17 // 18 // extern int __sigsetjmp (struct __jmp_buf_tag *__env, int __savemask) __attribute__ ((__nothrow__)); 19 // extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask) __attribute__ ((__nothrow__)); 20 // 21 // With -Wall, gcc-11 warns about the disagreement unless the CPP directive 22 // 23 // # 1 "/usr/include/pthread.h" 1 3 4 24 // 25 // appears, which appears to be witchcraft. Unfortunately, this directive is removed by the CFA preprocessor, so the 26 // batchtest fails because of the spurious warning message. Hence, the warning is elided. 27 16 28 extern "C" { 29 #if defined(__GNUC__) && __GNUC__ == 11 30 #pragma GCC diagnostic push 31 #pragma GCC diagnostic ignored "-Warray-parameter" 32 #endif // defined(__GNUC__) && __GNUC__ == 11 33 17 34 #include_next <pthread.h> // has internal check for multiple expansion 35 36 #if defined(__GNUC__) && __GNUC__ == 11 37 #pragma GCC diagnostic pop 38 #endif // defined(__GNUC__) && __GNUC__ == 11 18 39 } // extern "C" 19 40 20 41 // Local Variables: // 21 // tab-width: 4 //22 42 // mode: c++ // 23 // compile-command: "make install" //24 43 // End: // -
libcfa/src/stdhdr/setjmp.h
r21a99cc ra554e5f4 10 10 // Created On : Mon Jul 4 23:25:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jul 5 20:38:33 201613 // Update Count : 1 212 // Last Modified On : Thu Feb 3 21:53:28 2022 13 // Update Count : 18 14 14 // 15 15 16 // pthread.h and setjmp.h cannot agree on the type of __sigsetjmp: 17 // 18 // extern int __sigsetjmp (struct __jmp_buf_tag *__env, int __savemask) __attribute__ ((__nothrow__)); 19 // extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask) __attribute__ ((__nothrow__)); 20 // 21 // With -Wall, gcc-11 warns about the disagreement unless the CPP directive 22 // 23 // # 1 "/usr/include/pthread.h" 1 3 4 24 // 25 // appears, which appears to be witchcraft. Unfortunately, this directive is removed by the CFA preprocessor, so the 26 // batchtest fails because of the spurious warning message. Hence, the warning is elided. 27 16 28 extern "C" { 29 #if defined(__GNUC__) && __GNUC__ == 11 30 #pragma GCC diagnostic push 31 #pragma GCC diagnostic ignored "-Warray-parameter" 32 #endif // defined(__GNUC__) && __GNUC__ == 11 33 17 34 #include_next <setjmp.h> // has internal check for multiple expansion 35 36 #if defined(__GNUC__) && __GNUC__ == 11 37 #pragma GCC diagnostic pop 38 #endif // defined(__GNUC__) && __GNUC__ == 11 18 39 } // extern "C" 19 40 20 41 // Local Variables: // 21 // tab-width: 4 //22 42 // mode: c++ // 23 // compile-command: "make install" //24 43 // End: //
Note:
See TracChangeset
for help on using the changeset viewer.