| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: subr_vmem.c,v 1.53 2009/01/23 13:45:06 pooka Exp $ */ | | 1 | /* $NetBSD: subr_vmem.c,v 1.54 2009/01/25 13:08:56 yamt Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c)2006 YAMAMOTO Takashi, | | 4 | * Copyright (c)2006 YAMAMOTO Takashi, |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -28,27 +28,27 @@ | | | @@ -28,27 +28,27 @@ |
28 | | | 28 | |
29 | /* | | 29 | /* |
30 | * reference: | | 30 | * reference: |
31 | * - Magazines and Vmem: Extending the Slab Allocator | | 31 | * - Magazines and Vmem: Extending the Slab Allocator |
32 | * to Many CPUs and Arbitrary Resources | | 32 | * to Many CPUs and Arbitrary Resources |
33 | * http://www.usenix.org/event/usenix01/bonwick.html | | 33 | * http://www.usenix.org/event/usenix01/bonwick.html |
34 | * | | 34 | * |
35 | * todo: | | 35 | * todo: |
36 | * - decide how to import segments for vmem_xalloc. | | 36 | * - decide how to import segments for vmem_xalloc. |
37 | * - don't rely on malloc(9). | | 37 | * - don't rely on malloc(9). |
38 | */ | | 38 | */ |
39 | | | 39 | |
40 | #include <sys/cdefs.h> | | 40 | #include <sys/cdefs.h> |
41 | __KERNEL_RCSID(0, "$NetBSD: subr_vmem.c,v 1.53 2009/01/23 13:45:06 pooka Exp $"); | | 41 | __KERNEL_RCSID(0, "$NetBSD: subr_vmem.c,v 1.54 2009/01/25 13:08:56 yamt Exp $"); |
42 | | | 42 | |
43 | #if defined(_KERNEL) | | 43 | #if defined(_KERNEL) |
44 | #include "opt_ddb.h" | | 44 | #include "opt_ddb.h" |
45 | #define QCACHE | | 45 | #define QCACHE |
46 | #endif /* defined(_KERNEL) */ | | 46 | #endif /* defined(_KERNEL) */ |
47 | | | 47 | |
48 | #include <sys/param.h> | | 48 | #include <sys/param.h> |
49 | #include <sys/hash.h> | | 49 | #include <sys/hash.h> |
50 | #include <sys/queue.h> | | 50 | #include <sys/queue.h> |
51 | | | 51 | |
52 | #if defined(_KERNEL) | | 52 | #if defined(_KERNEL) |
53 | #include <sys/systm.h> | | 53 | #include <sys/systm.h> |
54 | #include <sys/kernel.h> /* hz */ | | 54 | #include <sys/kernel.h> /* hz */ |
| @@ -81,27 +81,27 @@ __KERNEL_RCSID(0, "$NetBSD: subr_vmem.c, | | | @@ -81,27 +81,27 @@ __KERNEL_RCSID(0, "$NetBSD: subr_vmem.c, |
81 | #define IPL_VM 0 | | 81 | #define IPL_VM 0 |
82 | #endif /* defined(_KERNEL) */ | | 82 | #endif /* defined(_KERNEL) */ |
83 | | | 83 | |
84 | struct vmem; | | 84 | struct vmem; |
85 | struct vmem_btag; | | 85 | struct vmem_btag; |
86 | | | 86 | |
87 | #if defined(VMEM_DEBUG) | | 87 | #if defined(VMEM_DEBUG) |
88 | void vmem_dump(const vmem_t *); | | 88 | void vmem_dump(const vmem_t *); |
89 | #endif /* defined(VMEM_DEBUG) */ | | 89 | #endif /* defined(VMEM_DEBUG) */ |
90 | | | 90 | |
91 | #define VMEM_MAXORDER (sizeof(vmem_size_t) * CHAR_BIT) | | 91 | #define VMEM_MAXORDER (sizeof(vmem_size_t) * CHAR_BIT) |
92 | | | 92 | |
93 | #define VMEM_HASHSIZE_MIN 1 /* XXX */ | | 93 | #define VMEM_HASHSIZE_MIN 1 /* XXX */ |
94 | #define VMEM_HASHSIZE_MAX 8192 /* XXX */ | | 94 | #define VMEM_HASHSIZE_MAX 65536 /* XXX */ |
95 | #define VMEM_HASHSIZE_INIT 128 | | 95 | #define VMEM_HASHSIZE_INIT 128 |
96 | | | 96 | |
97 | #define VM_FITMASK (VM_BESTFIT | VM_INSTANTFIT) | | 97 | #define VM_FITMASK (VM_BESTFIT | VM_INSTANTFIT) |
98 | | | 98 | |
99 | CIRCLEQ_HEAD(vmem_seglist, vmem_btag); | | 99 | CIRCLEQ_HEAD(vmem_seglist, vmem_btag); |
100 | LIST_HEAD(vmem_freelist, vmem_btag); | | 100 | LIST_HEAD(vmem_freelist, vmem_btag); |
101 | LIST_HEAD(vmem_hashlist, vmem_btag); | | 101 | LIST_HEAD(vmem_hashlist, vmem_btag); |
102 | | | 102 | |
103 | #if defined(QCACHE) | | 103 | #if defined(QCACHE) |
104 | #define VMEM_QCACHE_IDX_MAX 32 | | 104 | #define VMEM_QCACHE_IDX_MAX 32 |
105 | | | 105 | |
106 | #define QC_NAME_MAX 16 | | 106 | #define QC_NAME_MAX 16 |
107 | | | 107 | |