1997-08-05 00:07:31 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1997 John S. Dyson
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
1997-08-05 22:24:31 +00:00
|
|
|
* notice immediately at the beginning of the file, without modification,
|
|
|
|
* this list of conditions, and the following disclaimer.
|
1997-08-05 00:07:31 +00:00
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
1997-08-05 22:24:31 +00:00
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
1997-08-05 00:07:31 +00:00
|
|
|
* 3. Absolutely no warranty of function or purpose is made by the author
|
1997-08-05 22:24:31 +00:00
|
|
|
* John S. Dyson.
|
1997-08-05 00:07:31 +00:00
|
|
|
* 4. This work was done expressly for inclusion into FreeBSD. Other use
|
1997-08-05 22:24:31 +00:00
|
|
|
* is allowed if this notation is included.
|
1997-08-05 00:07:31 +00:00
|
|
|
* 5. Modifications may be freely made to this file if the above conditions
|
1997-08-05 22:24:31 +00:00
|
|
|
* are met.
|
1997-08-05 00:07:31 +00:00
|
|
|
*
|
1997-12-14 05:17:44 +00:00
|
|
|
* $Id: vm_zone.c,v 1.11 1997/12/05 19:55:52 bde Exp $
|
1997-08-05 00:07:31 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
1997-12-05 19:55:52 +00:00
|
|
|
#include <sys/lock.h>
|
1997-08-05 00:07:31 +00:00
|
|
|
#include <sys/malloc.h>
|
1997-08-06 04:58:05 +00:00
|
|
|
#include <sys/sysctl.h>
|
1997-08-05 00:07:31 +00:00
|
|
|
|
|
|
|
#include <vm/vm.h>
|
|
|
|
#include <vm/vm_object.h>
|
|
|
|
#include <vm/vm_prot.h>
|
|
|
|
#include <vm/vm_page.h>
|
|
|
|
#include <vm/vm_kern.h>
|
|
|
|
#include <vm/vm_extern.h>
|
|
|
|
#include <vm/vm_zone.h>
|
|
|
|
|
1997-10-12 20:26:33 +00:00
|
|
|
static MALLOC_DEFINE(M_ZONE, "ZONE", "Zone header");
|
1997-10-11 18:31:40 +00:00
|
|
|
|
1997-08-05 00:07:31 +00:00
|
|
|
/*
|
|
|
|
* This file comprises a very simple zone allocator. This is used
|
|
|
|
* in lieu of the malloc allocator, where needed or more optimal.
|
|
|
|
*
|
|
|
|
* Note that the initial implementation of this had coloring, and
|
|
|
|
* absolutely no improvement (actually perf degradation) occurred.
|
|
|
|
*
|
1997-08-05 22:24:31 +00:00
|
|
|
* zinitna, zinit, zbootinit are the initialization routines.
|
1997-08-05 00:07:31 +00:00
|
|
|
* zalloc, zfree, are the interrupt/lock unsafe allocation/free routines.
|
|
|
|
* zalloci, zfreei, are the interrupt/lock safe allocation/free routines.
|
|
|
|
*/
|
|
|
|
|
1997-08-06 04:58:05 +00:00
|
|
|
struct vm_zone *zlist;
|
|
|
|
int sysctl_vm_zone SYSCTL_HANDLER_ARGS;
|
|
|
|
|
1997-08-05 22:24:31 +00:00
|
|
|
/*
|
|
|
|
* Create a zone, but don't allocate the zone structure. If the
|
|
|
|
* zone had been previously created by the zone boot code, initialize
|
|
|
|
* various parts of the zone code.
|
|
|
|
*
|
|
|
|
* If waits are not allowed during allocation (e.g. during interrupt
|
|
|
|
* code), a-priori allocate the kernel virtual space, and allocate
|
|
|
|
* only pages when needed.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* z pointer to zone structure.
|
|
|
|
* obj pointer to VM object (opt).
|
|
|
|
* name name of zone.
|
|
|
|
* size size of zone entries.
|
|
|
|
* nentries number of zone entries allocated (only ZONE_INTERRUPT.)
|
1997-09-21 11:41:12 +00:00
|
|
|
* flags ZONE_INTERRUPT -- items can be allocated at interrupt time.
|
1997-08-05 22:24:31 +00:00
|
|
|
* zalloc number of pages allocated when memory is needed.
|
|
|
|
*
|
|
|
|
* Note that when using ZONE_INTERRUPT, the size of the zone is limited
|
|
|
|
* by the nentries argument. The size of the memory allocatable is
|
|
|
|
* unlimited if ZONE_INTERRUPT is not set.
|
|
|
|
*
|
|
|
|
*/
|
1997-08-05 00:07:31 +00:00
|
|
|
int
|
1997-08-05 22:24:31 +00:00
|
|
|
zinitna(vm_zone_t z, vm_object_t obj, char *name, int size,
|
1997-09-21 11:41:12 +00:00
|
|
|
int nentries, int flags, int zalloc)
|
|
|
|
{
|
1997-08-05 00:07:31 +00:00
|
|
|
int totsize;
|
|
|
|
|
|
|
|
if ((z->zflags & ZONE_BOOT) == 0) {
|
1997-12-14 05:17:44 +00:00
|
|
|
z->zsize = (size + ZONE_ROUNDING - 1) & ~(ZONE_ROUNDING - 1);
|
1997-08-05 00:07:31 +00:00
|
|
|
simple_lock_init(&z->zlock);
|
|
|
|
z->zfreecnt = 0;
|
1997-08-06 04:58:05 +00:00
|
|
|
z->ztotal = 0;
|
|
|
|
z->zmax = 0;
|
1997-08-05 00:07:31 +00:00
|
|
|
z->zname = name;
|
1997-08-07 03:52:55 +00:00
|
|
|
z->znalloc = 0;
|
1997-09-21 04:24:27 +00:00
|
|
|
z->zitems = NULL;
|
1997-08-06 04:58:05 +00:00
|
|
|
|
|
|
|
if (zlist == 0) {
|
|
|
|
zlist = z;
|
|
|
|
} else {
|
|
|
|
z->znext = zlist;
|
|
|
|
zlist = z;
|
|
|
|
}
|
1997-08-05 00:07:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
z->zflags |= flags;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we cannot wait, allocate KVA space up front, and we will fill
|
|
|
|
* in pages as needed.
|
|
|
|
*/
|
1997-08-05 22:24:31 +00:00
|
|
|
if (z->zflags & ZONE_INTERRUPT) {
|
1997-08-05 00:07:31 +00:00
|
|
|
|
|
|
|
totsize = round_page(z->zsize * nentries);
|
|
|
|
|
|
|
|
z->zkva = kmem_alloc_pageable(kernel_map, totsize);
|
1997-09-21 11:41:12 +00:00
|
|
|
if (z->zkva == 0)
|
1997-08-05 00:07:31 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
z->zpagemax = totsize / PAGE_SIZE;
|
|
|
|
if (obj == NULL) {
|
|
|
|
z->zobj = vm_object_allocate(OBJT_DEFAULT, z->zpagemax);
|
|
|
|
} else {
|
|
|
|
z->zobj = obj;
|
|
|
|
_vm_object_allocate(OBJT_DEFAULT, z->zpagemax, obj);
|
|
|
|
}
|
1997-08-05 22:24:31 +00:00
|
|
|
z->zallocflag = VM_ALLOC_INTERRUPT;
|
1997-08-06 04:58:05 +00:00
|
|
|
z->zmax += nentries;
|
1997-08-05 22:24:31 +00:00
|
|
|
} else {
|
|
|
|
z->zallocflag = VM_ALLOC_SYSTEM;
|
1997-08-06 04:58:05 +00:00
|
|
|
z->zmax = 0;
|
1997-08-05 00:07:31 +00:00
|
|
|
}
|
|
|
|
|
1997-08-06 04:58:05 +00:00
|
|
|
|
1997-09-21 11:41:12 +00:00
|
|
|
if (z->zsize > PAGE_SIZE)
|
1997-08-05 00:07:31 +00:00
|
|
|
z->zfreemin = 1;
|
|
|
|
else
|
|
|
|
z->zfreemin = PAGE_SIZE / z->zsize;
|
|
|
|
|
|
|
|
z->zpagecount = 0;
|
|
|
|
if (zalloc)
|
|
|
|
z->zalloc = zalloc;
|
|
|
|
else
|
|
|
|
z->zalloc = 1;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
1997-08-05 22:24:31 +00:00
|
|
|
/*
|
|
|
|
* Subroutine same as zinitna, except zone data structure is allocated
|
|
|
|
* automatically by malloc. This routine should normally be used, except
|
|
|
|
* in certain tricky startup conditions in the VM system -- then
|
|
|
|
* zbootinit and zinitna can be used. Zinit is the standard zone
|
|
|
|
* initialization call.
|
|
|
|
*/
|
1997-08-05 00:07:31 +00:00
|
|
|
vm_zone_t
|
1997-09-21 11:41:12 +00:00
|
|
|
zinit(char *name, int size, int nentries, int flags, int zalloc)
|
|
|
|
{
|
1997-08-05 00:07:31 +00:00
|
|
|
vm_zone_t z;
|
1997-09-21 11:41:12 +00:00
|
|
|
|
1997-08-05 00:07:31 +00:00
|
|
|
z = (vm_zone_t) malloc(sizeof (struct vm_zone), M_ZONE, M_NOWAIT);
|
|
|
|
if (z == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
1997-08-05 22:24:31 +00:00
|
|
|
z->zflags = 0;
|
|
|
|
if (zinitna(z, NULL, name, size, nentries, flags, zalloc) == 0) {
|
1997-08-05 00:07:31 +00:00
|
|
|
free(z, M_ZONE);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return z;
|
|
|
|
}
|
|
|
|
|
1997-08-05 22:24:31 +00:00
|
|
|
/*
|
|
|
|
* Initialize a zone before the system is fully up. This routine should
|
|
|
|
* only be called before full VM startup.
|
|
|
|
*/
|
1997-08-05 00:07:31 +00:00
|
|
|
void
|
1997-09-21 11:41:12 +00:00
|
|
|
zbootinit(vm_zone_t z, char *name, int size, void *item, int nitems)
|
|
|
|
{
|
1997-08-05 00:07:31 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
z->zname = name;
|
|
|
|
z->zsize = size;
|
|
|
|
z->zpagemax = 0;
|
|
|
|
z->zobj = NULL;
|
|
|
|
z->zflags = ZONE_BOOT;
|
|
|
|
z->zfreemin = 0;
|
|
|
|
z->zallocflag = 0;
|
|
|
|
z->zpagecount = 0;
|
|
|
|
z->zalloc = 0;
|
1997-08-07 03:52:55 +00:00
|
|
|
z->znalloc = 0;
|
1997-08-05 00:07:31 +00:00
|
|
|
simple_lock_init(&z->zlock);
|
|
|
|
|
1997-09-21 04:24:27 +00:00
|
|
|
z->zitems = NULL;
|
1997-08-05 00:07:31 +00:00
|
|
|
for (i = 0; i < nitems; i++) {
|
1997-09-21 04:24:27 +00:00
|
|
|
((void **) item)[0] = z->zitems;
|
|
|
|
#if defined(DIAGNOSTIC)
|
|
|
|
((void **) item)[1] = (void *) ZENTRY_FREE;
|
|
|
|
#endif
|
1997-08-05 00:07:31 +00:00
|
|
|
z->zitems = item;
|
|
|
|
(char *) item += z->zsize;
|
|
|
|
}
|
1997-08-06 04:58:05 +00:00
|
|
|
z->zfreecnt = nitems;
|
|
|
|
z->zmax = nitems;
|
|
|
|
z->ztotal = nitems;
|
|
|
|
|
|
|
|
if (zlist == 0) {
|
|
|
|
zlist = z;
|
|
|
|
} else {
|
|
|
|
z->znext = zlist;
|
|
|
|
zlist = z;
|
|
|
|
}
|
1997-08-05 00:07:31 +00:00
|
|
|
}
|
|
|
|
|
1997-08-05 22:24:31 +00:00
|
|
|
/*
|
|
|
|
* Zone critical region locks.
|
|
|
|
*/
|
1997-08-05 00:07:31 +00:00
|
|
|
static inline int
|
1997-09-21 11:41:12 +00:00
|
|
|
zlock(vm_zone_t z)
|
|
|
|
{
|
1997-08-05 00:07:31 +00:00
|
|
|
int s;
|
1997-09-21 11:41:12 +00:00
|
|
|
|
1997-08-05 00:07:31 +00:00
|
|
|
s = splhigh();
|
|
|
|
simple_lock(&z->zlock);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
1997-09-21 11:41:12 +00:00
|
|
|
zunlock(vm_zone_t z, int s)
|
|
|
|
{
|
1997-08-05 00:07:31 +00:00
|
|
|
simple_unlock(&z->zlock);
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
1997-08-05 22:24:31 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* void *zalloci(vm_zone_t zone) --
|
|
|
|
* Returns an item from a specified zone, interrupt safe.
|
|
|
|
*
|
|
|
|
* void zfreei(vm_zone_t zone, void *item) --
|
|
|
|
* Frees an item back to a specified zone, interrupt safe.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Zone allocator/deallocator. These are interrupt / (or potentially SMP)
|
|
|
|
* safe. The raw zalloc/zfree routines are in the vm_zone header file,
|
|
|
|
* and are not interrupt safe, but are fast.
|
|
|
|
*/
|
1997-08-05 00:07:31 +00:00
|
|
|
void *
|
1997-09-21 11:41:12 +00:00
|
|
|
zalloci(vm_zone_t z)
|
|
|
|
{
|
1997-08-05 00:07:31 +00:00
|
|
|
int s;
|
|
|
|
void *item;
|
1997-09-21 11:41:12 +00:00
|
|
|
|
1997-08-05 00:07:31 +00:00
|
|
|
s = zlock(z);
|
1997-08-05 22:24:31 +00:00
|
|
|
item = _zalloc(z);
|
1997-08-05 00:07:31 +00:00
|
|
|
zunlock(z, s);
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1997-09-21 11:41:12 +00:00
|
|
|
zfreei(vm_zone_t z, void *item)
|
|
|
|
{
|
1997-08-05 00:07:31 +00:00
|
|
|
int s;
|
1997-09-21 11:41:12 +00:00
|
|
|
|
1997-08-05 00:07:31 +00:00
|
|
|
s = zlock(z);
|
1997-08-05 22:24:31 +00:00
|
|
|
_zfree(z, item);
|
1997-08-05 00:07:31 +00:00
|
|
|
zunlock(z, s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1997-08-05 22:24:31 +00:00
|
|
|
/*
|
|
|
|
* Internal zone routine. Not to be called from external (non vm_zone) code.
|
|
|
|
*/
|
1997-08-05 00:07:31 +00:00
|
|
|
void *
|
1997-09-21 11:41:12 +00:00
|
|
|
_zget(vm_zone_t z)
|
|
|
|
{
|
1997-08-05 00:07:31 +00:00
|
|
|
int i;
|
|
|
|
vm_page_t m;
|
1997-09-21 04:24:27 +00:00
|
|
|
int nitems, nbytes;
|
1997-08-05 22:24:31 +00:00
|
|
|
void *item;
|
1997-08-05 00:07:31 +00:00
|
|
|
|
1997-09-21 04:24:27 +00:00
|
|
|
if (z == NULL)
|
|
|
|
panic("zget: null zone");
|
|
|
|
|
1997-08-05 22:24:31 +00:00
|
|
|
if (z->zflags & ZONE_INTERRUPT) {
|
1997-08-05 00:07:31 +00:00
|
|
|
item = (char *) z->zkva + z->zpagecount * PAGE_SIZE;
|
1997-09-21 11:41:12 +00:00
|
|
|
for (i = 0; ((i < z->zalloc) && (z->zpagecount < z->zpagemax));
|
|
|
|
i++) {
|
1997-08-05 00:07:31 +00:00
|
|
|
|
1997-09-21 11:41:12 +00:00
|
|
|
m = vm_page_alloc(z->zobj, z->zpagecount,
|
|
|
|
z->zallocflag);
|
|
|
|
if (m == NULL)
|
1997-08-05 00:07:31 +00:00
|
|
|
break;
|
|
|
|
|
1997-09-21 11:41:12 +00:00
|
|
|
pmap_kenter(z->zkva + z->zpagecount * PAGE_SIZE,
|
|
|
|
VM_PAGE_TO_PHYS(m));
|
1997-08-05 22:24:31 +00:00
|
|
|
z->zpagecount++;
|
1997-08-05 00:07:31 +00:00
|
|
|
}
|
|
|
|
nitems = (i * PAGE_SIZE) / z->zsize;
|
|
|
|
} else {
|
1997-09-21 04:24:27 +00:00
|
|
|
nbytes = z->zalloc * PAGE_SIZE;
|
1997-08-05 00:07:31 +00:00
|
|
|
/*
|
|
|
|
* We can wait, so just do normal kernel map allocation
|
|
|
|
*/
|
1997-09-21 04:24:27 +00:00
|
|
|
item = (void *) kmem_alloc(kernel_map, nbytes);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (z->zname)
|
|
|
|
printf("zalloc: %s, %d (0x%x --> 0x%x)\n",
|
1997-09-21 11:41:12 +00:00
|
|
|
z->zname, z->zalloc, item,
|
|
|
|
(char *)item + nbytes);
|
1997-09-21 04:24:27 +00:00
|
|
|
else
|
|
|
|
printf("zalloc: XXX(%d), %d (0x%x --> 0x%x)\n",
|
1997-09-21 11:41:12 +00:00
|
|
|
z->zsize, z->zalloc, item,
|
|
|
|
(char *)item + nbytes);
|
1997-09-21 04:24:27 +00:00
|
|
|
|
1997-09-21 11:41:12 +00:00
|
|
|
for (i = 0; i < nbytes; i += PAGE_SIZE)
|
|
|
|
printf("(%x, %x)", (char *) item + i,
|
|
|
|
pmap_kextract((char *) item + i));
|
1997-09-21 04:24:27 +00:00
|
|
|
printf("\n");
|
|
|
|
#endif
|
|
|
|
nitems = nbytes / z->zsize;
|
1997-08-05 00:07:31 +00:00
|
|
|
}
|
1997-08-06 04:58:05 +00:00
|
|
|
z->ztotal += nitems;
|
1997-08-05 00:07:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Save one for immediate allocation
|
|
|
|
*/
|
1997-08-05 22:24:31 +00:00
|
|
|
if (nitems != 0) {
|
|
|
|
nitems -= 1;
|
|
|
|
for (i = 0; i < nitems; i++) {
|
1997-09-21 04:24:27 +00:00
|
|
|
((void **) item)[0] = z->zitems;
|
|
|
|
#if defined(DIAGNOSTIC)
|
|
|
|
((void **) item)[1] = (void *) ZENTRY_FREE;
|
|
|
|
#endif
|
1997-08-05 22:24:31 +00:00
|
|
|
z->zitems = item;
|
|
|
|
(char *) item += z->zsize;
|
|
|
|
}
|
|
|
|
z->zfreecnt += nitems;
|
|
|
|
} else if (z->zfreecnt > 0) {
|
|
|
|
item = z->zitems;
|
1997-09-21 04:24:27 +00:00
|
|
|
z->zitems = ((void **) item)[0];
|
|
|
|
#if defined(DIAGNOSTIC)
|
|
|
|
if (((void **) item)[1] != (void *) ZENTRY_FREE)
|
|
|
|
zerror(ZONE_ERROR_NOTFREE);
|
|
|
|
((void **) item)[1] = 0;
|
|
|
|
#endif
|
1997-08-05 22:24:31 +00:00
|
|
|
z->zfreecnt--;
|
|
|
|
} else {
|
|
|
|
item = NULL;
|
1997-08-05 00:07:31 +00:00
|
|
|
}
|
1997-08-05 22:24:31 +00:00
|
|
|
|
1997-08-05 00:07:31 +00:00
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
1997-08-06 04:58:05 +00:00
|
|
|
int
|
|
|
|
sysctl_vm_zone SYSCTL_HANDLER_ARGS
|
|
|
|
{
|
|
|
|
int error=0;
|
|
|
|
vm_zone_t curzone, nextzone;
|
|
|
|
char tmpbuf[128];
|
1997-08-07 03:52:55 +00:00
|
|
|
char tmpname[14];
|
1997-08-06 04:58:05 +00:00
|
|
|
|
1997-12-14 05:17:44 +00:00
|
|
|
sprintf(tmpbuf, "\nITEM SIZE LIMIT USED FREE REQUESTS\n");
|
|
|
|
error = SYSCTL_OUT(req, tmpbuf, strlen(tmpbuf));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
1997-08-06 04:58:05 +00:00
|
|
|
for (curzone = zlist; curzone; curzone = nextzone) {
|
1997-09-21 11:41:12 +00:00
|
|
|
int i;
|
|
|
|
int len;
|
|
|
|
int offset;
|
|
|
|
|
|
|
|
nextzone = curzone->znext;
|
|
|
|
len = strlen(curzone->zname);
|
|
|
|
if (len >= (sizeof(tmpname) - 1))
|
|
|
|
len = (sizeof(tmpname) - 1);
|
|
|
|
for(i = 0; i < sizeof(tmpname) - 1; i++)
|
|
|
|
tmpname[i] = ' ';
|
|
|
|
tmpname[i] = 0;
|
|
|
|
memcpy(tmpname, curzone->zname, len);
|
|
|
|
tmpname[len] = ':';
|
|
|
|
offset = 0;
|
|
|
|
if (curzone == zlist) {
|
|
|
|
offset = 1;
|
|
|
|
tmpbuf[0] = '\n';
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(tmpbuf + offset,
|
1997-12-14 05:17:44 +00:00
|
|
|
"%s %6.6u, %8.8u, %6.6u, %6.6u, %8.8u\n",
|
|
|
|
tmpname, curzone->zsize, curzone->zmax,
|
1997-09-21 11:41:12 +00:00
|
|
|
(curzone->ztotal - curzone->zfreecnt),
|
|
|
|
curzone->zfreecnt, curzone->znalloc);
|
|
|
|
|
|
|
|
len = strlen((char *)tmpbuf);
|
|
|
|
if (nextzone == NULL)
|
|
|
|
tmpbuf[len - 1] = 0;
|
|
|
|
|
|
|
|
error = SYSCTL_OUT(req, tmpbuf, len);
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
return (error);
|
1997-08-06 04:58:05 +00:00
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1997-09-21 04:24:27 +00:00
|
|
|
#if defined(DIAGNOSTIC)
|
|
|
|
void
|
1997-09-21 11:41:12 +00:00
|
|
|
zerror(int error)
|
|
|
|
{
|
1997-09-21 04:24:27 +00:00
|
|
|
char *msg;
|
1997-09-21 11:41:12 +00:00
|
|
|
|
1997-09-21 04:24:27 +00:00
|
|
|
switch (error) {
|
1997-09-21 11:41:12 +00:00
|
|
|
case ZONE_ERROR_INVALID:
|
1997-09-21 04:24:27 +00:00
|
|
|
msg = "zone: invalid zone";
|
|
|
|
break;
|
1997-09-21 11:41:12 +00:00
|
|
|
case ZONE_ERROR_NOTFREE:
|
1997-09-21 04:24:27 +00:00
|
|
|
msg = "zone: entry not free";
|
|
|
|
break;
|
1997-09-21 11:41:12 +00:00
|
|
|
case ZONE_ERROR_ALREADYFREE:
|
1997-09-21 04:24:27 +00:00
|
|
|
msg = "zone: freeing free entry";
|
|
|
|
break;
|
1997-09-21 11:41:12 +00:00
|
|
|
default:
|
1997-09-21 04:24:27 +00:00
|
|
|
msg = "zone: invalid error";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
panic(msg);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1997-08-06 04:58:05 +00:00
|
|
|
SYSCTL_OID(_kern, OID_AUTO, zone, CTLTYPE_STRING|CTLFLAG_RD, \
|
|
|
|
NULL, 0, sysctl_vm_zone, "A", "Zone Info");
|