From owner-svn-src-stable-10@freebsd.org Sat Jan 9 14:47:10 2016 Return-Path: Delivered-To: svn-src-stable-10@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 72F34A69440; Sat, 9 Jan 2016 14:47:10 +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 4A5EA1F22; Sat, 9 Jan 2016 14:47:10 +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 u09El9JE005659; Sat, 9 Jan 2016 14:47:09 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u09El9Vu005656; Sat, 9 Jan 2016 14:47:09 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201601091447.u09El9Vu005656@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:47:09 +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: r293487 - in stable/10/sys: amd64/linux32 compat/linux i386/linux X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jan 2016 14:47:10 -0000 Author: dchagin Date: Sat Jan 9 14:47:08 2016 New Revision: 293487 URL: https://svnweb.freebsd.org/changeset/base/293487 Log: MFC r283379: Implement a Linux version of sched_getparam() && sched_setparam(). Temporarily use the first thread in proc. Modified: stable/10/sys/amd64/linux32/syscalls.master stable/10/sys/compat/linux/linux_misc.c stable/10/sys/i386/linux/syscalls.master Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/amd64/linux32/syscalls.master ============================================================================== --- stable/10/sys/amd64/linux32/syscalls.master Sat Jan 9 14:45:41 2016 (r293486) +++ stable/10/sys/amd64/linux32/syscalls.master Sat Jan 9 14:47:08 2016 (r293487) @@ -267,10 +267,10 @@ 151 AUE_MUNLOCK NOPROTO { int munlock(const void *addr, size_t len); } 152 AUE_MLOCKALL NOPROTO { int mlockall(int how); } 153 AUE_MUNLOCKALL NOPROTO { int munlockall(void); } -154 AUE_SCHED_SETPARAM NOPROTO { int sched_setparam(pid_t pid, \ - const struct sched_param *param); } -155 AUE_SCHED_GETPARAM NOPROTO { int sched_getparam(pid_t pid, \ - struct sched_param *param); } +154 AUE_SCHED_SETPARAM STD { int linux_sched_setparam(l_pid_t pid, \ + struct l_sched_param *param); } +155 AUE_SCHED_GETPARAM STD { int linux_sched_getparam(l_pid_t pid, \ + struct l_sched_param *param); } 156 AUE_SCHED_SETSCHEDULER STD { int linux_sched_setscheduler( \ l_pid_t pid, l_int policy, \ struct l_sched_param *param); } Modified: stable/10/sys/compat/linux/linux_misc.c ============================================================================== --- stable/10/sys/compat/linux/linux_misc.c Sat Jan 9 14:45:41 2016 (r293486) +++ stable/10/sys/compat/linux/linux_misc.c Sat Jan 9 14:47:08 2016 (r293487) @@ -1871,6 +1871,78 @@ linux_prctl(struct thread *td, struct li return (error); } +int +linux_sched_setparam(struct thread *td, + struct linux_sched_setparam_args *uap) +{ + struct sched_param sched_param; + struct thread *tdt; + struct proc *p; + int error; + +#ifdef DEBUG + if (ldebug(sched_setparam)) + printf(ARGS(sched_setparam, "%d, *"), uap->pid); +#endif + + error = copyin(uap->param, &sched_param, sizeof(sched_param)); + if (error) + return (error); + + if (uap->pid == 0) { + tdt = td; + p = tdt->td_proc; + PROC_LOCK(p); + } else { + p = pfind(uap->pid); + if (p == NULL) + return (ESRCH); + /* + * XXX. Scheduling parameters are in fact per-thread + * attributes in Linux. Temporarily use the first + * thread in proc. The same for get_param(). + */ + tdt = FIRST_THREAD_IN_PROC(p); + } + + error = kern_sched_setparam(td, tdt, &sched_param); + PROC_UNLOCK(p); + return (error); +} + +int +linux_sched_getparam(struct thread *td, + struct linux_sched_getparam_args *uap) +{ + struct sched_param sched_param; + struct thread *tdt; + struct proc *p; + int error; + +#ifdef DEBUG + if (ldebug(sched_getparam)) + printf(ARGS(sched_getparam, "%d, *"), uap->pid); +#endif + + 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_getparam(td, tdt, &sched_param); + PROC_UNLOCK(p); + if (error == 0) + error = copyout(&sched_param, uap->param, + sizeof(sched_param)); + return (error); +} + /* * Get affinity of a process. */ Modified: stable/10/sys/i386/linux/syscalls.master ============================================================================== --- stable/10/sys/i386/linux/syscalls.master Sat Jan 9 14:45:41 2016 (r293486) +++ stable/10/sys/i386/linux/syscalls.master Sat Jan 9 14:47:08 2016 (r293487) @@ -269,10 +269,10 @@ 151 AUE_MUNLOCK NOPROTO { int munlock(const void *addr, size_t len); } 152 AUE_MLOCKALL NOPROTO { int mlockall(int how); } 153 AUE_MUNLOCKALL NOPROTO { int munlockall(void); } -154 AUE_SCHED_SETPARAM NOPROTO { int sched_setparam(pid_t pid, \ - const struct sched_param *param); } -155 AUE_SCHED_GETPARAM NOPROTO { int sched_getparam(pid_t pid, \ - struct sched_param *param); } +154 AUE_SCHED_SETPARAM STD { int linux_sched_setparam(l_pid_t pid, \ + struct l_sched_param *param); } +155 AUE_SCHED_GETPARAM STD { int linux_sched_getparam(l_pid_t pid, \ + struct l_sched_param *param); } 156 AUE_SCHED_SETSCHEDULER STD { int linux_sched_setscheduler( \ l_pid_t pid, l_int policy, \ struct l_sched_param *param); }