From owner-svn-src-all@freebsd.org Sat Jan 9 14:44:43 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 03886A692C2; Sat, 9 Jan 2016 14:44:43 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 B552A1BA5; Sat, 9 Jan 2016 14:44:42 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u09EifTN005456; Sat, 9 Jan 2016 14:44:41 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u09EifBD005454; Sat, 9 Jan 2016 14:44:41 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201601091444.u09EifBD005454@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sat, 9 Jan 2016 14:44:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r293485 - in stable/10/sys: kern sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jan 2016 14:44:43 -0000 Author: dchagin Date: Sat Jan 9 14:44:41 2016 New Revision: 293485 URL: https://svnweb.freebsd.org/changeset/base/293485 Log: MFC r283377: In preparation for switching linuxulator to the use the native 1:1 threads split sys_sched_getparam(), sys_sched_setparam(), sys_sched_getscheduler(), sys_sched_setscheduler() to their kern_* counterparts and add targettd parameter to allow specify the target thread directly by callee. Modified: stable/10/sys/kern/p1003_1b.c stable/10/sys/sys/syscallsubr.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/p1003_1b.c ============================================================================== --- stable/10/sys/kern/p1003_1b.c Sat Jan 9 14:43:16 2016 (r293484) +++ stable/10/sys/kern/p1003_1b.c Sat Jan 9 14:44:41 2016 (r293485) @@ -130,16 +130,29 @@ sys_sched_setparam(struct thread *td, st targettd = FIRST_THREAD_IN_PROC(targetp); } - e = p_cansched(td, targetp); - if (e == 0) { - e = ksched_setparam(ksched, targettd, - (const struct sched_param *)&sched_param); - } + e = kern_sched_setparam(td, targettd, &sched_param); PROC_UNLOCK(targetp); return (e); } int +kern_sched_setparam(struct thread *td, struct thread *targettd, + struct sched_param *param) +{ + struct proc *targetp; + int error; + + targetp = targettd->td_proc; + PROC_LOCK_ASSERT(targetp, MA_OWNED); + + error = p_cansched(td, targetp); + if (error == 0) + error = ksched_setparam(ksched, targettd, + (const struct sched_param *)param); + return (error); +} + +int sys_sched_getparam(struct thread *td, struct sched_getparam_args *uap) { int e; @@ -159,10 +172,7 @@ sys_sched_getparam(struct thread *td, st targettd = FIRST_THREAD_IN_PROC(targetp); } - e = p_cansee(td, targetp); - if (e == 0) { - e = ksched_getparam(ksched, targettd, &sched_param); - } + e = kern_sched_getparam(td, targettd, &sched_param); PROC_UNLOCK(targetp); if (e == 0) e = copyout(&sched_param, uap->param, sizeof(sched_param)); @@ -170,6 +180,22 @@ sys_sched_getparam(struct thread *td, st } int +kern_sched_getparam(struct thread *td, struct thread *targettd, + struct sched_param *param) +{ + struct proc *targetp; + int error; + + targetp = targettd->td_proc; + PROC_LOCK_ASSERT(targetp, MA_OWNED); + + error = p_cansee(td, targetp); + if (error == 0) + error = ksched_getparam(ksched, targettd, param); + return (error); +} + +int sys_sched_setscheduler(struct thread *td, struct sched_setscheduler_args *uap) { int e; @@ -177,11 +203,6 @@ sys_sched_setscheduler(struct thread *td struct thread *targettd; struct proc *targetp; - /* Don't allow non root user to set a scheduler policy. */ - e = priv_check(td, PRIV_SCHED_SET); - if (e) - return (e); - e = copyin(uap->param, &sched_param, sizeof(sched_param)); if (e) return (e); @@ -197,16 +218,35 @@ sys_sched_setscheduler(struct thread *td targettd = FIRST_THREAD_IN_PROC(targetp); } - e = p_cansched(td, targetp); - if (e == 0) { - e = ksched_setscheduler(ksched, targettd, - uap->policy, (const struct sched_param *)&sched_param); - } + e = kern_sched_setscheduler(td, targettd, uap->policy, + &sched_param); PROC_UNLOCK(targetp); return (e); } int +kern_sched_setscheduler(struct thread *td, struct thread *targettd, + int policy, struct sched_param *param) +{ + struct proc *targetp; + int error; + + targetp = targettd->td_proc; + PROC_LOCK_ASSERT(targetp, MA_OWNED); + + /* Don't allow non root user to set a scheduler policy. */ + error = priv_check(td, PRIV_SCHED_SET); + if (error) + return (error); + + error = p_cansched(td, targetp); + if (error == 0) + error = ksched_setscheduler(ksched, targettd, policy, + (const struct sched_param *)param); + return (error); +} + +int sys_sched_getscheduler(struct thread *td, struct sched_getscheduler_args *uap) { int e, policy; @@ -224,17 +264,31 @@ sys_sched_getscheduler(struct thread *td targettd = FIRST_THREAD_IN_PROC(targetp); } - e = p_cansee(td, targetp); - if (e == 0) { - e = ksched_getscheduler(ksched, targettd, &policy); - td->td_retval[0] = policy; - } + e = kern_sched_getscheduler(td, targettd, &policy); PROC_UNLOCK(targetp); + if (e == 0) + td->td_retval[0] = policy; return (e); } int +kern_sched_getscheduler(struct thread *td, struct thread *targettd, + int *policy) +{ + struct proc *targetp; + int error; + + targetp = targettd->td_proc; + PROC_LOCK_ASSERT(targetp, MA_OWNED); + + error = p_cansee(td, targetp); + if (error == 0) + error = ksched_getscheduler(ksched, targettd, policy); + return (error); +} + +int sys_sched_yield(struct thread *td, struct sched_yield_args *uap) { Modified: stable/10/sys/sys/syscallsubr.h ============================================================================== --- stable/10/sys/sys/syscallsubr.h Sat Jan 9 14:43:16 2016 (r293484) +++ stable/10/sys/sys/syscallsubr.h Sat Jan 9 14:44:41 2016 (r293485) @@ -55,6 +55,7 @@ struct sendfile_args; struct sockaddr; struct stat; struct thr_param; +struct sched_param; struct __wrusage; int kern___getcwd(struct thread *td, char *buf, enum uio_seg bufseg, @@ -195,6 +196,14 @@ int kern_renameat(struct thread *td, int int kern_rmdir(struct thread *td, char *path, enum uio_seg pathseg); int kern_rmdirat(struct thread *td, int fd, char *path, enum uio_seg pathseg); +int kern_sched_getparam(struct thread *td, struct thread *targettd, + struct sched_param *param); +int kern_sched_getscheduler(struct thread *td, struct thread *targettd, + int *policy); +int kern_sched_setparam(struct thread *td, struct thread *targettd, + struct sched_param *param); +int kern_sched_setscheduler(struct thread *td, struct thread *targettd, + int policy, struct sched_param *param); 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,