sched_yield(): avoid schedule for single thread

This commit is contained in:
Balazs Gerofi
2016-12-05 18:10:08 +09:00
parent 0ab7d02994
commit 491e14d942

View File

@ -6449,7 +6449,23 @@ SYSCALL_DECLARE(nanosleep)
SYSCALL_DECLARE(sched_yield)
{
struct cpu_local_var *v;
int do_schedule = 0;
long runq_irqstate;
runq_irqstate =
ihk_mc_spinlock_lock(&(get_this_cpu_local_var()->runq_lock));
v = get_this_cpu_local_var();
if (v->flags & CPU_FLAG_NEED_RESCHED || v->runq_len > 1) {
do_schedule = 1;
}
ihk_mc_spinlock_unlock(&v->runq_lock, runq_irqstate);
if (do_schedule) {
schedule();
}
return 0;
}