Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/kernel.cfa

    r24e321c r445f984  
    341341                                }
    342342
    343                                 __STATS( if(this->print_halts) __cfaabi_bits_print_safe( STDOUT_FILENO, "PH:%d - %lld 0\n", this->unique_id, rdtscl()); )
     343                                        __STATS( if(this->print_halts) __cfaabi_bits_print_safe( STDOUT_FILENO, "PH:%d - %lld 0\n", this->unique_id, rdtscl()); )
    344344                                __cfadbg_print_safe(runtime_core, "Kernel : core %p waiting on eventfd %d\n", this, this->idle);
    345345
    346                                 {
    347                                         eventfd_t val;
    348                                         ssize_t ret = read( this->idle, &val, sizeof(val) );
    349                                         if(ret < 0) {
    350                                                 switch((int)errno) {
    351                                                 case EAGAIN:
    352                                                 #if EAGAIN != EWOULDBLOCK
    353                                                         case EWOULDBLOCK:
    354                                                 #endif
    355                                                 case EINTR:
    356                                                         // No need to do anything special here, just assume it's a legitimate wake-up
    357                                                         break;
    358                                                 default:
    359                                                         abort( "KERNEL : internal error, read failure on idle eventfd, error(%d) %s.", (int)errno, strerror( (int)errno ) );
    360                                                 }
    361                                         }
    362                                 }
     346                                // __disable_interrupts_hard();
     347                                eventfd_t val;
     348                                eventfd_read( this->idle, &val );
     349                                // __enable_interrupts_hard();
    363350
    364351                                        __STATS( if(this->print_halts) __cfaabi_bits_print_safe( STDOUT_FILENO, "PH:%d - %lld 1\n", this->unique_id, rdtscl()); )
     
    422409        /* paranoid */ verifyf( thrd_dst->link.next == 0p, "Expected null got %p", thrd_dst->link.next );
    423410        __builtin_prefetch( thrd_dst->context.SP );
     411
     412        int curr = __kernel_getcpu();
     413        if(thrd_dst->last_cpu != curr) {
     414                int64_t l = thrd_dst->last_cpu;
     415                int64_t c = curr;
     416                int64_t v = (l << 32) | c;
     417                __push_stat( __tls_stats(), v, false, "Processor", this );
     418        }
     419
     420        thrd_dst->last_cpu = curr;
    424421
    425422        __cfadbg_print_safe(runtime_core, "Kernel : core %p running thread %p (%s)\n", this, thrd_dst, thrd_dst->self_cor.name);
     
    476473                if(unlikely(thrd_dst->preempted != __NO_PREEMPTION)) {
    477474                        // The thread was preempted, reschedule it and reset the flag
    478                         schedule_thread$( thrd_dst, UNPARK_LOCAL );
     475                        schedule_thread$( thrd_dst );
    479476                        break RUNNING;
    480477                }
     
    560557// Scheduler routines
    561558// KERNEL ONLY
    562 static void __schedule_thread( thread$ * thrd, unpark_hint hint ) {
     559static void __schedule_thread( thread$ * thrd ) {
    563560        /* paranoid */ verify( ! __preemption_enabled() );
    564561        /* paranoid */ verify( ready_schedule_islocked());
     
    580577        // Dereference the thread now because once we push it, there is not guaranteed it's still valid.
    581578        struct cluster * cl = thrd->curr_cluster;
    582         __STATS(bool outside = hint == UNPARK_LOCAL && thrd->last_proc && thrd->last_proc != kernelTLS().this_processor; )
     579        __STATS(bool outside = thrd->last_proc && thrd->last_proc != kernelTLS().this_processor; )
    583580
    584581        // push the thread to the cluster ready-queue
    585         push( cl, thrd, hint );
     582        push( cl, thrd, local );
    586583
    587584        // variable thrd is no longer safe to use
     
    608605}
    609606
    610 void schedule_thread$( thread$ * thrd, unpark_hint hint ) {
     607void schedule_thread$( thread$ * thrd ) {
    611608        ready_schedule_lock();
    612                 __schedule_thread( thrd, hint );
     609                __schedule_thread( thrd );
    613610        ready_schedule_unlock();
    614611}
     
    661658}
    662659
    663 void __kernel_unpark( thread$ * thrd, unpark_hint hint ) {
     660void __kernel_unpark( thread$ * thrd ) {
    664661        /* paranoid */ verify( ! __preemption_enabled() );
    665662        /* paranoid */ verify( ready_schedule_islocked());
     
    669666        if(__must_unpark(thrd)) {
    670667                // Wake lost the race,
    671                 __schedule_thread( thrd, hint );
     668                __schedule_thread( thrd );
    672669        }
    673670
     
    676673}
    677674
    678 void unpark( thread$ * thrd, unpark_hint hint ) {
     675void unpark( thread$ * thrd ) {
    679676        if( !thrd ) return;
    680677
     
    682679                disable_interrupts();
    683680                        // Wake lost the race,
    684                         schedule_thread$( thrd, hint );
     681                        schedule_thread$( thrd );
    685682                enable_interrupts(false);
    686683        }
Note: See TracChangeset for help on using the changeset viewer.