dhcpcd: update README.DRAGONFLY
[dragonfly.git] / sys / vm / vm_zone.h
blobb709ff580f10632a2b8753944daf6a5c9b7b208a
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 $
17 #ifndef _VM_VM_ZONE_H_
18 #define _VM_VM_ZONE_H_
20 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
22 #include <sys/spinlock.h>
23 #include <sys/thread.h>
25 #define ZONE_INTERRUPT 0x0001 /* If you need to allocate at int time */
26 #define ZONE_PANICFAIL 0x0002 /* panic if the zalloc fails */
27 #define ZONE_SPECIAL 0x0004 /* special vm_map_entry zone, see zget() */
28 #define ZONE_BOOT 0x0010 /* Internal flag used by zbootinit */
29 #define ZONE_USE_RESERVE 0x0020 /* use reserve memory if necessary */
30 #define ZONE_DESTROYABLE 0x0040 /* can be zdestroy()'ed */
32 #define ZONE_MAXPGLOAD 32 /* max VM pages burst in zget() */
35 * Zone allocator.
36 * Zones are deprecated, use <sys/objcache.h> instead for new developments.
37 * Zones are not thread-safe; the mp lock must be held while calling
38 * zone functions.
40 struct vm_zpcpu {
41 void *zitems;
42 long zfreecnt;
43 long znalloc; /* allocations from pcpu */
44 } __cachealign;
46 typedef struct vm_zpcpu vm_zpcpu_t;
48 typedef struct vm_zone {
49 vm_zpcpu_t zpcpu[SMP_MAXCPU];
50 struct spinlock zspin; /* lock for global portion */
51 void *zitems; /* linked list of items */
52 long zfreecnt; /* free entries */
53 long zfreemin; /* minimum number of free entries */
54 long znalloc; /* allocations from global */
55 vm_offset_t zkva; /* Base kva of zone */
56 vm_pindex_t zpagecount; /* Total # of allocated pages */
57 vm_pindex_t zpagemax; /* Max address space */
58 long zmax; /* Max number of entries allocated */
59 long zmax_pcpu; /* Max pcpu cache */
60 long ztotal; /* Total entries allocated now */
61 long zsize; /* size of each entry */
62 long zalloc; /* hint for # of pages to alloc */
63 long zflags; /* flags for zone */
64 uint32_t zallocflag; /* flag for allocation */
65 char *zname; /* name for diags */
66 LIST_ENTRY(vm_zone) zlink; /* link in zlist */
69 * The following fields track kmem_alloc()'ed blocks when
70 * ZONE_DESTROYABLE set and normal zone (i.e. not ZONE_INTERRUPT nor
71 * ZONE_SPECIAL).
73 vm_offset_t *zkmvec; /* krealloc()'ed array */
74 long zkmcur; /* next free slot in zkmvec */
75 long zkmmax; /* # of slots in zkmvec */
76 struct lock zgetlk; /* special zget interlock */
77 } *vm_zone_t;
79 #ifdef _KERNEL
80 void zerror (int) __dead2;
81 vm_zone_t zinit (char *name, size_t size, long nentries, uint32_t flags);
82 int zinitna (vm_zone_t z, char *name,
83 size_t size, long nentries, uint32_t flags);
84 void * zalloc (vm_zone_t z);
85 void zfree (vm_zone_t z, void *item);
86 void zbootinit (vm_zone_t z, char *name, size_t size, void *item,
87 long nitems);
88 void zdestroy(vm_zone_t z);
89 #endif /* _KERNEL */
91 #endif /* _KERNEL || _KERNEL_STRUCTURES */
93 #endif /* _VM_VM_ZONE_H_ */