diff options
| author | Nick Piggin <nickpiggin@yahoo.com.au> | 2004-08-23 21:07:54 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-08-23 21:07:54 -0700 |
| commit | 8a78765b8a93722ddabe6ccd4884ebaae726a05c (patch) | |
| tree | 96fd312bf2453e50617664190bc4f7fb816ffe8f /kernel | |
| parent | 0df0d0635a54f071415d6994fd4c397c98ae57fd (diff) | |
[PATCH] sched: sched misc changes
Add some likely/unliklies, a for_each_cpu => for_each_cpu_online, and close
the sched_exit race.
From: Ingo Molnar <mingo@elte.hu>
fix a typo in a previous patch breaking RT scheduling & interactivity.
Signed-off-by: Nick Piggin <nickpiggin@yahoo.com.au>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/sched.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/kernel/sched.c b/kernel/sched.c index 51433fb2903a..21d777561e71 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -941,7 +941,7 @@ void fastcall sched_fork(task_t *p, unsigned long clone_flags) 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 @@ -1048,18 +1048,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 / @@ -1159,7 +1157,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; @@ -2313,7 +2311,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; } |
