Subject: Re: sched_changepri
To: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
From: Andrew Doran <ad@netbsd.org>
List: tech-kern
Date: 02/27/2007 12:35:18
On Sun, Feb 25, 2007 at 05:21:22PM +0900, YAMAMOTO Takashi wrote:

> - why doesn't sched_changepri() change l_priority if it was < PUSER? 

If the LWP has received a priority boost while in the kernel and is waiting
to run it shouldn't get dropped until it has run. Right now the drop in
priority takes place in userret(). I think that should be moved back into
remrunqueue() once cpu_switch() is eliminated.

> - which of the following is the preferred way to change the priority?
> 
> 	- uvm_scheduler does:
> 		l = curlwp;
> 		lwp_lock(l);
> 		lwp_changepri(l, PVM);
> 		lwp_unlock(l);
> 
> 	- workqueue_worker does:
> 		l = curlwp;
> 		lwp_lock(l);
> 		l->l_priority = wq->wq_prio;
> 		l->l_usrpri = wq->wq_prio;
> 		lwp_unlock(l);

The second the right thing to do in this case -- lwp_changepri() was the
wrong thing to use. To fix it properly we should be able to give newlwp() /
kthread_create() the priority before the LWP is created.

Andrew