Add exposure of some vm_zone allocation stats by sysctl. Also, change
the initialization parameters of some zones in VM map. This contains only optimizations and not bugfixes.
This commit is contained in:
parent
16050303bd
commit
507b10b48c
@ -61,7 +61,7 @@
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*
|
||||
* $Id: vm_map.c,v 1.83 1997/08/05 22:24:28 dyson Exp $
|
||||
* $Id: vm_map.c,v 1.84 1997/08/05 23:03:23 dyson Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -208,11 +208,11 @@ vmspace_alloc(min, max, pageable)
|
||||
void
|
||||
vm_init2(void) {
|
||||
zinitna(kmapentzone, &kmapentobj,
|
||||
NULL, 0, 4096, ZONE_INTERRUPT, 4);
|
||||
NULL, 0, cnt.v_page_count / 4, ZONE_INTERRUPT, 4);
|
||||
zinitna(mapentzone, &mapentobj,
|
||||
NULL, 0, 0, 0, 4);
|
||||
zinitna(mapzone, &mapobj,
|
||||
NULL, 0, 0, 0, 4);
|
||||
NULL, 0, 0, 0, 1);
|
||||
pmap_init2();
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
* 5. Modifications may be freely made to this file if the above conditions
|
||||
* are met.
|
||||
*
|
||||
* $Id: vm_zone.c,v 1.1 1997/08/05 00:07:29 dyson Exp $
|
||||
* $Id: vm_zone.c,v 1.2 1997/08/05 22:24:30 dyson Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -30,6 +30,7 @@
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/vmmeter.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include <vm/vm.h>
|
||||
#include <vm/vm_object.h>
|
||||
@ -53,6 +54,9 @@
|
||||
* zalloci, zfreei, are the interrupt/lock safe allocation/free routines.
|
||||
*/
|
||||
|
||||
struct vm_zone *zlist;
|
||||
int sysctl_vm_zone SYSCTL_HANDLER_ARGS;
|
||||
|
||||
/*
|
||||
* Create a zone, but don't allocate the zone structure. If the
|
||||
* zone had been previously created by the zone boot code, initialize
|
||||
@ -85,7 +89,16 @@ zinitna(vm_zone_t z, vm_object_t obj, char *name, int size,
|
||||
z->zsize = size;
|
||||
simple_lock_init(&z->zlock);
|
||||
z->zfreecnt = 0;
|
||||
z->ztotal = 0;
|
||||
z->zmax = 0;
|
||||
z->zname = name;
|
||||
|
||||
if (zlist == 0) {
|
||||
zlist = z;
|
||||
} else {
|
||||
z->znext = zlist;
|
||||
zlist = z;
|
||||
}
|
||||
}
|
||||
|
||||
z->zflags |= flags;
|
||||
@ -111,10 +124,13 @@ zinitna(vm_zone_t z, vm_object_t obj, char *name, int size,
|
||||
_vm_object_allocate(OBJT_DEFAULT, z->zpagemax, obj);
|
||||
}
|
||||
z->zallocflag = VM_ALLOC_INTERRUPT;
|
||||
z->zmax += nentries;
|
||||
} else {
|
||||
z->zallocflag = VM_ALLOC_SYSTEM;
|
||||
z->zmax = 0;
|
||||
}
|
||||
|
||||
|
||||
if ( z->zsize > PAGE_SIZE)
|
||||
z->zfreemin = 1;
|
||||
else
|
||||
@ -177,7 +193,16 @@ zbootinit(vm_zone_t z, char *name, int size, void *item, int nitems) {
|
||||
z->zitems = item;
|
||||
(char *) item += z->zsize;
|
||||
}
|
||||
z->zfreecnt += nitems;
|
||||
z->zfreecnt = nitems;
|
||||
z->zmax = nitems;
|
||||
z->ztotal = nitems;
|
||||
|
||||
if (zlist == 0) {
|
||||
zlist = z;
|
||||
} else {
|
||||
z->znext = zlist;
|
||||
zlist = z;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -266,6 +291,7 @@ _zget(vm_zone_t z) {
|
||||
item = (void *) kmem_alloc(kernel_map, z->zalloc * PAGE_SIZE);
|
||||
nitems = (z->zalloc * PAGE_SIZE) / z->zsize;
|
||||
}
|
||||
z->ztotal += nitems;
|
||||
|
||||
/*
|
||||
* Save one for immediate allocation
|
||||
@ -289,3 +315,45 @@ _zget(vm_zone_t z) {
|
||||
return item;
|
||||
}
|
||||
|
||||
int
|
||||
sysctl_vm_zone SYSCTL_HANDLER_ARGS
|
||||
{
|
||||
int error=0;
|
||||
vm_zone_t curzone, nextzone;
|
||||
char tmpbuf[128];
|
||||
char tmpname[16];
|
||||
|
||||
for (curzone = zlist; curzone; curzone = nextzone) {
|
||||
int i;
|
||||
int len;
|
||||
int offset;
|
||||
nextzone = curzone->znext;
|
||||
len = strlen(curzone->zname);
|
||||
for(i = 0; i < sizeof(tmpname) - 1; i++)
|
||||
tmpname[i] = ' ';
|
||||
tmpname[i] = 0;
|
||||
memcpy(tmpname, curzone->zname, len);
|
||||
offset = 0;
|
||||
if (curzone == zlist) {
|
||||
offset = 1;
|
||||
tmpbuf[0] = '\n';
|
||||
}
|
||||
|
||||
sprintf(tmpbuf + offset, "%s: maxpossible=%6.6d, total=%6.6d, free=%6.6d\n",
|
||||
tmpname, curzone->zmax, curzone->ztotal, curzone->zfreecnt);
|
||||
|
||||
len = strlen((char *)tmpbuf);
|
||||
if (nextzone == NULL) {
|
||||
tmpbuf[len - 1] = 0;
|
||||
}
|
||||
|
||||
error = SYSCTL_OUT(req, tmpbuf, len);
|
||||
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
SYSCTL_OID(_kern, OID_AUTO, zone, CTLTYPE_STRING|CTLFLAG_RD, \
|
||||
NULL, 0, sysctl_vm_zone, "A", "Zone Info");
|
||||
|
@ -19,7 +19,7 @@
|
||||
* 5. Modifications may be freely made to this file if the above conditions
|
||||
* are met.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: vm_zone.h,v 1.2 1997/08/05 22:24:31 dyson Exp $
|
||||
*/
|
||||
|
||||
#if !defined(_SYS_ZONE_H)
|
||||
@ -41,12 +41,15 @@ typedef struct vm_zone {
|
||||
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;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user