vkernel - Fix more pagein/pageout corruption
[dragonfly.git] / sys / vm / vm_zone.h
blob7a81d832579f9d872ddeff803b9a5a32f43e1f05
1 /*
2 * Copyright (c) 1997, 1998 John S. Dyson
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice immediately at the beginning of the file, without modification,
10 * this list of conditions, and the following disclaimer.
11 * 2. Absolutely no warranty of function or purpose is made by the author
12 * John S. Dyson.
14 * $FreeBSD: src/sys/vm/vm_zone.h,v 1.13.2.2 2002/10/10 19:50:16 dillon Exp $
15 * $DragonFly: src/sys/vm/vm_zone.h,v 1.10 2008/01/21 20:21:19 nth Exp $
18 #ifndef _VM_VM_ZONE_H_
19 #define _VM_VM_ZONE_H_
21 #define ZONE_INTERRUPT 0x0001 /* If you need to allocate at int time */
22 #define ZONE_PANICFAIL 0x0002 /* panic if the zalloc fails */
23 #define ZONE_SPECIAL 0x0004 /* special vm_map_entry zone, see zget() */
24 #define ZONE_BOOT 0x0010 /* Internal flag used by zbootinit */
25 #define ZONE_USE_RESERVE 0x0020 /* use reserve memory if necessary */
26 #define ZONE_DESTROYABLE 0x0040 /* can be zdestroy()'ed */
28 #include <sys/spinlock.h>
29 #include <sys/thread.h>
32 * Zone allocator.
33 * Zones are deprecated, use <sys/objcache.h> instead for new developments.
34 * Zones are not thread-safe; the mp lock must be held while calling
35 * zone functions.
37 struct vm_zpcpu {
38 void *zitems;
39 long zfreecnt;
40 long znalloc; /* allocations from pcpu */
41 } __cachealign;
43 typedef struct vm_zpcpu vm_zpcpu_t;
45 typedef struct vm_zone {
46 struct spinlock zlock; /* lock for global portion */
47 vm_zpcpu_t zpcpu[SMP_MAXCPU];
48 void *zitems; /* linked list of items */
49 long zfreecnt; /* free entries */
50 long zfreemin; /* minimum number of free entries */
51 long znalloc; /* allocations from global */
52 vm_offset_t zkva; /* Base kva of zone */
53 vm_pindex_t zpagecount; /* Total # of allocated pages */
54 vm_pindex_t zpagemax; /* Max address space */
55 long zmax; /* Max number of entries allocated */
56 long zmax_pcpu; /* Max pcpu cache */
57 long ztotal; /* Total entries allocated now */
58 long zsize; /* size of each entry */
59 long zalloc; /* hint for # of pages to alloc */
60 long zflags; /* flags for zone */
61 uint32_t zallocflag; /* flag for allocation */
62 struct vm_object *zobj; /* object to hold zone */
63 char *zname; /* name for diags */
64 LIST_ENTRY(vm_zone) zlink; /* link in zlist */
67 * The following fields track kmem_alloc()'ed blocks when
68 * ZONE_DESTROYABLE set and normal zone (i.e. not ZONE_INTERRUPT nor
69 * ZONE_SPECIAL).
71 vm_offset_t *zkmvec; /* krealloc()'ed array */
72 long zkmcur; /* next free slot in zkmvec */
73 long zkmmax; /* # of slots in zkmvec */
74 } *vm_zone_t;
77 void zerror (int) __dead2;
78 vm_zone_t zinit (char *name, size_t size, long nentries, uint32_t flags);
79 int zinitna (vm_zone_t z, struct vm_object *obj, char *name,
80 size_t size, long nentries, uint32_t flags);
81 void * zalloc (vm_zone_t z);
82 void zfree (vm_zone_t z, void *item);
83 void zbootinit (vm_zone_t z, char *name, size_t size, void *item,
84 long nitems);
85 void zdestroy(vm_zone_t z);
87 #endif /* _VM_VM_ZONE_H_ */