diff options
author | dchagin <dchagin@FreeBSD.org> | 2015-05-24 14:39:26 +0000 |
---|---|---|
committer | dchagin <dchagin@FreeBSD.org> | 2015-05-24 14:39:26 +0000 |
commit | ca1941958a1672731cb74d00b3650f97c891f30a (patch) | |
tree | 94115023d7532fdd62f72bd56e6cad2f53e57572 | |
parent | 4d4fc642c1cac69730bd677223d965ae7b270dda (diff) | |
download | FreeBSD-src-ca1941958a1672731cb74d00b3650f97c891f30a.zip FreeBSD-src-ca1941958a1672731cb74d00b3650f97c891f30a.tar.gz |
In preparation for switching linuxulator to the use the native 1:1
threads refactor kern_sched_rr_get_interval() and sys_sched_rr_get_interval().
Add a kern_sched_rr_get_interval() counterpart which takes a targettd
parameter to allow specify target thread directly by callee (new Linuxulator).
Linuxulator temporarily uses first thread in proc.
Move linux_sched_rr_get_interval() to the MI part.
Differential Revision: https://reviews.freebsd.org/D1032
Reviewed by: trasz
-rw-r--r-- | sys/amd64/linux32/linux32_machdep.c | 16 | ||||
-rw-r--r-- | sys/compat/linux/linux_misc.c | 30 | ||||
-rw-r--r-- | sys/kern/p1003_1b.c | 19 | ||||
-rw-r--r-- | sys/sys/syscallsubr.h | 2 |
4 files changed, 48 insertions, 19 deletions
diff --git a/sys/amd64/linux32/linux32_machdep.c b/sys/amd64/linux32/linux32_machdep.c index 155e90b..339c898 100644 --- a/sys/amd64/linux32/linux32_machdep.c +++ b/sys/amd64/linux32/linux32_machdep.c @@ -925,22 +925,6 @@ linux_getrusage(struct thread *td, struct linux_getrusage_args *uap) } 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) { diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index ec531d3..f804f0e 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -1928,3 +1928,33 @@ linux_sched_setaffinity(struct thread *td, 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; + p = tdt->td_proc; + PROC_LOCK(p); + } 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); + PROC_UNLOCK(p); + if (error != 0) + return (error); + lts.tv_sec = ts.tv_sec; + lts.tv_nsec = ts.tv_nsec; + return (copyout(<s, uap->interval, sizeof(lts))); +} diff --git a/sys/kern/p1003_1b.c b/sys/kern/p1003_1b.c index fb89efc..3d1656a 100644 --- a/sys/kern/p1003_1b.c +++ b/sys/kern/p1003_1b.c @@ -296,13 +296,26 @@ kern_sched_rr_get_interval(struct thread *td, pid_t pid, targettd = FIRST_THREAD_IN_PROC(targetp); } - e = p_cansee(td, targetp); - if (e == 0) - e = ksched_rr_get_interval(ksched, targettd, ts); + e = kern_sched_rr_get_interval_td(td, targettd, ts); PROC_UNLOCK(targetp); return (e); } +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); + return (error); +} #endif static void diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h index 4954e46..debb728 100644 --- a/sys/sys/syscallsubr.h +++ b/sys/sys/syscallsubr.h @@ -171,6 +171,8 @@ int kern_rmdirat(struct thread *td, int fd, char *path, 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, |