FreeBSD/sys/kern/subr_vmem.c
/*
 * Fill the vmem's boundary tag cache.  We guarantee that boundary tag
 * allocation will not fail once bt_fill() passes.  To do so we cache
 * at least the maximum possible tag allocations in the arena.
 */
Fill the vmem's boundary tag cache.  We guarantee that boundary tag
allocation will not fail once bt_fill() passes.  To do so we cache
at least the maximum possible tag allocations in the arena.
Fill the vmem ' s boundary tag cache . We guarantee that boundary tag allocation will not fail once bt_fill () passes . To do so we cache at least the maximum possible tag allocations in the arena .
static int
bt_fill(vmem_t *vm, int flags)
{
	bt_t *bt;
	VMEM_ASSERT_LOCKED(vm);
	flags &= BT_FLAGS;
	if (vm != kmem_arena)
		flags &= ~M_USE_RESERVE;
	while (vm->vm_nfreetags < BT_MAXALLOC) {
		bt = uma_zalloc(vmem_bt_zone,
		    (flags & M_USE_RESERVE) | M_NOWAIT | M_NOVM);
		if (bt == NULL) {
			VMEM_UNLOCK(vm);
			bt = uma_zalloc(vmem_bt_zone, flags);
			VMEM_LOCK(vm);
			if (bt == NULL && (flags & M_NOWAIT) != 0)
				break;
		}
		LIST_INSERT_HEAD(&vm->vm_freetags, bt, bt_freelist);
		vm->vm_nfreetags++;
	}
	if (vm->vm_nfreetags < BT_MAXALLOC)
		return ENOMEM;
	return 0;
}
static int bt_fill ( vmem_t * vm , int flags ) { bt_t * bt ; VMEM_ASSERT_LOCKED ( vm ) ; flags &= BT_FLAGS ; if ( vm != kmem_arena ) flags &= ~ M_USE_RESERVE ; while ( vm -> vm_nfreetags < BT_MAXALLOC ) { bt = uma_zalloc ( vmem_bt_zone , ( flags & M_USE_RESERVE ) | M_NOWAIT | M_NOVM ) ; if ( bt == NULL ) { VMEM_UNLOCK ( vm ) ; bt = uma_zalloc ( vmem_bt_zone , flags ) ; VMEM_LOCK ( vm ) ; if ( bt == NULL && ( flags & M_NOWAIT ) != 0 ) break ; } LIST_INSERT_HEAD ( & vm -> vm_freetags , bt , bt_freelist ) ; vm -> vm_nfreetags ++ ; } if ( vm -> vm_nfreetags < BT_MAXALLOC ) return ENOMEM ; return 0 ; }
Fill the vmem's boundary tag cache.
Fill the vmem ' s boundary tag cache .
/*
	 * Only allow the kmem arena to dip into reserve tags.  It is the
	 * vmem where new tags come from.
	 */ /*
	 * Loop until we meet the reserve.  To minimize the lock shuffle
	 * and prevent simultaneous fills we first try a NOWAIT regardless
	 * of the caller's flags.  Specify M_NOVM so we don't recurse while
	 * holding a vmem lock.
	 */