Index: sys/amd64/linux32/linux32_machdep.c =================================================================== --- sys/amd64/linux32/linux32_machdep.c +++ sys/amd64/linux32/linux32_machdep.c @@ -917,22 +917,6 @@ } int -linux_sched_rr_get_interval(struct thread *td, - struct linux_sched_rr_get_interval_args *uap) -{ - struct timespec ts; - struct l_timespec ts32; - int error; - - error = kern_sched_rr_get_interval(td, uap->pid, &ts); - if (error != 0) - return (error); - ts32.tv_sec = ts.tv_sec; - ts32.tv_nsec = ts.tv_nsec; - return (copyout(&ts32, uap->interval, sizeof(ts32))); -} - -int linux_set_thread_area(struct thread *td, struct linux_set_thread_area_args *args) { Index: sys/compat/linux/linux_misc.c =================================================================== --- sys/compat/linux/linux_misc.c +++ sys/compat/linux/linux_misc.c @@ -1925,3 +1925,31 @@ return (sys_cpuset_setaffinity(td, &csa)); } + +int +linux_sched_rr_get_interval(struct thread *td, + struct linux_sched_rr_get_interval_args *uap) +{ + struct timespec ts; + struct l_timespec lts; + struct thread *tdt; + struct proc *p; + int error; + + if (uap->pid == 0) { + tdt = td; + PROC_LOCK(tdt->td_proc); + } else { + p = pfind(uap->pid); + if (p == NULL) + return (ESRCH); + tdt = FIRST_THREAD_IN_PROC(p); + } + + error = kern_sched_rr_get_interval_td(td, tdt, &ts); + if (error != 0) + return (error); + lts.tv_sec = ts.tv_sec; + lts.tv_nsec = ts.tv_nsec; + return (copyout(<s, uap->interval, sizeof(lts))); +} Index: sys/kern/p1003_1b.c =================================================================== --- sys/kern/p1003_1b.c +++ sys/kern/p1003_1b.c @@ -281,7 +281,6 @@ kern_sched_rr_get_interval(struct thread *td, pid_t pid, struct timespec *ts) { - int e; struct thread *targettd; struct proc *targetp; @@ -296,13 +295,25 @@ targettd = FIRST_THREAD_IN_PROC(targetp); } - e = p_cansee(td, targetp); - if (e == 0) - e = ksched_rr_get_interval(ksched, targettd, ts); - PROC_UNLOCK(targetp); - return (e); + return (kern_sched_rr_get_interval_td(td, targettd, ts)); } +int +kern_sched_rr_get_interval_td(struct thread *td, struct thread *targettd, + struct timespec *ts) +{ + struct proc *p; + int error; + + p = targettd->td_proc; + PROC_LOCK_ASSERT(p, MA_OWNED); + + error = p_cansee(td, p); + if (error == 0) + error = ksched_rr_get_interval(ksched, targettd, ts); + PROC_UNLOCK(p); + return (error); +} #endif static void Index: sys/sys/syscallsubr.h =================================================================== --- sys/sys/syscallsubr.h +++ sys/sys/syscallsubr.h @@ -192,6 +192,8 @@ enum uio_seg pathseg); int kern_sched_rr_get_interval(struct thread *td, pid_t pid, struct timespec *ts); +int kern_sched_rr_get_interval_td(struct thread *td, struct thread *targettd, + struct timespec *ts); int kern_semctl(struct thread *td, int semid, int semnum, int cmd, union semun *arg, register_t *rval); int kern_select(struct thread *td, int nd, fd_set *fd_in, fd_set *fd_ou,