diff options
author | jb <jb@FreeBSD.org> | 2006-10-26 21:42:22 +0000 |
---|---|---|
committer | jb <jb@FreeBSD.org> | 2006-10-26 21:42:22 +0000 |
commit | f82c7997354f95e680341bb8e10136ded5fd15eb (patch) | |
tree | 2136d90e7e60f4ef25fe147499787d0e6a155b82 /sys/kern/kern_resource.c | |
parent | b3e38fbc69f126c6cc49a0a6e45096d6c01b7c43 (diff) | |
download | FreeBSD-src-f82c7997354f95e680341bb8e10136ded5fd15eb.zip FreeBSD-src-f82c7997354f95e680341bb8e10136ded5fd15eb.tar.gz |
Make KSE a kernel option, turned on by default in all GENERIC
kernel configs except sun4v (which doesn't process signals properly
with KSE).
Reviewed by: davidxu@
Diffstat (limited to 'sys/kern/kern_resource.c')
-rw-r--r-- | sys/kern/kern_resource.c | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c index 1556993..524631f 100644 --- a/sys/kern/kern_resource.c +++ b/sys/kern/kern_resource.c @@ -318,7 +318,11 @@ rtprio_thread(struct thread *td, struct rtprio_thread_args *uap) else td1 = thread_find(p, uap->lwpid); if (td1 != NULL) +#ifdef KSE pri_to_rtp(td1->td_ksegrp, &rtp); +#else + pri_to_rtp(td1, &rtp); +#endif else error = ESRCH; mtx_unlock_spin(&sched_lock); @@ -354,7 +358,11 @@ rtprio_thread(struct thread *td, struct rtprio_thread_args *uap) else td1 = thread_find(p, uap->lwpid); if (td1 != NULL) +#ifdef KSE error = rtp_to_pri(&rtp, td1->td_ksegrp); +#else + error = rtp_to_pri(&rtp, td1); +#endif else error = ESRCH; mtx_unlock_spin(&sched_lock); @@ -387,7 +395,11 @@ rtprio(td, uap) { struct proc *curp; struct proc *p; +#ifdef KSE struct ksegrp *kg; +#else + struct thread *tdp; +#endif struct rtprio rtp; int cierror, error; @@ -423,14 +435,23 @@ rtprio(td, uap) * as leaving it zero. */ if (uap->pid == 0) { +#ifdef KSE pri_to_rtp(td->td_ksegrp, &rtp); +#else + pri_to_rtp(td, &rtp); +#endif } else { struct rtprio rtp2; rtp.type = RTP_PRIO_IDLE; rtp.prio = RTP_PRIO_MAX; +#ifdef KSE FOREACH_KSEGRP_IN_PROC(p, kg) { pri_to_rtp(kg, &rtp2); +#else + FOREACH_THREAD_IN_PROC(p, tdp) { + pri_to_rtp(tdp, &rtp2); +#endif if (rtp2.type < rtp.type || (rtp2.type == rtp.type && rtp2.prio < rtp.prio)) { @@ -471,20 +492,39 @@ rtprio(td, uap) } } +#ifdef KSE /* * If we are setting our own priority, set just our * KSEGRP but if we are doing another process, * do all the groups on that process. If we * specify our own pid we do the latter. */ +#else + /* + * If we are setting our own priority, set just our + * thread but if we are doing another process, + * do all the threads on that process. If we + * specify our own pid we do the latter. + */ +#endif mtx_lock_spin(&sched_lock); if (uap->pid == 0) { +#ifdef KSE error = rtp_to_pri(&rtp, td->td_ksegrp); +#else + error = rtp_to_pri(&rtp, td); +#endif } else { +#ifdef KSE FOREACH_KSEGRP_IN_PROC(p, kg) { if ((error = rtp_to_pri(&rtp, kg)) != 0) { break; } +#else + FOREACH_THREAD_IN_PROC(p, td) { + if ((error = rtp_to_pri(&rtp, td)) != 0) + break; +#endif } } mtx_unlock_spin(&sched_lock); @@ -498,7 +538,11 @@ rtprio(td, uap) } int +#ifdef KSE rtp_to_pri(struct rtprio *rtp, struct ksegrp *kg) +#else +rtp_to_pri(struct rtprio *rtp, struct thread *td) +#endif { mtx_assert(&sched_lock, MA_OWNED); @@ -506,43 +550,85 @@ rtp_to_pri(struct rtprio *rtp, struct ksegrp *kg) return (EINVAL); switch (RTP_PRIO_BASE(rtp->type)) { case RTP_PRIO_REALTIME: +#ifdef KSE kg->kg_user_pri = PRI_MIN_REALTIME + rtp->prio; +#else + td->td_user_pri = PRI_MIN_REALTIME + rtp->prio; +#endif break; case RTP_PRIO_NORMAL: +#ifdef KSE kg->kg_user_pri = PRI_MIN_TIMESHARE + rtp->prio; +#else + td->td_user_pri = PRI_MIN_TIMESHARE + rtp->prio; +#endif break; case RTP_PRIO_IDLE: +#ifdef KSE kg->kg_user_pri = PRI_MIN_IDLE + rtp->prio; +#else + td->td_user_pri = PRI_MIN_IDLE + rtp->prio; +#endif break; default: return (EINVAL); } +#ifdef KSE sched_class(kg, rtp->type); if (curthread->td_ksegrp == kg) { sched_prio(curthread, kg->kg_user_pri); /* XXX dubious */ } +#else + sched_class(td, rtp->type); /* XXX fix */ + if (curthread == td) + sched_prio(curthread, td->td_user_pri); /* XXX dubious */ +#endif return (0); } void +#ifdef KSE pri_to_rtp(struct ksegrp *kg, struct rtprio *rtp) +#else +pri_to_rtp(struct thread *td, struct rtprio *rtp) +#endif { mtx_assert(&sched_lock, MA_OWNED); +#ifdef KSE switch (PRI_BASE(kg->kg_pri_class)) { +#else + switch (PRI_BASE(td->td_pri_class)) { +#endif case PRI_REALTIME: +#ifdef KSE rtp->prio = kg->kg_user_pri - PRI_MIN_REALTIME; +#else + rtp->prio = td->td_user_pri - PRI_MIN_REALTIME; +#endif break; case PRI_TIMESHARE: +#ifdef KSE rtp->prio = kg->kg_user_pri - PRI_MIN_TIMESHARE; +#else + rtp->prio = td->td_user_pri - PRI_MIN_TIMESHARE; +#endif break; case PRI_IDLE: +#ifdef KSE rtp->prio = kg->kg_user_pri - PRI_MIN_IDLE; +#else + rtp->prio = td->td_user_pri - PRI_MIN_IDLE; +#endif break; default: break; } +#ifdef KSE rtp->type = kg->kg_pri_class; +#else + rtp->type = td->td_pri_class; +#endif } #if defined(COMPAT_43) |