Matt Dillon <[EMAIL PROTECTED]> writes:
> We can't just go do an end-run around the established API as a
> hack around the problem.
I fail too se how my suggestion would change the API at all, but in
case I was unclear, diffs are below.
/assar
Index: vm_zone.c
===================================================================
RCS file: /home/ncvs/src/sys/vm/vm_zone.c,v
retrieving revision 1.35
diff -u -w -r1.35 vm_zone.c
--- vm_zone.c 2000/12/13 10:01:00 1.35
+++ vm_zone.c 2000/12/27 00:13:44
@@ -32,6 +32,81 @@
static MALLOC_DEFINE(M_ZONE, "ZONE", "Zone header");
+#include <machine/lock.h>
+
+struct vm_zone {
+ struct simplelock zlock; /* lock for data structure */
+ void *zitems; /* linked list of items */
+ int zfreecnt; /* free entries */
+ int zfreemin; /* minimum number of free entries */
+ int znalloc; /* number of allocations */
+ vm_offset_t zkva; /* Base kva of zone */
+ int zpagecount; /* Total # of allocated pages */
+ int zpagemax; /* Max address space */
+ int zmax; /* Max number of entries allocated */
+ int ztotal; /* Total entries allocated now */
+ int zsize; /* size of each entry */
+ int zalloc; /* hint for # of pages to alloc */
+ int zflags; /* flags for zone */
+ int zallocflag; /* flag for allocation */
+ struct vm_object *zobj; /* object to hold zone */
+ char *zname; /* name for diags */
+ struct vm_zone *znext; /* list of zones for sysctl */
+};
+
+#define ZONE_ERROR_INVALID 0
+#define ZONE_ERROR_NOTFREE 1
+#define ZONE_ERROR_ALREADYFREE 2
+
+#define ZONE_ROUNDING 32
+
+#define ZENTRY_FREE 0x12342378
+/*
+ * void *zalloc(vm_zone_t zone) --
+ * Returns an item from a specified zone.
+ *
+ * void zfree(vm_zone_t zone, void *item) --
+ * Frees an item back to a specified zone.
+ */
+static __inline__ void *
+_zalloc(vm_zone_t z)
+{
+ void *item;
+
+#ifdef INVARIANTS
+ if (z == 0)
+ zerror(ZONE_ERROR_INVALID);
+#endif
+
+ if (z->zfreecnt <= z->zfreemin)
+ return _zget(z);
+
+ item = z->zitems;
+ z->zitems = ((void **) item)[0];
+#ifdef INVARIANTS
+ if (((void **) item)[1] != (void *) ZENTRY_FREE)
+ zerror(ZONE_ERROR_NOTFREE);
+ ((void **) item)[1] = 0;
+#endif
+
+ z->zfreecnt--;
+ z->znalloc++;
+ return item;
+}
+
+static __inline__ void
+_zfree(vm_zone_t z, void *item)
+{
+ ((void **) item)[0] = z->zitems;
+#ifdef INVARIANTS
+ if (((void **) item)[1] == (void *) ZENTRY_FREE)
+ zerror(ZONE_ERROR_ALREADYFREE);
+ ((void **) item)[1] = (void *) ZENTRY_FREE;
+#endif
+ z->zitems = item;
+ z->zfreecnt++;
+}
+
/*
* This file comprises a very simple zone allocator. This is used
* in lieu of the malloc allocator, where needed or more optimal.
Index: vm_zone.h
===================================================================
RCS file: /home/ncvs/src/sys/vm/vm_zone.h,v
retrieving revision 1.13
diff -u -w -r1.13 vm_zone.h
--- vm_zone.h 1999/08/28 00:52:44 1.13
+++ vm_zone.h 2000/12/27 00:13:44
@@ -21,29 +21,9 @@
#define ZONE_INTERRUPT 1 /* Use this if you need to allocate at int time */
#define ZONE_BOOT 16 /* This is an internal flag used by zbootinit */
-#include <machine/lock.h>
+struct vm_zone;
+typedef struct vm_zone *vm_zone_t;
-typedef struct vm_zone {
- struct simplelock zlock; /* lock for data structure */
- void *zitems; /* linked list of items */
- int zfreecnt; /* free entries */
- int zfreemin; /* minimum number of free entries */
- int znalloc; /* number of allocations */
- vm_offset_t zkva; /* Base kva of zone */
- int zpagecount; /* Total # of allocated pages */
- int zpagemax; /* Max address space */
- int zmax; /* Max number of entries allocated */
- int ztotal; /* Total entries allocated now */
- int zsize; /* size of each entry */
- int zalloc; /* hint for # of pages to alloc */
- int zflags; /* flags for zone */
- int zallocflag; /* flag for allocation */
- struct vm_object *zobj; /* object to hold zone */
- char *zname; /* name for diags */
- struct vm_zone *znext; /* list of zones for sysctl */
-} *vm_zone_t;
-
-
void zerror __P((int)) __dead2;
vm_zone_t zinit __P((char *name, int size, int nentries, int flags,
int zalloc));
@@ -57,77 +37,16 @@
int nitems));
void * _zget __P((vm_zone_t z));
-#define ZONE_ERROR_INVALID 0
-#define ZONE_ERROR_NOTFREE 1
-#define ZONE_ERROR_ALREADYFREE 2
-
-#define ZONE_ROUNDING 32
-
-#define ZENTRY_FREE 0x12342378
-/*
- * void *zalloc(vm_zone_t zone) --
- * Returns an item from a specified zone.
- *
- * void zfree(vm_zone_t zone, void *item) --
- * Frees an item back to a specified zone.
- */
-static __inline__ void *
-_zalloc(vm_zone_t z)
-{
- void *item;
-
-#ifdef INVARIANTS
- if (z == 0)
- zerror(ZONE_ERROR_INVALID);
-#endif
-
- if (z->zfreecnt <= z->zfreemin)
- return _zget(z);
-
- item = z->zitems;
- z->zitems = ((void **) item)[0];
-#ifdef INVARIANTS
- if (((void **) item)[1] != (void *) ZENTRY_FREE)
- zerror(ZONE_ERROR_NOTFREE);
- ((void **) item)[1] = 0;
-#endif
-
- z->zfreecnt--;
- z->znalloc++;
- return item;
-}
-
-static __inline__ void
-_zfree(vm_zone_t z, void *item)
-{
- ((void **) item)[0] = z->zitems;
-#ifdef INVARIANTS
- if (((void **) item)[1] == (void *) ZENTRY_FREE)
- zerror(ZONE_ERROR_ALREADYFREE);
- ((void **) item)[1] = (void *) ZENTRY_FREE;
-#endif
- z->zitems = item;
- z->zfreecnt++;
-}
-
static __inline__ void *
zalloc(vm_zone_t z)
{
-#if defined(SMP)
return zalloci(z);
-#else
- return _zalloc(z);
-#endif
}
static __inline__ void
zfree(vm_zone_t z, void *item)
{
-#ifdef SMP
zfreei(z, item);
-#else
- _zfree(z, item);
-#endif
}
-#endif
+#endif /* _SYS_ZONE_H */