From owner-svn-src-all@FreeBSD.ORG Fri Aug 1 15:04:47 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B0964C69; Fri, 1 Aug 2014 15:04:47 +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 912852B66; Fri, 1 Aug 2014 15:04:47 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s71F4l5r038580; Fri, 1 Aug 2014 15:04:47 GMT (envelope-from truckman@svn.freebsd.org) Received: (from truckman@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s71F4k7u038574; Fri, 1 Aug 2014 15:04:46 GMT (envelope-from truckman@svn.freebsd.org) Message-Id: <201408011504.s71F4k7u038574@svn.freebsd.org> From: Don Lewis Date: Fri, 1 Aug 2014 15:04:46 +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: r269383 - in stable/10: share/man/man9 sys/kern sys/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.18 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: Fri, 01 Aug 2014 15:04:47 -0000 Author: truckman Date: Fri Aug 1 15:04:46 2014 New Revision: 269383 URL: http://svnweb.freebsd.org/changeset/base/269383 Log: MFC r268780 Nuke the never-used RF_TIMESHARE feature, reducing the complexity of the code. The consensus on arch@ is that this feature might have been useful in the distant past, but is now just unnecessary bloat. The int_rman_activate_resource() and int_rman_deactivate_resource() functions become trivial, so manually inline them. The special deferred handling of RF_ACTIVE is no longer needed in reserve_resource_bound(), so eliminate the associated code at the end of the function. These changes reduce the object file size by more than 500 bytes on i386. Update the rman.9 man page to reflect the removal of the RF_TIMESHARE feature. Modified: stable/10/share/man/man9/rman.9 stable/10/sys/kern/subr_rman.c stable/10/sys/sys/rman.h Directory Properties: stable/10/ (props changed) Modified: stable/10/share/man/man9/rman.9 ============================================================================== --- stable/10/share/man/man9/rman.9 Fri Aug 1 14:10:10 2014 (r269382) +++ stable/10/share/man/man9/rman.9 Fri Aug 1 15:04:46 2014 (r269383) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 29, 2011 +.Dd July 15, 2014 .Dt RMAN 9 .Os .Sh NAME @@ -141,13 +141,11 @@ represented by a 16-bit flag register, a #define RF_ALLOCATED 0x0001 /* resource has been reserved */ #define RF_ACTIVE 0x0002 /* resource allocation has been activated */ #define RF_SHAREABLE 0x0004 /* resource permits contemporaneous sharing */ -#define RF_TIMESHARE 0x0008 /* resource permits time-division sharing */ -#define RF_WANTED 0x0010 /* somebody is waiting for this resource */ #define RF_FIRSTSHARE 0x0020 /* first in sharing list */ #define RF_PREFETCHABLE 0x0040 /* resource is prefetchable */ .Ed .Pp -The remainder of the flag bits are used to represent the desired alignment +Bits 15:10 of the flag register are used to represent the desired alignment of the resource within the region. .Pp The @@ -299,12 +297,9 @@ The .Fa bound argument must be a power of two. It may be set to zero to specify no boundary restriction. -The default behavior is to allocate an exclusive segment, unless the +A shared segment will be allocated if the .Dv RF_SHAREABLE -or -.Dv RF_TIMESHARE -flags are set, in which case a shared -segment will be allocated. +flag is set, otherwise an exclusive segment will be allocated. If this shared segment already exists, the caller has its device added to the list of consumers. .Pp Modified: stable/10/sys/kern/subr_rman.c ============================================================================== --- stable/10/sys/kern/subr_rman.c Fri Aug 1 14:10:10 2014 (r269382) +++ stable/10/sys/kern/subr_rman.c Fri Aug 1 15:04:46 2014 (r269383) @@ -110,9 +110,6 @@ static MALLOC_DEFINE(M_RMAN, "rman", "Re struct rman_head rman_head; static struct mtx rman_mtx; /* mutex to protect rman_head */ -static int int_rman_activate_resource(struct rman *rm, struct resource_i *r, - struct resource_i **whohas); -static int int_rman_deactivate_resource(struct resource_i *r); static int int_rman_release_resource(struct rman *rm, struct resource_i *r); static __inline struct resource_i * @@ -322,7 +319,7 @@ rman_adjust_resource(struct resource *rr /* Not supported for shared resources. */ r = rr->__r_i; - if (r->r_flags & (RF_TIMESHARE | RF_SHAREABLE)) + if (r->r_flags & RF_SHAREABLE) return (EINVAL); /* @@ -435,7 +432,7 @@ rman_adjust_resource(struct resource *rr return (0); } -#define SHARE_TYPE(f) (f & (RF_SHAREABLE | RF_TIMESHARE | RF_PREFETCHABLE)) +#define SHARE_TYPE(f) (f & (RF_SHAREABLE | RF_PREFETCHABLE)) struct resource * rman_reserve_resource_bound(struct rman *rm, u_long start, u_long end, @@ -452,10 +449,9 @@ rman_reserve_resource_bound(struct rman "length %#lx, flags %u, device %s\n", rm->rm_descr, start, end, count, flags, dev == NULL ? "" : device_get_nameunit(dev))); - KASSERT((flags & (RF_WANTED | RF_FIRSTSHARE)) == 0, + KASSERT((flags & RF_FIRSTSHARE) == 0, ("invalid flags %#x", flags)); - new_rflags = (flags & ~(RF_ACTIVE | RF_WANTED | RF_FIRSTSHARE)) | - RF_ALLOCATED; + new_rflags = (flags & ~RF_FIRSTSHARE) | RF_ALLOCATED; mtx_lock(rm->rm_mtx); @@ -601,7 +597,7 @@ rman_reserve_resource_bound(struct rman * additional work, but this does not seem warranted.) */ DPRINTF(("no unshared regions found\n")); - if ((flags & (RF_SHAREABLE | RF_TIMESHARE)) == 0) + if ((flags & RF_SHAREABLE) == 0) goto out; for (s = r; s && s->r_end <= end; s = TAILQ_NEXT(s, r_link)) { @@ -636,25 +632,11 @@ rman_reserve_resource_bound(struct rman goto out; } } - /* * We couldn't find anything. */ -out: - /* - * If the user specified RF_ACTIVE in flags, we attempt to atomically - * activate the resource. If this fails, we release the resource - * and indicate overall failure. (This behavior probably doesn't - * make sense for RF_TIMESHARE-type resources.) - */ - if (rv && (flags & RF_ACTIVE) != 0) { - struct resource_i *whohas; - if (int_rman_activate_resource(rm, rv, &whohas)) { - int_rman_release_resource(rm, rv); - rv = NULL; - } - } +out: mtx_unlock(rm->rm_mtx); return (rv == NULL ? NULL : &rv->r_r); } @@ -668,91 +650,17 @@ rman_reserve_resource(struct rman *rm, u dev)); } -static int -int_rman_activate_resource(struct rman *rm, struct resource_i *r, - struct resource_i **whohas) -{ - struct resource_i *s; - int ok; - - /* - * If we are not timesharing, then there is nothing much to do. - * If we already have the resource, then there is nothing at all to do. - * If we are not on a sharing list with anybody else, then there is - * little to do. - */ - if ((r->r_flags & RF_TIMESHARE) == 0 - || (r->r_flags & RF_ACTIVE) != 0 - || r->r_sharehead == NULL) { - r->r_flags |= RF_ACTIVE; - return 0; - } - - ok = 1; - for (s = LIST_FIRST(r->r_sharehead); s && ok; - s = LIST_NEXT(s, r_sharelink)) { - if ((s->r_flags & RF_ACTIVE) != 0) { - ok = 0; - *whohas = s; - } - } - if (ok) { - r->r_flags |= RF_ACTIVE; - return 0; - } - return EBUSY; -} - int rman_activate_resource(struct resource *re) { - int rv; - struct resource_i *r, *whohas; + struct resource_i *r; struct rman *rm; r = re->__r_i; rm = r->r_rm; mtx_lock(rm->rm_mtx); - rv = int_rman_activate_resource(rm, r, &whohas); + r->r_flags |= RF_ACTIVE; mtx_unlock(rm->rm_mtx); - return rv; -} - -int -rman_await_resource(struct resource *re, int pri, int timo) -{ - int rv; - struct resource_i *r, *whohas; - struct rman *rm; - - r = re->__r_i; - rm = r->r_rm; - mtx_lock(rm->rm_mtx); - for (;;) { - rv = int_rman_activate_resource(rm, r, &whohas); - if (rv != EBUSY) - return (rv); /* returns with mutex held */ - - if (r->r_sharehead == NULL) - panic("rman_await_resource"); - whohas->r_flags |= RF_WANTED; - rv = msleep(r->r_sharehead, rm->rm_mtx, pri, "rmwait", timo); - if (rv) { - mtx_unlock(rm->rm_mtx); - return (rv); - } - } -} - -static int -int_rman_deactivate_resource(struct resource_i *r) -{ - - r->r_flags &= ~RF_ACTIVE; - if (r->r_flags & RF_WANTED) { - r->r_flags &= ~RF_WANTED; - wakeup(r->r_sharehead); - } return 0; } @@ -763,7 +671,7 @@ rman_deactivate_resource(struct resource rm = r->__r_i->r_rm; mtx_lock(rm->rm_mtx); - int_rman_deactivate_resource(r->__r_i); + r->__r_i->r_flags &= ~RF_ACTIVE; mtx_unlock(rm->rm_mtx); return 0; } @@ -774,7 +682,7 @@ int_rman_release_resource(struct rman *r struct resource_i *s, *t; if (r->r_flags & RF_ACTIVE) - int_rman_deactivate_resource(r); + r->r_flags &= ~RF_ACTIVE; /* * Check for a sharing list first. If there is one, then we don't Modified: stable/10/sys/sys/rman.h ============================================================================== --- stable/10/sys/sys/rman.h Fri Aug 1 14:10:10 2014 (r269382) +++ stable/10/sys/sys/rman.h Fri Aug 1 15:04:46 2014 (r269383) @@ -42,8 +42,8 @@ #define RF_ALLOCATED 0x0001 /* resource has been reserved */ #define RF_ACTIVE 0x0002 /* resource allocation has been activated */ #define RF_SHAREABLE 0x0004 /* resource permits contemporaneous sharing */ -#define RF_TIMESHARE 0x0008 /* resource permits time-division sharing */ -#define RF_WANTED 0x0010 /* somebody is waiting for this resource */ +#define RF_SPARE1 0x0008 +#define RF_SPARE2 0x0010 #define RF_FIRSTSHARE 0x0020 /* first in sharing list */ #define RF_PREFETCHABLE 0x0040 /* resource is prefetchable */ #define RF_OPTIONAL 0x0080 /* for bus_alloc_resources() */