From owner-svn-src-stable@freebsd.org Sun Sep 6 17:32:35 2015 Return-Path: Delivered-To: svn-src-stable@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 2D71B9CB27D; Sun, 6 Sep 2015 17:32:35 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.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 19FA0145D; Sun, 6 Sep 2015 17:32:35 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t86HWYha058474; Sun, 6 Sep 2015 17:32:34 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t86HWYP6058471; Sun, 6 Sep 2015 17:32:34 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201509061732.t86HWYP6058471@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 6 Sep 2015 17:32:34 +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: r287507 - 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-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Sep 2015 17:32:35 -0000 Author: kib Date: Sun Sep 6 17:32:33 2015 New Revision: 287507 URL: https://svnweb.freebsd.org/changeset/base/287507 Log: MFC r287309: Remove single-use macros obfuscating malloc(9) and free(9) calls. Style. Modified: stable/10/sys/kern/ksched.c stable/10/sys/sys/posix4.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/ksched.c ============================================================================== --- stable/10/sys/kern/ksched.c Sun Sep 6 16:17:14 2015 (r287506) +++ stable/10/sys/kern/ksched.c Sun Sep 6 17:32:33 2015 (r287507) @@ -30,8 +30,7 @@ * SUCH DAMAGE. */ -/* ksched: Soft real time scheduling based on "rtprio". - */ +/* ksched: Soft real time scheduling based on "rtprio". */ #include __FBSDID("$FreeBSD$"); @@ -51,8 +50,7 @@ __FBSDID("$FreeBSD$"); FEATURE(kposix_priority_scheduling, "POSIX P1003.1B realtime extensions"); -/* ksched: Real-time extension to support POSIX priority scheduling. - */ +/* ksched: Real-time extension to support POSIX priority scheduling. */ struct ksched { struct timespec rr_interval; @@ -61,21 +59,21 @@ struct ksched { int ksched_attach(struct ksched **p) { - struct ksched *ksched= p31b_malloc(sizeof(*ksched)); + struct ksched *ksched; + ksched = malloc(sizeof(*ksched), M_P31B, M_WAITOK); ksched->rr_interval.tv_sec = 0; ksched->rr_interval.tv_nsec = 1000000000L / hz * sched_rr_interval(); - *p = ksched; - return 0; + return (0); } int ksched_detach(struct ksched *ks) { - p31b_free(ks); - return 0; + free(ks, M_P31B); + return (0); } /* @@ -108,47 +106,39 @@ static __inline int getscheduler(struct ksched *ksched, struct thread *td, int *policy) { struct rtprio rtp; - int e = 0; + int e; + e = 0; pri_to_rtp(td, &rtp); - switch (rtp.type) - { - case RTP_PRIO_FIFO: + switch (rtp.type) { + case RTP_PRIO_FIFO: *policy = SCHED_FIFO; break; - - case RTP_PRIO_REALTIME: + case RTP_PRIO_REALTIME: *policy = SCHED_RR; break; - - default: + default: *policy = SCHED_OTHER; break; } - - return e; + return (e); } int ksched_setparam(struct ksched *ksched, struct thread *td, const struct sched_param *param) { - int policy; - int e; + int e, policy; e = getscheduler(ksched, td, &policy); - if (e == 0) - { - e = ksched_setscheduler(ksched, td, policy, param); - } - - return e; + e = ksched_setscheduler(ksched, td, policy, param); + return (e); } int -ksched_getparam(struct ksched *ksched, - struct thread *td, struct sched_param *param) +ksched_getparam(struct ksched *ksched, struct thread *td, + struct sched_param *param) { struct rtprio rtp; @@ -159,13 +149,14 @@ ksched_getparam(struct ksched *ksched, if (PRI_MIN_TIMESHARE < rtp.prio) /* * The interactive score has it to min realtime - * so we must show max (64 most likely + * so we must show max (64 most likely). */ - param->sched_priority = (PRI_MAX_TIMESHARE - PRI_MIN_TIMESHARE); + param->sched_priority = PRI_MAX_TIMESHARE - + PRI_MIN_TIMESHARE; else param->sched_priority = tsprio_to_p4prio(rtp.prio); } - return 0; + return (0); } /* @@ -176,117 +167,106 @@ ksched_getparam(struct ksched *ksched, * */ int -ksched_setscheduler(struct ksched *ksched, - struct thread *td, int policy, const struct sched_param *param) +ksched_setscheduler(struct ksched *ksched, struct thread *td, int policy, + const struct sched_param *param) { - int e = 0; struct rtprio rtp; + int e; - switch(policy) - { - case SCHED_RR: - case SCHED_FIFO: - + e = 0; + switch(policy) { + case SCHED_RR: + case SCHED_FIFO: if (param->sched_priority >= P1B_PRIO_MIN && - param->sched_priority <= P1B_PRIO_MAX) - { + param->sched_priority <= P1B_PRIO_MAX) { rtp.prio = p4prio_to_rtpprio(param->sched_priority); - rtp.type = (policy == SCHED_FIFO) - ? RTP_PRIO_FIFO : RTP_PRIO_REALTIME; - + rtp.type = (policy == SCHED_FIFO) ? RTP_PRIO_FIFO : + RTP_PRIO_REALTIME; rtp_to_pri(&rtp, td); - } - else + } else { e = EPERM; - - + } break; - - case SCHED_OTHER: - if (param->sched_priority >= 0 && - param->sched_priority <= (PRI_MAX_TIMESHARE - PRI_MIN_TIMESHARE)) { + case SCHED_OTHER: + if (param->sched_priority >= 0 && param->sched_priority <= + (PRI_MAX_TIMESHARE - PRI_MIN_TIMESHARE)) { rtp.type = RTP_PRIO_NORMAL; rtp.prio = p4prio_to_tsprio(param->sched_priority); rtp_to_pri(&rtp, td); - } else + } else { e = EINVAL; - + } + break; + default: + e = EINVAL; break; - - default: - e = EINVAL; - break; } - - return e; + return (e); } int ksched_getscheduler(struct ksched *ksched, struct thread *td, int *policy) { - return getscheduler(ksched, td, policy); + + return (getscheduler(ksched, td, policy)); } -/* ksched_yield: Yield the CPU. - */ +/* ksched_yield: Yield the CPU. */ int ksched_yield(struct ksched *ksched) { + sched_relinquish(curthread); - return 0; + return (0); } int ksched_get_priority_max(struct ksched *ksched, int policy, int *prio) { - int e = 0; + int e; - switch (policy) - { - case SCHED_FIFO: - case SCHED_RR: + e = 0; + switch (policy) { + case SCHED_FIFO: + case SCHED_RR: *prio = RTP_PRIO_MAX; break; - - case SCHED_OTHER: + case SCHED_OTHER: *prio = PRI_MAX_TIMESHARE - PRI_MIN_TIMESHARE; break; - - default: + default: e = EINVAL; + break; } - - return e; + return (e); } int ksched_get_priority_min(struct ksched *ksched, int policy, int *prio) { - int e = 0; + int e; - switch (policy) - { - case SCHED_FIFO: - case SCHED_RR: + e = 0; + switch (policy) { + case SCHED_FIFO: + case SCHED_RR: *prio = P1B_PRIO_MIN; break; - - case SCHED_OTHER: + case SCHED_OTHER: *prio = 0; break; - - default: + default: e = EINVAL; + break; } - - return e; + return (e); } int -ksched_rr_get_interval(struct ksched *ksched, - struct thread *td, struct timespec *timespec) +ksched_rr_get_interval(struct ksched *ksched, struct thread *td, + struct timespec *timespec) { - *timespec = ksched->rr_interval; - return 0; + *timespec = ksched->rr_interval; + return (0); } Modified: stable/10/sys/sys/posix4.h ============================================================================== --- stable/10/sys/sys/posix4.h Sun Sep 6 16:17:14 2015 (r287506) +++ stable/10/sys/sys/posix4.h Sun Sep 6 17:32:33 2015 (r287507) @@ -56,9 +56,6 @@ int sys_ ## SC (struct thread *td, struc MALLOC_DECLARE(M_P31B); -#define p31b_malloc(SIZE) malloc((SIZE), M_P31B, M_WAITOK) -#define p31b_free(P) free((P), M_P31B) - int p31b_proc(struct proc *, pid_t, struct proc **); void p31b_setcfg(int, int);