version 1.21, 2006/11/12 22:28:17 |
version 1.22, 2006/11/18 07:51:06 |
|
|
/* quantum cache */ |
/* quantum cache */ |
size_t vm_qcache_max; |
size_t vm_qcache_max; |
struct pool_allocator vm_qcache_allocator; |
struct pool_allocator vm_qcache_allocator; |
qcache_t vm_qcache[VMEM_QCACHE_IDX_MAX]; |
qcache_t vm_qcache_store[VMEM_QCACHE_IDX_MAX]; |
|
qcache_t *vm_qcache[VMEM_QCACHE_IDX_MAX]; |
#endif /* defined(QCACHE) */ |
#endif /* defined(QCACHE) */ |
}; |
}; |
|
|
Line 464 qc_poolpage_free(struct pool *pool, void |
|
Line 465 qc_poolpage_free(struct pool *pool, void |
|
static void |
static void |
qc_init(vmem_t *vm, size_t qcache_max) |
qc_init(vmem_t *vm, size_t qcache_max) |
{ |
{ |
|
qcache_t *prevqc; |
struct pool_allocator *pa; |
struct pool_allocator *pa; |
int qcache_idx_max; |
int qcache_idx_max; |
int i; |
int i; |
Line 480 qc_init(vmem_t *vm, size_t qcache_max) |
|
Line 482 qc_init(vmem_t *vm, size_t qcache_max) |
|
pa->pa_pagesz = qc_poolpage_size(qcache_max); |
pa->pa_pagesz = qc_poolpage_size(qcache_max); |
|
|
qcache_idx_max = qcache_max >> vm->vm_quantum_shift; |
qcache_idx_max = qcache_max >> vm->vm_quantum_shift; |
for (i = 1; i <= qcache_idx_max; i++) { |
prevqc = NULL; |
qcache_t *qc = &vm->vm_qcache[i - 1]; |
for (i = qcache_idx_max; i > 0; i--) { |
|
qcache_t *qc = &vm->vm_qcache_store[i - 1]; |
size_t size = i << vm->vm_quantum_shift; |
size_t size = i << vm->vm_quantum_shift; |
|
|
qc->qc_vmem = vm; |
qc->qc_vmem = vm; |
Line 489 qc_init(vmem_t *vm, size_t qcache_max) |
|
Line 492 qc_init(vmem_t *vm, size_t qcache_max) |
|
vm->vm_name, size); |
vm->vm_name, size); |
pool_init(&qc->qc_pool, size, ORDER2SIZE(vm->vm_quantum_shift), |
pool_init(&qc->qc_pool, size, ORDER2SIZE(vm->vm_quantum_shift), |
0, PR_NOALIGN | PR_NOTOUCH /* XXX */, qc->qc_name, pa); |
0, PR_NOALIGN | PR_NOTOUCH /* XXX */, qc->qc_name, pa); |
|
if (prevqc != NULL && |
|
qc->qc_pool.pr_itemsperpage == |
|
prevqc->qc_pool.pr_itemsperpage) { |
|
pool_destroy(&qc->qc_pool); |
|
vm->vm_qcache[i - 1] = prevqc; |
|
} |
pool_cache_init(&qc->qc_cache, &qc->qc_pool, NULL, NULL, NULL); |
pool_cache_init(&qc->qc_cache, &qc->qc_pool, NULL, NULL, NULL); |
|
vm->vm_qcache[i - 1] = qc; |
|
prevqc = qc; |
} |
} |
} |
} |
|
|
static boolean_t |
static boolean_t |
qc_reap(vmem_t *vm) |
qc_reap(vmem_t *vm) |
{ |
{ |
|
const qcache_t *prevqc; |
int i; |
int i; |
int qcache_idx_max; |
int qcache_idx_max; |
boolean_t didsomething = FALSE; |
boolean_t didsomething = FALSE; |
|
|
qcache_idx_max = vm->vm_qcache_max >> vm->vm_quantum_shift; |
qcache_idx_max = vm->vm_qcache_max >> vm->vm_quantum_shift; |
|
prevqc = NULL; |
for (i = 1; i <= qcache_idx_max; i++) { |
for (i = 1; i <= qcache_idx_max; i++) { |
qcache_t *qc = &vm->vm_qcache[i - 1]; |
qcache_t *qc = vm->vm_qcache[i - 1]; |
|
|
|
if (prevqc == qc) { |
|
continue; |
|
} |
if (pool_reclaim(&qc->qc_pool) != 0) { |
if (pool_reclaim(&qc->qc_pool) != 0) { |
didsomething = TRUE; |
didsomething = TRUE; |
} |
} |
|
prevqc = qc; |
} |
} |
|
|
return didsomething; |
return didsomething; |
Line 801 vmem_alloc(vmem_t *vm, vmem_size_t size0 |
|
Line 818 vmem_alloc(vmem_t *vm, vmem_size_t size0 |
|
#if defined(QCACHE) |
#if defined(QCACHE) |
if (size <= vm->vm_qcache_max) { |
if (size <= vm->vm_qcache_max) { |
int qidx = size >> vm->vm_quantum_shift; |
int qidx = size >> vm->vm_quantum_shift; |
qcache_t *qc = &vm->vm_qcache[qidx - 1]; |
qcache_t *qc = vm->vm_qcache[qidx - 1]; |
|
|
return (vmem_addr_t)pool_cache_get(&qc->qc_cache, |
return (vmem_addr_t)pool_cache_get(&qc->qc_cache, |
vmf_to_prf(flags)); |
vmf_to_prf(flags)); |
Line 971 vmem_free(vmem_t *vm, vmem_addr_t addr, |
|
Line 988 vmem_free(vmem_t *vm, vmem_addr_t addr, |
|
#if defined(QCACHE) |
#if defined(QCACHE) |
if (size <= vm->vm_qcache_max) { |
if (size <= vm->vm_qcache_max) { |
int qidx = (size + vm->vm_quantum_mask) >> vm->vm_quantum_shift; |
int qidx = (size + vm->vm_quantum_mask) >> vm->vm_quantum_shift; |
qcache_t *qc = &vm->vm_qcache[qidx - 1]; |
qcache_t *qc = vm->vm_qcache[qidx - 1]; |
|
|
return pool_cache_put(&qc->qc_cache, (void *)addr); |
return pool_cache_put(&qc->qc_cache, (void *)addr); |
} |
} |