Changeset 3260ada in mainline


Ignore:
Timestamp:
2006-02-04T21:08:45Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e72b0a3
Parents:
04225a7
Message:

Simplify load balancing activation.
This in fact removes the livelock that prevented cpu_sleep() to be called in SMP systems.

Location:
generic
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • generic/include/cpu.h

    r04225a7 r3260ada  
    5858        link_t timeout_active_head;
    5959
    60         #ifdef CONFIG_SMP
    61         atomic_t kcpulbstarted;
    62         waitq_t kcpulb_wq;
    63         #endif /* CONFIG_SMP */
    64 
    6560        /**
    6661         * Processor ID assigned by kernel.
  • generic/src/cpu/cpu.c

    r04225a7 r3260ada  
    6868                        spinlock_initialize(&cpus[i].lock, "cpu_t.lock");
    6969
    70                         #ifdef CONFIG_SMP
    71                         waitq_initialize(&cpus[i].kcpulb_wq);
    72                         #endif /* __SMP */
    73                        
    7470                        for (j = 0; j < RQ_COUNT; j++) {
    7571                                spinlock_initialize(&cpus[i].rq[j].lock, "rq_t.lock");
  • generic/src/proc/scheduler.c

    r04225a7 r3260ada  
    134134       
    135135        if (n == 0) {
    136                 #ifdef CONFIG_SMP
    137                 /*
    138                  * If the load balancing thread is not running, wake it up and
    139                  * set CPU-private flag that the kcpulb has been started.
    140                  */
    141                 if (test_and_set(&CPU->kcpulbstarted) == 0) {
    142                         waitq_wakeup(&CPU->kcpulb_wq, 0);
    143                         goto loop;
    144                 }
    145                 #endif /* CONFIG_SMP */
    146                
    147136                /*
    148137                 * For there was nothing to run, the CPU goes to sleep
    149138                 * until a hardware interrupt or an IPI comes.
    150139                 * This improves energy saving and hyperthreading.
    151                  * On the other hand, several hardware interrupts can be ignored.
    152140                 */
    153141                 cpu_sleep();
     
    482470loop:
    483471        /*
    484          * Sleep until there's some work to do.
     472         * Work in 1s intervals.
    485473         */
    486         waitq_sleep(&CPU->kcpulb_wq);
     474        thread_sleep(1);
    487475
    488476not_satisfied:
     
    579567                                spinlock_lock(&t->lock);
    580568                                #ifdef KCPULB_VERBOSE
    581                                 printf("kcpulb%d: TID %d -> cpu%d, nrdy=%d, avg=%d\n", CPU->id, t->tid, CPU->id, CPU->nrdy, nrdy / config.cpu_active);
     569                                printf("kcpulb%d: TID %d -> cpu%d, nrdy=%d, avg=%d\n", CPU->id, t->tid, CPU->id, CPU->nrdy, atomic_get(&nrdy) / config.cpu_active);
    582570                                #endif
    583571                                t->flags |= X_STOLEN;
     
    607595                 */
    608596                scheduler();
    609         }
    610         else {
     597        } else {
    611598                /*
    612599                 * We failed to migrate a single thread.
    613                  * Something more sophisticated should be done.
     600                 * Give up this turn.
    614601                 */
    615                 scheduler();
     602                goto loop;
    616603        }
    617604               
     
    619606
    620607satisfied:
    621         /*
    622          * Tell find_best_thread() to wake us up later again.
    623          */
    624         atomic_set(&CPU->kcpulbstarted,0);
    625608        goto loop;
    626609}
     
    656639                                continue;
    657640                        }
    658                         printf("Rq %d: ", i);
     641                        printf("\tRq %d: ", i);
    659642                        for (cur=r->rq_head.next; cur!=&r->rq_head; cur=cur->next) {
    660643                                t = list_get_instance(cur, thread_t, rq_link);
Note: See TracChangeset for help on using the changeset viewer.