2 * zsmalloc memory allocator
4 * Copyright (C) 2011 Nitin Gupta
6 * This code is released using a dual license strategy: BSD/GPL
7 * You can choose the license that better fits your requirements.
9 * Released under the terms of 3-clause BSD License
10 * Released under the terms of GNU General Public License Version 2.0
16 #include <linux/types.h>
19 * zsmalloc mapping modes
21 * NOTE: These only make a difference when a mapped object spans pages.
22 * They also have no effect when PGTABLE_MAPPING is selected.
25 ZS_MM_RW, /* normal read-write mapping */
26 ZS_MM_RO, /* read-only (no copy-out at unmap time) */
27 ZS_MM_WO /* write-only (no copy-in at map time) */
29 * NOTE: ZS_MM_WO should only be used for initializing new
30 * (uninitialized) allocations. Partial writes to already
31 * initialized allocations should use ZS_MM_RW to preserve the
38 struct zs_pool *zs_create_pool(gfp_t flags);
39 void zs_destroy_pool(struct zs_pool *pool);
41 unsigned long zs_malloc(struct zs_pool *pool, size_t size);
42 void zs_free(struct zs_pool *pool, unsigned long obj);
44 void *zs_map_object(struct zs_pool *pool, unsigned long handle,
46 void zs_unmap_object(struct zs_pool *pool, unsigned long handle);
48 u64 zs_get_total_size_bytes(struct zs_pool *pool);