Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 1 Aug 2014 15:08:48 +0000 (UTC)
From:      Don Lewis <truckman@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r269384 - in stable/9: share/man/man9 sys/kern sys/sys
Message-ID:  <201408011508.s71F8ms2039608@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: truckman
Date: Fri Aug  1 15:08:47 2014
New Revision: 269384
URL: http://svnweb.freebsd.org/changeset/base/269384

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/9/share/man/man9/rman.9
  stable/9/sys/kern/subr_rman.c
  stable/9/sys/sys/rman.h
Directory Properties:
  stable/9/share/man/man9/   (props changed)
  stable/9/sys/   (props changed)
  stable/9/sys/sys/   (props changed)

Modified: stable/9/share/man/man9/rman.9
==============================================================================
--- stable/9/share/man/man9/rman.9	Fri Aug  1 15:04:46 2014	(r269383)
+++ stable/9/share/man/man9/rman.9	Fri Aug  1 15:08:47 2014	(r269384)
@@ -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/9/sys/kern/subr_rman.c
==============================================================================
--- stable/9/sys/kern/subr_rman.c	Fri Aug  1 15:04:46 2014	(r269383)
+++ stable/9/sys/kern/subr_rman.c	Fri Aug  1 15:08:47 2014	(r269384)
@@ -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 *
@@ -317,7 +314,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);
 
 	/*
@@ -430,7 +427,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,
@@ -447,10 +444,9 @@ rman_reserve_resource_bound(struct rman 
 	       "length %#lx, flags %u, device %s\n", rm->rm_descr, start, end,
 	       count, flags,
 	       dev == NULL ? "<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);
 
@@ -596,7 +592,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)) {
@@ -631,25 +627,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);
 }
@@ -663,91 +645,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;
 }
 
@@ -758,7 +666,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;
 }
@@ -769,7 +677,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/9/sys/sys/rman.h
==============================================================================
--- stable/9/sys/sys/rman.h	Fri Aug  1 15:04:46 2014	(r269383)
+++ stable/9/sys/sys/rman.h	Fri Aug  1 15:08:47 2014	(r269384)
@@ -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() */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201408011508.s71F8ms2039608>