| 1 | /* |
| 2 | * zsmalloc memory allocator |
| 3 | * |
| 4 | * Copyright (C) 2011 Nitin Gupta |
| 5 | * Copyright (C) 2012, 2013 Minchan Kim |
| 6 | * |
| 7 | * This code is released using a dual license strategy: BSD/GPL |
| 8 | * You can choose the license that better fits your requirements. |
| 9 | * |
| 10 | * Released under the terms of 3-clause BSD License |
| 11 | * Released under the terms of GNU General Public License Version 2.0 |
| 12 | */ |
| 13 | |
| 14 | #ifndef _ZS_MALLOC_H_ |
| 15 | #define _ZS_MALLOC_H_ |
| 16 | |
| 17 | #include <linux/types.h> |
| 18 | |
| 19 | struct zs_pool_stats { |
| 20 | /* How many pages were migrated (freed) */ |
| 21 | atomic_long_t pages_compacted; |
| 22 | }; |
| 23 | |
| 24 | struct zs_pool; |
| 25 | |
| 26 | struct zs_pool *zs_create_pool(const char *name); |
| 27 | void zs_destroy_pool(struct zs_pool *pool); |
| 28 | |
| 29 | unsigned long zs_malloc(struct zs_pool *pool, size_t size, gfp_t flags, |
| 30 | const int nid); |
| 31 | void zs_free(struct zs_pool *pool, unsigned long obj); |
| 32 | |
| 33 | size_t zs_huge_class_size(struct zs_pool *pool); |
| 34 | |
| 35 | unsigned long zs_get_total_pages(struct zs_pool *pool); |
| 36 | unsigned long zs_compact(struct zs_pool *pool); |
| 37 | |
| 38 | unsigned int zs_lookup_class_index(struct zs_pool *pool, unsigned int size); |
| 39 | |
| 40 | void zs_pool_stats(struct zs_pool *pool, struct zs_pool_stats *stats); |
| 41 | |
| 42 | void *zs_obj_read_begin(struct zs_pool *pool, unsigned long handle, |
| 43 | void *local_copy); |
| 44 | void zs_obj_read_end(struct zs_pool *pool, unsigned long handle, |
| 45 | void *handle_mem); |
| 46 | void zs_obj_write(struct zs_pool *pool, unsigned long handle, |
| 47 | void *handle_mem, size_t mem_len); |
| 48 | |
| 49 | #endif |
| 50 | |