From owner-svn-src-head@freebsd.org Sun Aug 30 17:58:13 2015 Return-Path: Delivered-To: svn-src-head@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 F2D7D9C6E23; Sun, 30 Aug 2015 17:58:12 +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 D96E0BEF; Sun, 30 Aug 2015 17:58:12 +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 t7UHwCeO065129; Sun, 30 Aug 2015 17:58:12 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7UHwCIK065126; Sun, 30 Aug 2015 17:58:12 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201508301758.t7UHwCIK065126@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 30 Aug 2015 17:58:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r287309 - in head/sys: 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, 30 Aug 2015 17:58:13 -0000 Author: kib Date: Sun Aug 30 17:58:11 2015 New Revision: 287309 URL: https://svnweb.freebsd.org/changeset/base/287309 Log: Remove single-use macros obfuscating malloc(9) and free(9) calls. Style. Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/sys/kern/ksched.c head/sys/sys/posix4.h Modified: head/sys/kern/ksched.c ============================================================================== --- head/sys/kern/ksched.c Sun Aug 30 17:24:22 2015 (r287308) +++ head/sys/kern/ksched.c Sun Aug 30 17:58:11 2015 (r287309) @@ -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: head/sys/sys/posix4.h ============================================================================== --- head/sys/sys/posix4.h Sun Aug 30 17:24:22 2015 (r287308) +++ head/sys/sys/posix4.h Sun Aug 30 17:58:11 2015 (r287309) @@ -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);