FreeBSD/sys/kern/vfs_bio.c
/*
 *	bufkva_free:
 *
 *	Free the kva allocation for a buffer.
 *
 */
Free the kva allocation for a buffer.
Free the kva allocation for a buffer .
static void
bufkva_free(struct buf *bp)
{
#ifdef INVARIANTS
	if (bp->b_kvasize == 0) {
		KASSERT(bp->b_kvabase == unmapped_buf &&
		    bp->b_data == unmapped_buf,
		    ("Leaked KVA space on %p", bp));
	} else if (buf_mapped(bp))
		BUF_CHECK_MAPPED(bp);
	else
		BUF_CHECK_UNMAPPED(bp);
#endif
	if (bp->b_kvasize == 0)
		return;
	vmem_free(buffer_arena, (vm_offset_t)bp->b_kvabase, bp->b_kvasize);
	atomic_subtract_long(&bufkvaspace, bp->b_kvasize);
	atomic_add_int(&buffreekvacnt, 1);
	bp->b_data = bp->b_kvabase = unmapped_buf;
	bp->b_kvasize = 0;
}
static void bufkva_free ( struct buf * bp ) { #ifdef INVARIANTS if ( bp -> b_kvasize == 0 ) { KASSERT ( bp -> b_kvabase == unmapped_buf && bp -> b_data == unmapped_buf , ( " " , bp ) ) ; } else if ( buf_mapped ( bp ) ) BUF_CHECK_MAPPED ( bp ) ; else BUF_CHECK_UNMAPPED ( bp ) ; #endif if ( bp -> b_kvasize == 0 ) return ; vmem_free ( buffer_arena , ( vm_offset_t ) bp -> b_kvabase , bp -> b_kvasize ) ; atomic_subtract_long ( & bufkvaspace , bp -> b_kvasize ) ; atomic_add_int ( & buffreekvacnt , 1 ) ; bp -> b_data = bp -> b_kvabase = unmapped_buf ; bp -> b_kvasize = 0 ; }
bufkva_free:
      Free the kva allocation for a buffer.
bufkva_free : Free the kva allocation for a buffer .