PERFORCE change 33659 for review

Peter Wemm peter at FreeBSD.org
Wed Jun 25 14:22:55 PDT 2003


http://perforce.freebsd.org/chv.cgi?CH=33659

Change 33659 by peter at peter_daintree on 2003/06/25 14:21:53

	IFC @33657

Affected files ...

.. //depot/projects/hammer/include/Makefile#12 integrate
.. //depot/projects/hammer/sys/kern/kern_ntptime.c#5 integrate
.. //depot/projects/hammer/sys/netgraph/ng_tee.c#3 integrate
.. //depot/projects/hammer/sys/vm/uma_core.c#13 integrate
.. //depot/projects/hammer/sys/vm/uma_int.h#5 integrate

Differences ...

==== //depot/projects/hammer/include/Makefile#12 (text+ko) ====

@@ -1,5 +1,5 @@
 #	@(#)Makefile	8.2 (Berkeley) 1/4/94
-# $FreeBSD: src/include/Makefile,v 1.201 2003/06/25 14:59:17 sam Exp $
+# $FreeBSD: src/include/Makefile,v 1.202 2003/06/25 19:39:03 sam Exp $
 #
 # Doing a "make install" builds /usr/include.
 
@@ -27,8 +27,8 @@
 LHDRS=	aio.h errno.h fcntl.h linker_set.h poll.h stdint.h syslog.h \
 	termios.h ucontext.h
 
-LDIRS=	cam geom net net80211 netatalk netatm netgraph netinet netinet6 \
-	netipsec netipx netkey netnatm netncp netsmb nfs nfsclient nfsserver \
+LDIRS=	cam geom net netatalk netatm netgraph netinet netinet6 netipsec \
+	netipx netkey netnatm netncp netsmb nfs nfsclient nfsserver \
 	pccard posix4 sys vm
 
 LSUBDIRS=	cam/scsi dev/an dev/ic dev/iicbus dev/firewire dev/ofw \

==== //depot/projects/hammer/sys/kern/kern_ntptime.c#5 (text+ko) ====

@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_ntptime.c,v 1.51 2003/06/11 00:56:56 obrien Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_ntptime.c,v 1.52 2003/06/25 20:56:40 imp Exp $");
 
 #include "opt_ntp.h"
 
@@ -480,6 +480,7 @@
 		else if ((*newsec) % 86400 == 0) {
 			(*newsec)--;
 			time_state = TIME_OOP;
+			time_tai++;
 		}
 		break;
 
@@ -500,7 +501,6 @@
 		 * Insert second in progress.
 		 */
 		case TIME_OOP:
-			time_tai++;
 			time_state = TIME_WAIT;
 		break;
 

==== //depot/projects/hammer/sys/netgraph/ng_tee.c#3 (text+ko) ====

@@ -36,7 +36,7 @@
  *
  * Author: Julian Elischer <julian at freebsd.org>
  *
- * $FreeBSD: src/sys/netgraph/ng_tee.c,v 1.23 2003/02/19 05:47:32 imp Exp $
+ * $FreeBSD: src/sys/netgraph/ng_tee.c,v 1.24 2003/06/25 20:58:35 julian Exp $
  * $Whistle: ng_tee.c,v 1.18 1999/11/01 09:24:52 julian Exp $
  */
 
@@ -46,7 +46,7 @@
  * entering from the right is passed to the left and duplicated on
  * right2left, and data entering from the left is passed to the right
  * and duplicated on left2right. Data entering from left2right is
- * sent to right, and data from right2left to left.
+ * sent to left, and data from right2left to right.
  */
 
 #include <sys/param.h>

==== //depot/projects/hammer/sys/vm/uma_core.c#13 (text+ko) ====

@@ -46,7 +46,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/vm/uma_core.c,v 1.59 2003/06/25 17:25:45 bmilekic Exp $");
+__FBSDID("$FreeBSD: src/sys/vm/uma_core.c,v 1.60 2003/06/25 20:49:48 bmilekic Exp $");
 
 /* I should really use ktr.. */
 /*
@@ -115,6 +115,9 @@
 /* This mutex protects the zone list */
 static struct mtx uma_mtx;
 
+/* These are the pcpu cache locks */
+static struct mtx uma_pcpu_mtx[MAXCPU];
+
 /* Linked list of boot time pages */
 static LIST_HEAD(,uma_slab) uma_boot_pages =
     LIST_HEAD_INITIALIZER(&uma_boot_pages);
@@ -249,7 +252,7 @@
 		for (cpu = 0; cpu < maxcpu; cpu++) {
 			if (CPU_ABSENT(cpu))
 				continue;
-			CPU_LOCK(zone, cpu); 
+			CPU_LOCK(cpu); 
 			cache = &zone->uz_cpu[cpu];
 			/* Add them up, and reset */
 			alloc += cache->uc_allocs;
@@ -258,7 +261,7 @@
 				free += cache->uc_allocbucket->ub_ptr + 1;
 			if (cache->uc_freebucket)
 				free += cache->uc_freebucket->ub_ptr + 1;
-			CPU_UNLOCK(zone, cpu);
+			CPU_UNLOCK(cpu);
 		}
 	}
 
@@ -514,7 +517,7 @@
 	for (cpu = 0; cpu < maxcpu; cpu++) {
 		if (CPU_ABSENT(cpu))
 			continue;
-		CPU_LOCK(zone, cpu);
+		CPU_LOCK(cpu);
 		cache = &zone->uz_cpu[cpu];
 		bucket_drain(zone, cache->uc_allocbucket);
 		bucket_drain(zone, cache->uc_freebucket);
@@ -543,7 +546,7 @@
 	for (cpu = 0; cpu < maxcpu; cpu++) {
 		if (CPU_ABSENT(cpu))
 			continue;
-		CPU_UNLOCK(zone, cpu);
+		CPU_UNLOCK(cpu);
 	}
 
 	zone->uz_cachefree = 0;
@@ -985,8 +988,6 @@
 	struct uma_zctor_args *arg = udata;
 	uma_zone_t zone = mem;
 	int privlc;
-	int cplen;
-	int cpu;
 
 	bzero(zone, size);
 	zone->uz_name = arg->name;
@@ -1033,12 +1034,6 @@
 	else
 		privlc = 0;
 
-	/* We do this so that the per cpu lock name is unique for each zone */
-	memcpy(zone->uz_lname, "PCPU ", 5);
-	cplen = min(strlen(zone->uz_name) + 1, LOCKNAME_LEN - 6);
-	memcpy(zone->uz_lname+5, zone->uz_name, cplen);
-	zone->uz_lname[LOCKNAME_LEN - 1] = '\0';
-
 	/*
 	 * If we're putting the slab header in the actual page we need to
 	 * figure out where in each page it goes.  This calculates a right 
@@ -1107,9 +1102,6 @@
 		zone->uz_count = zone->uz_ipers - 1;
 	else
 		zone->uz_count = UMA_BUCKET_SIZE - 1;
-
-	for (cpu = 0; cpu < maxcpu; cpu++)
-		CPU_LOCK_INIT(zone, cpu, privlc);
 }
 
 /* 
@@ -1124,10 +1116,8 @@
 zone_dtor(void *arg, int size, void *udata)
 {
 	uma_zone_t zone;
-	int cpu;
 
 	zone = (uma_zone_t)arg;
-
 	ZONE_LOCK(zone);
 	zone->uz_wssize = 0;
 	ZONE_UNLOCK(zone);
@@ -1142,10 +1132,6 @@
 		printf("Zone %s was not empty (%d items).  Lost %d pages of memory.\n",
 		    zone->uz_name, zone->uz_free, zone->uz_pages);
 
-	if ((zone->uz_flags & UMA_ZFLAG_INTERNAL) == 0)
-		for (cpu = 0; cpu < maxcpu; cpu++)
-			CPU_LOCK_FINI(zone, cpu);
-
 	ZONE_UNLOCK(zone);
 	if ((zone->uz_flags & UMA_ZFLAG_OFFPAGE) != 0)
 		hash_free(&zone->uz_hash);
@@ -1210,6 +1196,10 @@
 	/* The initial zone has no Per cpu queues so it's smaller */
 	zone_ctor(zones, sizeof(struct uma_zone), &args);
 
+	/* Initialize the pcpu cache lock set once and for all */
+	for (i = 0; i < maxcpu; i++)
+		CPU_LOCK_INIT(i);
+
 #ifdef UMA_DEBUG
 	printf("Filling boot free list.\n");
 #endif
@@ -1339,7 +1329,7 @@
 
 zalloc_restart:
 	cpu = PCPU_GET(cpuid);
-	CPU_LOCK(zone, cpu);
+	CPU_LOCK(cpu);
 	cache = &zone->uz_cpu[cpu];
 
 zalloc_start:
@@ -1360,7 +1350,7 @@
 			uma_dbg_alloc(zone, NULL, item);
 			ZONE_UNLOCK(zone);
 #endif
-			CPU_UNLOCK(zone, cpu);
+			CPU_UNLOCK(cpu);
 			if (zone->uz_ctor)
 				zone->uz_ctor(item, zone->uz_size, udata);
 			if (flags & M_ZERO)
@@ -1410,7 +1400,7 @@
 		goto zalloc_start;
 	} 
 	/* We are no longer associated with this cpu!!! */
-	CPU_UNLOCK(zone, cpu);
+	CPU_UNLOCK(cpu);
 
 	/* Bump up our uz_count so we get here less */
 	if (zone->uz_count < UMA_BUCKET_SIZE - 1)
@@ -1655,7 +1645,7 @@
 
 	ZONE_UNLOCK(zone);
 
-	if (zone->uz_ctor != NULL) 
+	if (zone->uz_ctor != NULL)
 		zone->uz_ctor(item, zone->uz_size, udata);
 	if (flags & M_ZERO)
 		bzero(item, zone->uz_size);
@@ -1693,7 +1683,7 @@
 
 zfree_restart:
 	cpu = PCPU_GET(cpuid);
-	CPU_LOCK(zone, cpu);
+	CPU_LOCK(cpu);
 	cache = &zone->uz_cpu[cpu];
 
 zfree_start:
@@ -1718,7 +1708,7 @@
 				uma_dbg_free(zone, NULL, item);
 			ZONE_UNLOCK(zone);
 #endif
-			CPU_UNLOCK(zone, cpu);
+			CPU_UNLOCK(cpu);
 			return;
 		} else if (cache->uc_allocbucket) {
 #ifdef UMA_DEBUG_ALLOC
@@ -1772,7 +1762,7 @@
 		goto zfree_start;
 	}
 	/* We're done with this CPU now */
-	CPU_UNLOCK(zone, cpu);
+	CPU_UNLOCK(cpu);
 
 	/* And the zone.. */
 	ZONE_UNLOCK(zone);

==== //depot/projects/hammer/sys/vm/uma_int.h#5 (text+ko) ====

@@ -23,7 +23,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/vm/uma_int.h,v 1.14 2003/05/31 19:52:15 phk Exp $
+ * $FreeBSD: src/sys/vm/uma_int.h,v 1.15 2003/06/25 20:49:48 bmilekic Exp $
  *
  */
 
@@ -190,7 +190,6 @@
 typedef struct uma_bucket * uma_bucket_t;
 
 struct uma_cache {
-	struct mtx	uc_lock;	/* Spin lock on this cpu's bucket */
 	uma_bucket_t	uc_freebucket;	/* Bucket we're freeing to */
 	uma_bucket_t	uc_allocbucket;	/* Bucket to allocate from */
 	u_int64_t	uc_allocs;	/* Count of allocations */
@@ -198,8 +197,6 @@
 
 typedef struct uma_cache * uma_cache_t;
 
-#define LOCKNAME_LEN	16		/* Length of the name for cpu locks */
-
 /*
  * Zone management structure 
  *
@@ -207,7 +204,6 @@
  *
  */
 struct uma_zone {
-	char		uz_lname[LOCKNAME_LEN];	/* Text name for the cpu lock */
 	char		*uz_name;	/* Text name of the zone */
 	LIST_ENTRY(uma_zone)	uz_link;	/* List of all zones */
 	u_int32_t	uz_align;	/* Alignment mask */
@@ -292,26 +288,15 @@
 #define	ZONE_LOCK(z)	mtx_lock(&(z)->uz_lock)
 #define ZONE_UNLOCK(z)	mtx_unlock(&(z)->uz_lock)
 
-#define	CPU_LOCK_INIT(z, cpu, lc)				\
-	do {							\
-		if ((lc))					\
-			mtx_init(&(z)->uz_cpu[(cpu)].uc_lock,	\
-			    (z)->uz_lname, (z)->uz_lname,	\
-			    MTX_DEF | MTX_DUPOK);		\
-		else						\
-			mtx_init(&(z)->uz_cpu[(cpu)].uc_lock,	\
-			    (z)->uz_lname, "UMA cpu",		\
-			    MTX_DEF | MTX_DUPOK);		\
-	} while (0)
+#define	CPU_LOCK_INIT(cpu)					\
+	mtx_init(&uma_pcpu_mtx[(cpu)], "UMA pcpu", "UMA pcpu",	\
+	    MTX_DEF | MTX_DUPOK)
 
-#define	CPU_LOCK_FINI(z, cpu)	\
-	mtx_destroy(&(z)->uz_cpu[(cpu)].uc_lock)
+#define CPU_LOCK(cpu)						\
+	mtx_lock(&uma_pcpu_mtx[(cpu)])
 
-#define CPU_LOCK(z, cpu)	\
-	mtx_lock(&(z)->uz_cpu[(cpu)].uc_lock)
-
-#define CPU_UNLOCK(z, cpu)	\
-	mtx_unlock(&(z)->uz_cpu[(cpu)].uc_lock)
+#define CPU_UNLOCK(cpu)						\
+	mtx_unlock(&uma_pcpu_mtx[(cpu)])
 
 /*
  * Find a slab within a hash table.  This is used for OFFPAGE zones to lookup


More information about the p4-projects mailing list