Lines Matching +full:memory +full:- +full:mapped

1 // SPDX-License-Identifier: GPL-2.0-only
3 * zpool memory storage api
7 * This is a common frontend for memory storage pool implementations.
8 * Typically, this is used to store compressed memory.
37 * zpool_register_driver() - register a zpool implementation.
43 atomic_set(&driver->refcount, 0); in zpool_register_driver()
44 list_add(&driver->list, &drivers_head); in zpool_register_driver()
50 * zpool_unregister_driver() - unregister a zpool implementation.
64 refcount = atomic_read(&driver->refcount); in zpool_unregister_driver()
67 ret = -EBUSY; in zpool_unregister_driver()
69 list_del(&driver->list); in zpool_unregister_driver()
76 /* this assumes @type is null-terminated. */
83 if (!strcmp(driver->type, type)) { in zpool_get_driver()
84 bool got = try_module_get(driver->owner); in zpool_get_driver()
87 atomic_inc(&driver->refcount); in zpool_get_driver()
99 atomic_dec(&driver->refcount); in zpool_put_driver()
100 module_put(driver->owner); in zpool_put_driver()
104 * zpool_has_pool() - Check if the pool driver is available
117 * The @type string must be null-terminated.
126 request_module("zpool-%s", type); in zpool_has_pool()
139 * zpool_create_pool() - Create a new zpool
146 * used when allocating memory, if the implementation supports it. If the
149 * Implementations must guarantee this to be thread-safe.
151 * The @type and @name strings must be null-terminated.
166 request_module("zpool-%s", type); in zpool_create_pool()
177 pr_err("couldn't create zpool - out of memory\n"); in zpool_create_pool()
182 zpool->driver = driver; in zpool_create_pool()
183 zpool->pool = driver->create(name, gfp, ops, zpool); in zpool_create_pool()
184 zpool->ops = ops; in zpool_create_pool()
185 zpool->evictable = driver->shrink && ops && ops->evict; in zpool_create_pool()
187 if (!zpool->pool) { in zpool_create_pool()
197 list_add(&zpool->list, &pools_head); in zpool_create_pool()
204 * zpool_destroy_pool() - Destroy a zpool
207 * Implementations must guarantee this to be thread-safe,
216 pr_debug("destroying pool type %s\n", zpool->driver->type); in zpool_destroy_pool()
219 list_del(&zpool->list); in zpool_destroy_pool()
221 zpool->driver->destroy(zpool->pool); in zpool_destroy_pool()
222 zpool_put_driver(zpool->driver); in zpool_destroy_pool()
227 * zpool_get_type() - Get the type of the zpool
232 * Implementations must guarantee this to be thread-safe.
238 return zpool->driver->type; in zpool_get_type()
242 * zpool_malloc_support_movable() - Check if the zpool supports
243 * allocating movable memory
246 * This returns if the zpool supports allocating movable memory.
248 * Implementations must guarantee this to be thread-safe.
250 * Returns: true if the zpool supports allocating movable memory, false if not
254 return zpool->driver->malloc_support_movable; in zpool_malloc_support_movable()
258 * zpool_malloc() - Allocate memory
260 * @size: The amount of memory to allocate.
261 * @gfp: The GFP flags to use when allocating memory.
264 * This allocates the requested amount of memory from the pool.
265 * The gfp flags will be used when allocating memory, if the
269 * Implementations must guarantee this to be thread-safe.
276 return zpool->driver->malloc(zpool->pool, size, gfp, handle); in zpool_malloc()
280 * zpool_free() - Free previously allocated memory
281 * @zpool: The zpool that allocated the memory.
282 * @handle: The handle to the memory to free.
284 * This frees previously allocated memory. This does not guarantee
285 * that the pool will actually free memory, only that the memory
288 * Implementations must guarantee this to be thread-safe,
295 zpool->driver->free(zpool->pool, handle); in zpool_free()
299 * zpool_shrink() - Shrink the pool size
304 * This attempts to shrink the actual memory size of the pool
307 * of the handles, this will fail. If non-NULL, the @reclaimed
311 * Implementations must guarantee this to be thread-safe.
318 return zpool->driver->shrink ? in zpool_shrink()
319 zpool->driver->shrink(zpool->pool, pages, reclaimed) : -EINVAL; in zpool_shrink()
323 * zpool_map_handle() - Map a previously allocated handle into memory
326 * @mapmode: How the memory should be mapped
328 * This maps a previously allocated handle into memory. The @mapmode
329 * param indicates to the implementation how the memory will be
330 * used, i.e. read-only, write-only, read-write. If the
331 * implementation does not support it, the memory will be treated
332 * as read-write.
336 * actions. The code that uses the mapped handle should complete
337 * its operatons on the mapped handle memory quickly and unmap
338 * as soon as possible. As the implementation may use per-cpu
339 * data, multiple handles should not be mapped concurrently on
342 * Returns: A pointer to the handle's mapped memory area.
347 return zpool->driver->map(zpool->pool, handle, mapmode); in zpool_map_handle()
351 * zpool_unmap_handle() - Unmap a previously mapped handle
355 * This unmaps a previously mapped handle. Any locks or other
357 * will be undone here. The memory area returned from
362 zpool->driver->unmap(zpool->pool, handle); in zpool_unmap_handle()
366 * zpool_get_total_size() - The total size of the pool
375 return zpool->driver->total_size(zpool->pool); in zpool_get_total_size()
379 * zpool_evictable() - Test if zpool is potentially evictable
393 return zpool->evictable; in zpool_evictable()
398 MODULE_DESCRIPTION("Common API for compressed memory storage");