From owner-svn-src-head@FreeBSD.ORG Sun May 24 14:39:28 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2D472101; Sun, 24 May 2015 14:39:28 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1B0BB16AD; Sun, 24 May 2015 14:39:28 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t4OEdRmX024684; Sun, 24 May 2015 14:39:27 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t4OEdRGD024680; Sun, 24 May 2015 14:39:27 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201505241439.t4OEdRGD024680@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sun, 24 May 2015 14:39:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r283374 - in head/sys: amd64/linux32 compat/linux kern sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 May 2015 14:39:28 -0000 Author: dchagin Date: Sun May 24 14:39:26 2015 New Revision: 283374 URL: https://svnweb.freebsd.org/changeset/base/283374 Log: 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 Modified: head/sys/amd64/linux32/linux32_machdep.c head/sys/compat/linux/linux_misc.c head/sys/kern/p1003_1b.c head/sys/sys/syscallsubr.h Modified: head/sys/amd64/linux32/linux32_machdep.c ============================================================================== --- head/sys/amd64/linux32/linux32_machdep.c Sun May 24 14:37:45 2015 (r283373) +++ head/sys/amd64/linux32/linux32_machdep.c Sun May 24 14:39:26 2015 (r283374) @@ -925,22 +925,6 @@ linux_getrusage(struct thread *td, struc } 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) { Modified: head/sys/compat/linux/linux_misc.c ============================================================================== --- head/sys/compat/linux/linux_misc.c Sun May 24 14:37:45 2015 (r283373) +++ head/sys/compat/linux/linux_misc.c Sun May 24 14:39:26 2015 (r283374) @@ -1928,3 +1928,33 @@ linux_sched_setaffinity(struct thread *t 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))); +} Modified: head/sys/kern/p1003_1b.c ============================================================================== --- head/sys/kern/p1003_1b.c Sun May 24 14:37:45 2015 (r283373) +++ head/sys/kern/p1003_1b.c Sun May 24 14:39:26 2015 (r283374) @@ -296,13 +296,26 @@ kern_sched_rr_get_interval(struct thread 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 Modified: head/sys/sys/syscallsubr.h ============================================================================== --- head/sys/sys/syscallsubr.h Sun May 24 14:37:45 2015 (r283373) +++ head/sys/sys/syscallsubr.h Sun May 24 14:39:26 2015 (r283374) @@ -171,6 +171,8 @@ int kern_rmdirat(struct thread *td, int 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,