From: Nick Piggin Add some likely/unliklies, a for_each_cpu => for_each_cpu_online, and close the sched_exit race. Signed-off-by: Nick Piggin DESC sched: fix RT scheduling & interactivity estimator EDESC From: Ingo Molnar fix a typo in a previous patch breaking RT scheduling & interactivity. Signed-off-by: Ingo Molnar Signed-off-by: Andrew Morton --- 25-akpm/kernel/sched.c | 18 ++++++++---------- 1 files changed, 8 insertions(+), 10 deletions(-) diff -puN kernel/sched.c~sched-misc kernel/sched.c --- 25/kernel/sched.c~sched-misc Mon Aug 16 16:01:30 2004 +++ 25-akpm/kernel/sched.c Mon Aug 16 16:01:32 2004 @@ -942,7 +942,7 @@ void fastcall sched_fork(task_t *p, unsi p->first_time_slice = 1; current->time_slice >>= 1; p->timestamp = sched_clock(); - if (!current->time_slice) { + if (unlikely(!current->time_slice)) { /* * This case is rare, it happens when the parent has only * a single jiffy left from its timeslice. Taking the @@ -1049,18 +1049,16 @@ void fastcall sched_exit(task_t * p) unsigned long flags; runqueue_t *rq; - local_irq_save(flags); - if (p->first_time_slice) { - p->parent->time_slice += p->time_slice; - if (unlikely(p->parent->time_slice > MAX_TIMESLICE)) - p->parent->time_slice = MAX_TIMESLICE; - } - local_irq_restore(flags); /* * If the child was a (relative-) CPU hog then decrease * the sleep_avg of the parent as well. */ rq = task_rq_lock(p->parent, &flags); + if (p->first_time_slice) { + p->parent->time_slice += p->time_slice; + if (unlikely(p->parent->time_slice > MAX_TIMESLICE)) + p->parent->time_slice = MAX_TIMESLICE; + } if (p->sleep_avg < p->parent->sleep_avg) p->parent->sleep_avg = p->parent->sleep_avg / (EXIT_WEIGHT + 1) * EXIT_WEIGHT + p->sleep_avg / @@ -1160,7 +1158,7 @@ unsigned long nr_running(void) { unsigned long i, sum = 0; - for_each_cpu(i) + for_each_online_cpu(i) sum += cpu_rq(i)->nr_running; return sum; @@ -2314,7 +2312,7 @@ switch_tasks: reacquire_kernel_lock(current); preempt_enable_no_resched(); - if (test_thread_flag(TIF_NEED_RESCHED)) + if (unlikely(test_thread_flag(TIF_NEED_RESCHED))) goto need_resched; } _