2 * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
3 * Copyright (C) 2007 The Regents of the University of California.
4 * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
5 * Written by Brian Behlendorf <behlendorf1@llnl.gov>.
8 * This file is part of the SPL, Solaris Porting Layer.
9 * For details, see <http://zfsonlinux.org/>.
11 * The SPL is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
16 * The SPL is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * You should have received a copy of the GNU General Public License along
22 * with the SPL. If not, see <http://www.gnu.org/licenses/>.
25 #include <sys/debug.h>
27 #include <linux/mm_compat.h>
28 #include <linux/module.h>
30 vmem_t *heap_arena = NULL;
31 EXPORT_SYMBOL(heap_arena);
33 vmem_t *zio_alloc_arena = NULL;
34 EXPORT_SYMBOL(zio_alloc_arena);
36 vmem_t *zio_arena = NULL;
37 EXPORT_SYMBOL(zio_arena);
40 vmem_size(vmem_t *vmp, int typemask)
42 ASSERT3P(vmp, ==, NULL);
43 ASSERT3S(typemask & VMEM_ALLOC, ==, VMEM_ALLOC);
44 ASSERT3S(typemask & VMEM_FREE, ==, VMEM_FREE);
46 return (VMALLOC_TOTAL);
48 EXPORT_SYMBOL(vmem_size);
51 * Public vmem_alloc(), vmem_zalloc() and vmem_free() interfaces.
54 spl_vmem_alloc(size_t size, int flags, const char *func, int line)
56 ASSERT0(flags & ~KM_PUBLIC_MASK);
60 #if !defined(DEBUG_KMEM)
61 return (spl_kmem_alloc_impl(size, flags, NUMA_NO_NODE));
62 #elif !defined(DEBUG_KMEM_TRACKING)
63 return (spl_kmem_alloc_debug(size, flags, NUMA_NO_NODE));
65 return (spl_kmem_alloc_track(size, flags, func, line, NUMA_NO_NODE));
68 EXPORT_SYMBOL(spl_vmem_alloc);
71 spl_vmem_zalloc(size_t size, int flags, const char *func, int line)
73 ASSERT0(flags & ~KM_PUBLIC_MASK);
75 flags |= (KM_VMEM | KM_ZERO);
77 #if !defined(DEBUG_KMEM)
78 return (spl_kmem_alloc_impl(size, flags, NUMA_NO_NODE));
79 #elif !defined(DEBUG_KMEM_TRACKING)
80 return (spl_kmem_alloc_debug(size, flags, NUMA_NO_NODE));
82 return (spl_kmem_alloc_track(size, flags, func, line, NUMA_NO_NODE));
85 EXPORT_SYMBOL(spl_vmem_zalloc);
88 spl_vmem_free(const void *buf, size_t size)
90 #if !defined(DEBUG_KMEM)
91 return (spl_kmem_free_impl(buf, size));
92 #elif !defined(DEBUG_KMEM_TRACKING)
93 return (spl_kmem_free_debug(buf, size));
95 return (spl_kmem_free_track(buf, size));
98 EXPORT_SYMBOL(spl_vmem_free);