PERFORCE change 119919 for review
John Baldwin
jhb at FreeBSD.org
Wed May 16 17:27:46 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=119919
Change 119919 by jhb at jhb_mutex on 2007/05/16 17:27:39
Retire uz_lock and just use uz_keg->uk_lock, it's still a single
pointer deref but makes 'uma_zone' smaller. Also, cleanup the
macros to init/teardown some for the locking being a keg lock
rather than a zone lock.
Affected files ...
.. //depot/projects/smpng/sys/vm/uma_core.c#70 edit
.. //depot/projects/smpng/sys/vm/uma_int.h#31 edit
Differences ...
==== //depot/projects/smpng/sys/vm/uma_core.c#70 (text+ko) ====
@@ -1247,14 +1247,9 @@
}
/*
- * Initialize keg's lock (shared among zones) through
- * Master zone
+ * Initialize keg's lock (shared among zones).
*/
- zone->uz_lock = &keg->uk_lock;
- if (arg->flags & UMA_ZONE_MTXCLASS)
- ZONE_LOCK_INIT(zone, 1);
- else
- ZONE_LOCK_INIT(zone, 0);
+ KEG_LOCK_INIT(keg, zone->uz_name, arg->flags & UMA_ZONE_MTXCLASS);
/*
* If we're putting the slab header in the actual page we need to
@@ -1349,7 +1344,6 @@
zone->uz_keg = keg;
zone->uz_init = arg->uminit;
zone->uz_fini = arg->fini;
- zone->uz_lock = &keg->uk_lock;
mtx_lock(&uma_mtx);
ZONE_LOCK(zone);
keg->uk_flags |= UMA_ZONE_SECONDARY;
@@ -1382,7 +1376,6 @@
return (error);
}
keg = zone->uz_keg;
- zone->uz_lock = &keg->uk_lock;
/*
* Some internal zones don't have room allocated for the per cpu
@@ -1416,18 +1409,18 @@
uma_keg_t keg;
keg = (uma_keg_t)arg;
- mtx_lock(&keg->uk_lock);
+ KEG_LOCK(keg);
if (keg->uk_free != 0) {
printf("Freed UMA keg was not empty (%d items). "
" Lost %d pages of memory.\n",
keg->uk_free, keg->uk_pages);
}
- mtx_unlock(&keg->uk_lock);
+ KEG_UNLOCK(keg);
if (keg->uk_flags & UMA_ZONE_HASH)
hash_free(&keg->uk_hash);
- mtx_destroy(&keg->uk_lock);
+ KEG_LOCK_FINI(keg);
}
/*
==== //depot/projects/smpng/sys/vm/uma_int.h#31 (text+ko) ====
@@ -331,19 +331,21 @@
/* Lock Macros */
-#define ZONE_LOCK_INIT(z, lc) \
+#define KEG_LOCK_INIT(k, name, lc) \
do { \
if ((lc)) \
- mtx_init((z)->uz_lock, (z)->uz_name, \
- (z)->uz_name, MTX_DEF | MTX_DUPOK); \
+ mtx_init(&(k)->uk_lock, (name), \
+ NULL, MTX_DEF | MTX_DUPOK); \
else \
- mtx_init((z)->uz_lock, (z)->uz_name, \
+ mtx_init(&(k)->uk_lock, (name), \
"UMA zone", MTX_DEF | MTX_DUPOK); \
} while (0)
-
-#define ZONE_LOCK_FINI(z) mtx_destroy((z)->uz_lock)
-#define ZONE_LOCK(z) mtx_lock((z)->uz_lock)
-#define ZONE_UNLOCK(z) mtx_unlock((z)->uz_lock)
+#define KEG_LOCK_FINI(k) mtx_destroy(&(k)->uk_lock)
+#define KEG_LOCK(k) mtx_lock(&(k)->uk_lock)
+#define KEG_UNLOCK(k) mtx_unlock(&(k)->uk_lock)
+
+#define ZONE_LOCK(z) mtx_lock(&(z)->uz_keg->uk_lock)
+#define ZONE_UNLOCK(z) mtx_unlock(&(z)->uz_keg->uk_lock)
/*
* Find a slab within a hash table. This is used for OFFPAGE zones to lookup
More information about the p4-projects
mailing list