> Date: Wed, 6 Jul 2016 18:21:21 +0200
> From: Martin Pieuchot <[email protected]>
> 
> Kernel threads are cooperative and yield.  I'd argue that preempt()
> should be kept for user processes hogging CPUs.  So let's be coherent
> with the rest of the kernel and use sched_pause() here.  ok?

To be honest, I'd argue that that if SPC_SHOULDYIELD is set, the
context switch is *involuntary*.  That argues for making the change
you propose, but also make sched_pause() call preempt(NULL) instead of
yield().

But perhaps we should also think about what the difference between
preempt(NULL) and yield() really means.  Besides the differences in
accounting (which doesn't really matter), the former calls
sched_choosecpu(), wheras the latter doesn't.

In any case, I agree that what we currently have is inconsistent.

> Index: uvm/uvm_glue.c
> ===================================================================
> RCS file: /cvs/src/sys/uvm/uvm_glue.c,v
> retrieving revision 1.70
> diff -u -p -r1.70 uvm_glue.c
> --- uvm/uvm_glue.c    13 Sep 2015 17:08:03 -0000      1.70
> +++ uvm/uvm_glue.c    6 Jul 2016 16:18:49 -0000
> @@ -473,8 +473,7 @@ uvm_pause(void)
>               KERNEL_UNLOCK();
>               KERNEL_LOCK();
>       }
> -     if (curcpu()->ci_schedstate.spc_schedflags & SPCF_SHOULDYIELD)
> -             preempt(NULL);
> +     sched_pause();
>  }
>  
>  #ifndef SMALL_KERNEL
> 
> 

Reply via email to