Use a name instead of a magic number for kern_yield(9) when the priority
should not change. Fetch the td_user_pri under the thread lock. This is probably not necessary but a magic number also seems preferable to knowing the implementation details here. Requested by: Jason Behmer < jason DOT behmer AT isilon DOT com >
This commit is contained in:
parent
c4f9a10590
commit
3d08a76bbc
@ -551,7 +551,7 @@ maybe_yield(void)
|
||||
{
|
||||
|
||||
if (should_yield())
|
||||
kern_yield(curthread->td_user_pri);
|
||||
kern_yield(PRI_USER);
|
||||
}
|
||||
|
||||
void
|
||||
@ -562,6 +562,8 @@ kern_yield(int prio)
|
||||
td = curthread;
|
||||
DROP_GIANT();
|
||||
thread_lock(td);
|
||||
if (prio == PRI_USER)
|
||||
prio = td->td_user_pri;
|
||||
if (prio >= 0)
|
||||
sched_prio(td, prio);
|
||||
mi_switch(SW_VOL | SWT_RELINQUISH, NULL);
|
||||
|
@ -1590,7 +1590,7 @@ userland_sysctl(struct thread *td, int *name, u_int namelen, void *old,
|
||||
SYSCTL_XUNLOCK();
|
||||
if (error != EAGAIN)
|
||||
break;
|
||||
kern_yield(curthread->td_user_pri);
|
||||
kern_yield(PRI_USER);
|
||||
}
|
||||
|
||||
CURVNET_RESTORE();
|
||||
|
@ -2234,7 +2234,7 @@ buf_daemon()
|
||||
while (numdirtybuffers > lodirtybuffers) {
|
||||
if (buf_do_flush(NULL) == 0)
|
||||
break;
|
||||
kern_yield(-1);
|
||||
kern_yield(PRI_UNCHANGED);
|
||||
}
|
||||
lodirtybuffers = lodirtysave;
|
||||
|
||||
|
@ -1644,7 +1644,7 @@ __mnt_vnode_next(struct vnode **mvp, struct mount *mp)
|
||||
KASSERT((*mvp)->v_mount == mp, ("marker vnode mount list mismatch"));
|
||||
if (should_yield()) {
|
||||
MNT_IUNLOCK(mp);
|
||||
kern_yield(-1);
|
||||
kern_yield(PRI_UNCHANGED);
|
||||
MNT_ILOCK(mp);
|
||||
}
|
||||
vp = TAILQ_NEXT(*mvp, v_nmntvnodes);
|
||||
|
@ -718,7 +718,7 @@ vlrureclaim(struct mount *mp)
|
||||
continue;
|
||||
MNT_IUNLOCK(mp);
|
||||
yield:
|
||||
kern_yield(-1);
|
||||
kern_yield(PRI_UNCHANGED);
|
||||
relock_mnt:
|
||||
MNT_ILOCK(mp);
|
||||
}
|
||||
@ -831,7 +831,7 @@ vnlru_proc(void)
|
||||
vnlru_nowhere++;
|
||||
tsleep(vnlruproc, PPAUSE, "vlrup", hz * 3);
|
||||
} else
|
||||
kern_yield(-1);
|
||||
kern_yield(PRI_UNCHANGED);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -491,7 +491,7 @@ vn_rdwr_inchunks(rw, vp, base, len, offset, segflg, ioflg, active_cred,
|
||||
break;
|
||||
offset += chunk;
|
||||
base = (char *)base + chunk;
|
||||
kern_yield(curthread->td_user_pri);
|
||||
kern_yield(PRI_USER);
|
||||
} while (len);
|
||||
if (aresid)
|
||||
*aresid = len + iaresid;
|
||||
|
@ -117,6 +117,12 @@
|
||||
#define PRI_MIN_IDLE (224)
|
||||
#define PRI_MAX_IDLE (PRI_MAX)
|
||||
|
||||
#ifdef _KERNEL
|
||||
/* Other arguments for kern_yield(9). */
|
||||
#define PRI_USER -2 /* Change to current user priority. */
|
||||
#define PRI_UNCHANGED -1 /* Do not change priority. */
|
||||
#endif
|
||||
|
||||
struct priority {
|
||||
u_char pri_class; /* Scheduling class. */
|
||||
u_char pri_level; /* Normal priority level. */
|
||||
|
@ -1412,7 +1412,7 @@ softdep_process_worklist(mp, full)
|
||||
*/
|
||||
if (should_yield()) {
|
||||
FREE_LOCK(&lk);
|
||||
kern_yield(-1);
|
||||
kern_yield(PRI_UNCHANGED);
|
||||
bwillwrite();
|
||||
ACQUIRE_LOCK(&lk);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user