- Timestamp:
- Jan 30, 2022, 1:16:50 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
- Children:
- 473d1da0, 8e5e945
- Parents:
- ac6fc48
- Location:
- libcfa/src/concurrency
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel.cfa
rac6fc48 rc9c1c1c 42 42 43 43 #if !defined(__CFA_NO_STATISTICS__) 44 #define __STATS ( ...) __VA_ARGS__44 #define __STATS_DEF( ...) __VA_ARGS__ 45 45 #else 46 #define __STATS ( ...)46 #define __STATS_DEF( ...) 47 47 #endif 48 48 … … 122 122 static thread$ * __next_thread(cluster * this); 123 123 static thread$ * __next_thread_slow(cluster * this); 124 static thread$ * __next_thread_search(cluster * this); 124 125 static inline bool __must_unpark( thread$ * thrd ) __attribute((nonnull(1))); 125 126 static void __run_thread(processor * this, thread$ * dst); … … 194 195 195 196 if( !readyThread ) { 196 __ tls_stats()->io.flush.idle++;197 __IO_STATS__(true, io.flush.idle++; ) 197 198 __cfa_io_flush( this, 0 ); 198 199 200 readyThread = __next_thread( this->cltr ); 201 } 202 203 if( !readyThread ) for(5) { 204 __IO_STATS__(true, io.flush.idle++; ) 205 199 206 readyThread = __next_thread_slow( this->cltr ); 207 208 if( readyThread ) break; 209 210 __cfa_io_flush( this, 0 ); 200 211 } 201 212 … … 209 220 210 221 // Confirm the ready-queue is empty 211 readyThread = __next_thread_s low( this->cltr );222 readyThread = __next_thread_search( this->cltr ); 212 223 if( readyThread ) { 213 224 // A thread was found, cancel the halt 214 225 mark_awake(this->cltr->procs, * this); 215 226 216 #if !defined(__CFA_NO_STATISTICS__) 217 __tls_stats()->ready.sleep.cancels++; 218 #endif 227 __STATS__(true, ready.sleep.cancels++; ) 219 228 220 229 // continue the mai loop … … 243 252 244 253 if(this->io.pending && !this->io.dirty) { 245 __ tls_stats()->io.flush.dirty++;254 __IO_STATS__(true, io.flush.dirty++; ) 246 255 __cfa_io_flush( this, 0 ); 247 256 } … … 356 365 break RUNNING; 357 366 case TICKET_UNBLOCK: 358 #if !defined(__CFA_NO_STATISTICS__) 359 __tls_stats()->ready.threads.threads++; 360 #endif 367 __STATS__(true, ready.threads.threads++; ) 361 368 // This is case 2, the racy case, someone tried to run this thread before it finished blocking 362 369 // In this case, just run it again. … … 373 380 __cfadbg_print_safe(runtime_core, "Kernel : core %p finished running thread %p\n", this, thrd_dst); 374 381 375 #if !defined(__CFA_NO_STATISTICS__) 376 __tls_stats()->ready.threads.threads--; 377 #endif 382 __STATS__(true, ready.threads.threads--; ) 378 383 379 384 /* paranoid */ verify( ! __preemption_enabled() ); … … 386 391 thread$ * thrd_src = kernelTLS().this_thread; 387 392 388 __STATS ( thrd_src->last_proc = kernelTLS().this_processor; )393 __STATS_DEF( thrd_src->last_proc = kernelTLS().this_processor; ) 389 394 390 395 // Run the thread on this processor … … 438 443 // Dereference the thread now because once we push it, there is not guaranteed it's still valid. 439 444 struct cluster * cl = thrd->curr_cluster; 440 __STATS (bool outside = hint == UNPARK_LOCAL && thrd->last_proc && thrd->last_proc != kernelTLS().this_processor; )445 __STATS_DEF(bool outside = hint == UNPARK_LOCAL && thrd->last_proc && thrd->last_proc != kernelTLS().this_processor; ) 441 446 442 447 // push the thread to the cluster ready-queue … … 489 494 490 495 ready_schedule_lock(); 491 thread$ * thrd; 492 for(25) { 493 thrd = pop_slow( this ); 494 if(thrd) goto RET; 495 } 496 thrd = pop_search( this ); 497 498 RET: 496 thread$ * thrd = pop_slow( this ); 497 ready_schedule_unlock(); 498 499 /* paranoid */ verify( ! __preemption_enabled() ); 500 return thrd; 501 } 502 503 // KERNEL ONLY 504 static inline thread$ * __next_thread_search(cluster * this) with( *this ) { 505 /* paranoid */ verify( ! __preemption_enabled() ); 506 507 ready_schedule_lock(); 508 thread$ * thrd = pop_search( this ); 499 509 ready_schedule_unlock(); 500 510 … … 738 748 739 749 static bool mark_idle(__cluster_proc_list & this, processor & proc) { 740 #if !defined(__CFA_NO_STATISTICS__) 741 __tls_stats()->ready.sleep.halts++; 742 #endif 750 __STATS__(true, ready.sleep.halts++; ) 743 751 744 752 proc.idle_wctx.fd = 0; -
libcfa/src/concurrency/kernel/fwd.hfa
rac6fc48 rc9c1c1c 396 396 if( !(in_kernel) ) enable_interrupts(); \ 397 397 } 398 #if defined(CFA_HAVE_LINUX_IO_URING_H) 399 #define __IO_STATS__(in_kernel, ...) { \ 400 if( !(in_kernel) ) disable_interrupts(); \ 401 with( *__tls_stats() ) { \ 402 __VA_ARGS__ \ 403 } \ 404 if( !(in_kernel) ) enable_interrupts(); \ 405 } 406 #else 407 #define __IO_STATS__(in_kernel, ...) 408 #endif 398 409 #else 399 410 #define __STATS__(in_kernel, ...) 411 #define __IO_STATS__(in_kernel, ...) 400 412 #endif 401 413 }
Note: See TracChangeset
for help on using the changeset viewer.