Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm: remove unused zpool layer

With zswap using zsmalloc directly, there are no more in-tree users of
this code. Remove it.

With zpool gone, zsmalloc is now always a simple dependency and no
longer something the user needs to configure. Hide CONFIG_ZSMALLOC
from the user and have zswap and zram pull it in as needed.

Link: https://lkml.kernel.org/r/20250829162212.208258-3-hannes@cmpxchg.org
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: SeongJae Park <sj@kernel.org>
Acked-by: Yosry Ahmed <yosry.ahmed@linux.dev>
Cc: Chengming Zhou <zhouchengming@bytedance.com>
Cc: Nhat Pham <nphamcs@gmail.com>
Cc: Vitaly Wool <vitaly.wool@konsulko.se>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Johannes Weiner and committed by
Andrew Morton
2ccd9fec 5c3f8be0

+24 -561
+12 -21
Documentation/admin-guide/mm/zswap.rst
··· 53 53 evict pages from its own compressed pool on an LRU basis and write them back to 54 54 the backing swap device in the case that the compressed pool is full. 55 55 56 - Zswap makes use of zpool for the managing the compressed memory pool. Each 57 - allocation in zpool is not directly accessible by address. Rather, a handle is 56 + Zswap makes use of zsmalloc for the managing the compressed memory pool. Each 57 + allocation in zsmalloc is not directly accessible by address. Rather, a handle is 58 58 returned by the allocation routine and that handle must be mapped before being 59 59 accessed. The compressed memory pool grows on demand and shrinks as compressed 60 - pages are freed. The pool is not preallocated. By default, a zpool 61 - of type selected in ``CONFIG_ZSWAP_ZPOOL_DEFAULT`` Kconfig option is created, 62 - but it can be overridden at boot time by setting the ``zpool`` attribute, 63 - e.g. ``zswap.zpool=zsmalloc``. It can also be changed at runtime using the sysfs 64 - ``zpool`` attribute, e.g.:: 65 - 66 - echo zsmalloc > /sys/module/zswap/parameters/zpool 67 - 68 - The zsmalloc type zpool has a complex compressed page storage method, and it 69 - can achieve great storage densities. 60 + pages are freed. The pool is not preallocated. 70 61 71 62 When a swap page is passed from swapout to zswap, zswap maintains a mapping 72 - of the swap entry, a combination of the swap type and swap offset, to the zpool 73 - handle that references that compressed swap page. This mapping is achieved 74 - with a red-black tree per swap type. The swap offset is the search key for the 75 - tree nodes. 63 + of the swap entry, a combination of the swap type and swap offset, to the 64 + zsmalloc handle that references that compressed swap page. This mapping is 65 + achieved with a red-black tree per swap type. The swap offset is the search 66 + key for the tree nodes. 76 67 77 68 During a page fault on a PTE that is a swap entry, the swapin code calls the 78 69 zswap load function to decompress the page into the page allocated by the page ··· 87 96 88 97 echo lzo > /sys/module/zswap/parameters/compressor 89 98 90 - When the zpool and/or compressor parameter is changed at runtime, any existing 91 - compressed pages are not modified; they are left in their own zpool. When a 92 - request is made for a page in an old zpool, it is uncompressed using its 93 - original compressor. Once all pages are removed from an old zpool, the zpool 94 - and its compressor are freed. 99 + When the compressor parameter is changed at runtime, any existing compressed 100 + pages are not modified; they are left in their own pool. When a request is 101 + made for a page in an old pool, it is uncompressed using its original 102 + compressor. Once all pages are removed from an old pool, the pool and its 103 + compressor are freed. 95 104 96 105 Some of the pages in zswap are same-value filled pages (i.e. contents of the 97 106 page have same value or repetitive pattern). These pages include zero-filled
-1
Documentation/core-api/mm-api.rst
··· 118 118 .. kernel-doc:: mm/memremap.c 119 119 .. kernel-doc:: mm/hugetlb.c 120 120 .. kernel-doc:: mm/swap.c 121 - .. kernel-doc:: mm/zpool.c 122 121 .. kernel-doc:: mm/memcontrol.c 123 122 .. #kernel-doc:: mm/memory-tiers.c (build warnings) 124 123 .. kernel-doc:: mm/shmem.c
-2
Documentation/driver-api/crypto/iaa/iaa-crypto.rst
··· 476 476 # echo 0 > /sys/module/zswap/parameters/enabled 477 477 # echo 50 > /sys/module/zswap/parameters/max_pool_percent 478 478 # echo deflate-iaa > /sys/module/zswap/parameters/compressor 479 - # echo zsmalloc > /sys/module/zswap/parameters/zpool 480 479 # echo 1 > /sys/module/zswap/parameters/enabled 481 480 # echo 100 > /proc/sys/vm/swappiness 482 481 # echo never > /sys/kernel/mm/transparent_hugepage/enabled ··· 624 625 echo 0 > /sys/module/zswap/parameters/enabled 625 626 echo 50 > /sys/module/zswap/parameters/max_pool_percent 626 627 echo deflate-iaa > /sys/module/zswap/parameters/compressor 627 - echo zsmalloc > /sys/module/zswap/parameters/zpool 628 628 echo 1 > /sys/module/zswap/parameters/enabled 629 629 630 630 echo 100 > /proc/sys/vm/swappiness
-2
MAINTAINERS
··· 27879 27879 L: linux-mm@kvack.org 27880 27880 S: Maintained 27881 27881 F: Documentation/admin-guide/mm/zswap.rst 27882 - F: include/linux/zpool.h 27883 27882 F: include/linux/zswap.h 27884 - F: mm/zpool.c 27885 27883 F: mm/zswap.c 27886 27884 F: tools/testing/selftests/cgroup/test_zswap.c 27887 27885
-1
arch/loongarch/configs/loongson3_defconfig
··· 106 106 CONFIG_IOSCHED_BFQ=y 107 107 CONFIG_BFQ_GROUP_IOSCHED=y 108 108 CONFIG_BINFMT_MISC=m 109 - CONFIG_ZPOOL=y 110 109 CONFIG_ZSWAP=y 111 110 CONFIG_ZSWAP_COMPRESSOR_DEFAULT_ZSTD=y 112 111 CONFIG_ZSMALLOC=y
-86
include/linux/zpool.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - /* 3 - * zpool memory storage api 4 - * 5 - * Copyright (C) 2014 Dan Streetman 6 - * 7 - * This is a common frontend for the zswap compressed memory storage 8 - * implementations. 9 - */ 10 - 11 - #ifndef _ZPOOL_H_ 12 - #define _ZPOOL_H_ 13 - 14 - struct zpool; 15 - 16 - bool zpool_has_pool(char *type); 17 - 18 - struct zpool *zpool_create_pool(const char *type, const char *name, gfp_t gfp); 19 - 20 - const char *zpool_get_type(struct zpool *pool); 21 - 22 - void zpool_destroy_pool(struct zpool *pool); 23 - 24 - int zpool_malloc(struct zpool *pool, size_t size, gfp_t gfp, 25 - unsigned long *handle, const int nid); 26 - 27 - void zpool_free(struct zpool *pool, unsigned long handle); 28 - 29 - void *zpool_obj_read_begin(struct zpool *zpool, unsigned long handle, 30 - void *local_copy); 31 - 32 - void zpool_obj_read_end(struct zpool *zpool, unsigned long handle, 33 - void *handle_mem); 34 - 35 - void zpool_obj_write(struct zpool *zpool, unsigned long handle, 36 - void *handle_mem, size_t mem_len); 37 - 38 - u64 zpool_get_total_pages(struct zpool *pool); 39 - 40 - 41 - /** 42 - * struct zpool_driver - driver implementation for zpool 43 - * @type: name of the driver. 44 - * @list: entry in the list of zpool drivers. 45 - * @create: create a new pool. 46 - * @destroy: destroy a pool. 47 - * @malloc: allocate mem from a pool. 48 - * @free: free mem from a pool. 49 - * @sleep_mapped: whether zpool driver can sleep during map. 50 - * @map: map a handle. 51 - * @unmap: unmap a handle. 52 - * @total_size: get total size of a pool. 53 - * 54 - * This is created by a zpool implementation and registered 55 - * with zpool. 56 - */ 57 - struct zpool_driver { 58 - char *type; 59 - struct module *owner; 60 - atomic_t refcount; 61 - struct list_head list; 62 - 63 - void *(*create)(const char *name, gfp_t gfp); 64 - void (*destroy)(void *pool); 65 - 66 - int (*malloc)(void *pool, size_t size, gfp_t gfp, 67 - unsigned long *handle, const int nid); 68 - void (*free)(void *pool, unsigned long handle); 69 - 70 - void *(*obj_read_begin)(void *pool, unsigned long handle, 71 - void *local_copy); 72 - void (*obj_read_end)(void *pool, unsigned long handle, 73 - void *handle_mem); 74 - void (*obj_write)(void *pool, unsigned long handle, 75 - void *handle_mem, size_t mem_len); 76 - 77 - u64 (*total_pages)(void *pool); 78 - }; 79 - 80 - void zpool_register_driver(struct zpool_driver *driver); 81 - 82 - int zpool_unregister_driver(struct zpool_driver *driver); 83 - 84 - bool zpool_can_sleep_mapped(struct zpool *pool); 85 - 86 - #endif
+12 -39
mm/Kconfig
··· 9 9 config ARCH_NO_SWAP 10 10 bool 11 11 12 - config ZPOOL 13 - bool 14 - 15 12 menuconfig SWAP 16 13 bool "Support for paging of anonymous memory (swap)" 17 14 depends on MMU && BLOCK && !ARCH_NO_SWAP ··· 23 26 bool "Compressed cache for swap pages" 24 27 depends on SWAP 25 28 select CRYPTO 26 - select ZPOOL 29 + select ZSMALLOC 27 30 help 28 31 A lightweight compressed cache for swap pages. It takes 29 32 pages that are in the process of being swapped out and attempts to ··· 122 125 default "zstd" if ZSWAP_COMPRESSOR_DEFAULT_ZSTD 123 126 default "" 124 127 125 - choice 126 - prompt "Default allocator" 127 - depends on ZSWAP 128 - default ZSWAP_ZPOOL_DEFAULT_ZSMALLOC if MMU 129 - help 130 - Selects the default allocator for the compressed cache for 131 - swap pages. 132 - The default is 'zbud' for compatibility, however please do 133 - read the description of each of the allocators below before 134 - making a right choice. 135 - 136 - The selection made here can be overridden by using the kernel 137 - command line 'zswap.zpool=' option. 138 - 139 - config ZSWAP_ZPOOL_DEFAULT_ZSMALLOC 140 - bool "zsmalloc" 141 - select ZSMALLOC 142 - help 143 - Use the zsmalloc allocator as the default allocator. 144 - endchoice 145 - 146 - config ZSWAP_ZPOOL_DEFAULT 147 - string 148 - depends on ZSWAP 149 - default "zsmalloc" if ZSWAP_ZPOOL_DEFAULT_ZSMALLOC 150 - default "" 151 - 152 128 config ZSMALLOC 153 129 tristate 154 - prompt "N:1 compression allocator (zsmalloc)" if (ZSWAP || ZRAM) 155 - depends on MMU 156 - help 157 - zsmalloc is a slab-based memory allocator designed to store 158 - pages of various compression levels efficiently. It achieves 159 - the highest storage density with the least amount of fragmentation. 130 + 131 + if ZSMALLOC 132 + 133 + menu "Zsmalloc allocator options" 134 + depends on ZSMALLOC 135 + 136 + comment "Zsmalloc is a common backend allocator for zswap & zram" 160 137 161 138 config ZSMALLOC_STAT 162 139 bool "Export zsmalloc statistics" 163 - depends on ZSMALLOC 164 140 select DEBUG_FS 165 141 help 166 142 This option enables code in the zsmalloc to collect various ··· 145 175 int "Maximum number of physical pages per-zspage" 146 176 default 8 147 177 range 4 16 148 - depends on ZSMALLOC 149 178 help 150 179 This option sets the upper limit on the number of physical pages 151 180 that a zmalloc page (zspage) can consist of. The optimal zspage ··· 158 189 characteristics. 159 190 160 191 For more information, see zsmalloc documentation. 192 + 193 + endmenu 194 + 195 + endif 161 196 162 197 menu "Slab allocator options" 163 198
-1
mm/Makefile
··· 115 115 obj-$(CONFIG_DEBUG_VM_PGTABLE) += debug_vm_pgtable.o 116 116 obj-$(CONFIG_PAGE_OWNER) += page_owner.o 117 117 obj-$(CONFIG_MEMORY_ISOLATION) += page_isolation.o 118 - obj-$(CONFIG_ZPOOL) += zpool.o 119 118 obj-$(CONFIG_ZSMALLOC) += zsmalloc.o 120 119 obj-$(CONFIG_GENERIC_EARLY_IOREMAP) += early_ioremap.o 121 120 obj-$(CONFIG_CMA) += cma.o
-328
mm/zpool.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-only 2 - /* 3 - * zpool memory storage api 4 - * 5 - * Copyright (C) 2014 Dan Streetman 6 - * 7 - * This is a common frontend for memory storage pool implementations. 8 - * Typically, this is used to store compressed memory. 9 - */ 10 - 11 - #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 12 - 13 - #include <linux/list.h> 14 - #include <linux/types.h> 15 - #include <linux/mm.h> 16 - #include <linux/slab.h> 17 - #include <linux/spinlock.h> 18 - #include <linux/module.h> 19 - #include <linux/zpool.h> 20 - 21 - struct zpool { 22 - struct zpool_driver *driver; 23 - void *pool; 24 - }; 25 - 26 - static LIST_HEAD(drivers_head); 27 - static DEFINE_SPINLOCK(drivers_lock); 28 - 29 - /** 30 - * zpool_register_driver() - register a zpool implementation. 31 - * @driver: driver to register 32 - */ 33 - void zpool_register_driver(struct zpool_driver *driver) 34 - { 35 - spin_lock(&drivers_lock); 36 - atomic_set(&driver->refcount, 0); 37 - list_add(&driver->list, &drivers_head); 38 - spin_unlock(&drivers_lock); 39 - } 40 - EXPORT_SYMBOL(zpool_register_driver); 41 - 42 - /** 43 - * zpool_unregister_driver() - unregister a zpool implementation. 44 - * @driver: driver to unregister. 45 - * 46 - * Module usage counting is used to prevent using a driver 47 - * while/after unloading, so if this is called from module 48 - * exit function, this should never fail; if called from 49 - * other than the module exit function, and this returns 50 - * failure, the driver is in use and must remain available. 51 - */ 52 - int zpool_unregister_driver(struct zpool_driver *driver) 53 - { 54 - int ret = 0, refcount; 55 - 56 - spin_lock(&drivers_lock); 57 - refcount = atomic_read(&driver->refcount); 58 - WARN_ON(refcount < 0); 59 - if (refcount > 0) 60 - ret = -EBUSY; 61 - else 62 - list_del(&driver->list); 63 - spin_unlock(&drivers_lock); 64 - 65 - return ret; 66 - } 67 - EXPORT_SYMBOL(zpool_unregister_driver); 68 - 69 - /* this assumes @type is null-terminated. */ 70 - static struct zpool_driver *zpool_get_driver(const char *type) 71 - { 72 - struct zpool_driver *driver; 73 - 74 - spin_lock(&drivers_lock); 75 - list_for_each_entry(driver, &drivers_head, list) { 76 - if (!strcmp(driver->type, type)) { 77 - bool got = try_module_get(driver->owner); 78 - 79 - if (got) 80 - atomic_inc(&driver->refcount); 81 - spin_unlock(&drivers_lock); 82 - return got ? driver : NULL; 83 - } 84 - } 85 - 86 - spin_unlock(&drivers_lock); 87 - return NULL; 88 - } 89 - 90 - static void zpool_put_driver(struct zpool_driver *driver) 91 - { 92 - atomic_dec(&driver->refcount); 93 - module_put(driver->owner); 94 - } 95 - 96 - /** 97 - * zpool_has_pool() - Check if the pool driver is available 98 - * @type: The type of the zpool to check (e.g. zsmalloc) 99 - * 100 - * This checks if the @type pool driver is available. This will try to load 101 - * the requested module, if needed, but there is no guarantee the module will 102 - * still be loaded and available immediately after calling. If this returns 103 - * true, the caller should assume the pool is available, but must be prepared 104 - * to handle the @zpool_create_pool() returning failure. However if this 105 - * returns false, the caller should assume the requested pool type is not 106 - * available; either the requested pool type module does not exist, or could 107 - * not be loaded, and calling @zpool_create_pool() with the pool type will 108 - * fail. 109 - * 110 - * The @type string must be null-terminated. 111 - * 112 - * Returns: true if @type pool is available, false if not 113 - */ 114 - bool zpool_has_pool(char *type) 115 - { 116 - struct zpool_driver *driver = zpool_get_driver(type); 117 - 118 - if (!driver) { 119 - request_module("zpool-%s", type); 120 - driver = zpool_get_driver(type); 121 - } 122 - 123 - if (!driver) 124 - return false; 125 - 126 - zpool_put_driver(driver); 127 - return true; 128 - } 129 - EXPORT_SYMBOL(zpool_has_pool); 130 - 131 - /** 132 - * zpool_create_pool() - Create a new zpool 133 - * @type: The type of the zpool to create (e.g. zsmalloc) 134 - * @name: The name of the zpool (e.g. zram0, zswap) 135 - * @gfp: The GFP flags to use when allocating the pool. 136 - * 137 - * This creates a new zpool of the specified type. The gfp flags will be 138 - * used when allocating memory, if the implementation supports it. If the 139 - * ops param is NULL, then the created zpool will not be evictable. 140 - * 141 - * Implementations must guarantee this to be thread-safe. 142 - * 143 - * The @type and @name strings must be null-terminated. 144 - * 145 - * Returns: New zpool on success, NULL on failure. 146 - */ 147 - struct zpool *zpool_create_pool(const char *type, const char *name, gfp_t gfp) 148 - { 149 - struct zpool_driver *driver; 150 - struct zpool *zpool; 151 - 152 - pr_debug("creating pool type %s\n", type); 153 - 154 - driver = zpool_get_driver(type); 155 - 156 - if (!driver) { 157 - request_module("zpool-%s", type); 158 - driver = zpool_get_driver(type); 159 - } 160 - 161 - if (!driver) { 162 - pr_err("no driver for type %s\n", type); 163 - return NULL; 164 - } 165 - 166 - zpool = kmalloc(sizeof(*zpool), gfp); 167 - if (!zpool) { 168 - pr_err("couldn't create zpool - out of memory\n"); 169 - zpool_put_driver(driver); 170 - return NULL; 171 - } 172 - 173 - zpool->driver = driver; 174 - zpool->pool = driver->create(name, gfp); 175 - 176 - if (!zpool->pool) { 177 - pr_err("couldn't create %s pool\n", type); 178 - zpool_put_driver(driver); 179 - kfree(zpool); 180 - return NULL; 181 - } 182 - 183 - pr_debug("created pool type %s\n", type); 184 - 185 - return zpool; 186 - } 187 - 188 - /** 189 - * zpool_destroy_pool() - Destroy a zpool 190 - * @zpool: The zpool to destroy. 191 - * 192 - * Implementations must guarantee this to be thread-safe, 193 - * however only when destroying different pools. The same 194 - * pool should only be destroyed once, and should not be used 195 - * after it is destroyed. 196 - * 197 - * This destroys an existing zpool. The zpool should not be in use. 198 - */ 199 - void zpool_destroy_pool(struct zpool *zpool) 200 - { 201 - pr_debug("destroying pool type %s\n", zpool->driver->type); 202 - 203 - zpool->driver->destroy(zpool->pool); 204 - zpool_put_driver(zpool->driver); 205 - kfree(zpool); 206 - } 207 - 208 - /** 209 - * zpool_get_type() - Get the type of the zpool 210 - * @zpool: The zpool to check 211 - * 212 - * This returns the type of the pool. 213 - * 214 - * Implementations must guarantee this to be thread-safe. 215 - * 216 - * Returns: The type of zpool. 217 - */ 218 - const char *zpool_get_type(struct zpool *zpool) 219 - { 220 - return zpool->driver->type; 221 - } 222 - 223 - /** 224 - * zpool_malloc() - Allocate memory 225 - * @zpool: The zpool to allocate from. 226 - * @size: The amount of memory to allocate. 227 - * @gfp: The GFP flags to use when allocating memory. 228 - * @handle: Pointer to the handle to set 229 - * @nid: The preferred node id. 230 - * 231 - * This allocates the requested amount of memory from the pool. 232 - * The gfp flags will be used when allocating memory, if the 233 - * implementation supports it. The provided @handle will be 234 - * set to the allocated object handle. The allocation will 235 - * prefer the NUMA node specified by @nid. 236 - * 237 - * Implementations must guarantee this to be thread-safe. 238 - * 239 - * Returns: 0 on success, negative value on error. 240 - */ 241 - int zpool_malloc(struct zpool *zpool, size_t size, gfp_t gfp, 242 - unsigned long *handle, const int nid) 243 - { 244 - return zpool->driver->malloc(zpool->pool, size, gfp, handle, nid); 245 - } 246 - 247 - /** 248 - * zpool_free() - Free previously allocated memory 249 - * @zpool: The zpool that allocated the memory. 250 - * @handle: The handle to the memory to free. 251 - * 252 - * This frees previously allocated memory. This does not guarantee 253 - * that the pool will actually free memory, only that the memory 254 - * in the pool will become available for use by the pool. 255 - * 256 - * Implementations must guarantee this to be thread-safe, 257 - * however only when freeing different handles. The same 258 - * handle should only be freed once, and should not be used 259 - * after freeing. 260 - */ 261 - void zpool_free(struct zpool *zpool, unsigned long handle) 262 - { 263 - zpool->driver->free(zpool->pool, handle); 264 - } 265 - 266 - /** 267 - * zpool_obj_read_begin() - Start reading from a previously allocated handle. 268 - * @zpool: The zpool that the handle was allocated from 269 - * @handle: The handle to read from 270 - * @local_copy: A local buffer to use if needed. 271 - * 272 - * This starts a read operation of a previously allocated handle. The passed 273 - * @local_copy buffer may be used if needed by copying the memory into. 274 - * zpool_obj_read_end() MUST be called after the read is completed to undo any 275 - * actions taken (e.g. release locks). 276 - * 277 - * Returns: A pointer to the handle memory to be read, if @local_copy is used, 278 - * the returned pointer is @local_copy. 279 - */ 280 - void *zpool_obj_read_begin(struct zpool *zpool, unsigned long handle, 281 - void *local_copy) 282 - { 283 - return zpool->driver->obj_read_begin(zpool->pool, handle, local_copy); 284 - } 285 - 286 - /** 287 - * zpool_obj_read_end() - Finish reading from a previously allocated handle. 288 - * @zpool: The zpool that the handle was allocated from 289 - * @handle: The handle to read from 290 - * @handle_mem: The pointer returned by zpool_obj_read_begin() 291 - * 292 - * Finishes a read operation previously started by zpool_obj_read_begin(). 293 - */ 294 - void zpool_obj_read_end(struct zpool *zpool, unsigned long handle, 295 - void *handle_mem) 296 - { 297 - zpool->driver->obj_read_end(zpool->pool, handle, handle_mem); 298 - } 299 - 300 - /** 301 - * zpool_obj_write() - Write to a previously allocated handle. 302 - * @zpool: The zpool that the handle was allocated from 303 - * @handle: The handle to read from 304 - * @handle_mem: The memory to copy from into the handle. 305 - * @mem_len: The length of memory to be written. 306 - * 307 - */ 308 - void zpool_obj_write(struct zpool *zpool, unsigned long handle, 309 - void *handle_mem, size_t mem_len) 310 - { 311 - zpool->driver->obj_write(zpool->pool, handle, handle_mem, mem_len); 312 - } 313 - 314 - /** 315 - * zpool_get_total_pages() - The total size of the pool 316 - * @zpool: The zpool to check 317 - * 318 - * This returns the total size in pages of the pool. 319 - * 320 - * Returns: Total size of the zpool in pages. 321 - */ 322 - u64 zpool_get_total_pages(struct zpool *zpool) 323 - { 324 - return zpool->driver->total_pages(zpool->pool); 325 - } 326 - 327 - MODULE_AUTHOR("Dan Streetman <ddstreet@ieee.org>"); 328 - MODULE_DESCRIPTION("Common API for compressed memory storage");
-79
mm/zsmalloc.c
··· 36 36 #include <linux/types.h> 37 37 #include <linux/debugfs.h> 38 38 #include <linux/zsmalloc.h> 39 - #include <linux/zpool.h> 40 39 #include <linux/fs.h> 41 40 #include <linux/workqueue.h> 42 41 #include "zpdesc.h" ··· 431 432 { 432 433 *(unsigned long *)handle = obj; 433 434 } 434 - 435 - /* zpool driver */ 436 - 437 - #ifdef CONFIG_ZPOOL 438 - 439 - static void *zs_zpool_create(const char *name, gfp_t gfp) 440 - { 441 - /* 442 - * Ignore global gfp flags: zs_malloc() may be invoked from 443 - * different contexts and its caller must provide a valid 444 - * gfp mask. 445 - */ 446 - return zs_create_pool(name); 447 - } 448 - 449 - static void zs_zpool_destroy(void *pool) 450 - { 451 - zs_destroy_pool(pool); 452 - } 453 - 454 - static int zs_zpool_malloc(void *pool, size_t size, gfp_t gfp, 455 - unsigned long *handle, const int nid) 456 - { 457 - *handle = zs_malloc(pool, size, gfp, nid); 458 - 459 - if (IS_ERR_VALUE(*handle)) 460 - return PTR_ERR((void *)*handle); 461 - return 0; 462 - } 463 - static void zs_zpool_free(void *pool, unsigned long handle) 464 - { 465 - zs_free(pool, handle); 466 - } 467 - 468 - static void *zs_zpool_obj_read_begin(void *pool, unsigned long handle, 469 - void *local_copy) 470 - { 471 - return zs_obj_read_begin(pool, handle, local_copy); 472 - } 473 - 474 - static void zs_zpool_obj_read_end(void *pool, unsigned long handle, 475 - void *handle_mem) 476 - { 477 - zs_obj_read_end(pool, handle, handle_mem); 478 - } 479 - 480 - static void zs_zpool_obj_write(void *pool, unsigned long handle, 481 - void *handle_mem, size_t mem_len) 482 - { 483 - zs_obj_write(pool, handle, handle_mem, mem_len); 484 - } 485 - 486 - static u64 zs_zpool_total_pages(void *pool) 487 - { 488 - return zs_get_total_pages(pool); 489 - } 490 - 491 - static struct zpool_driver zs_zpool_driver = { 492 - .type = "zsmalloc", 493 - .owner = THIS_MODULE, 494 - .create = zs_zpool_create, 495 - .destroy = zs_zpool_destroy, 496 - .malloc = zs_zpool_malloc, 497 - .free = zs_zpool_free, 498 - .obj_read_begin = zs_zpool_obj_read_begin, 499 - .obj_read_end = zs_zpool_obj_read_end, 500 - .obj_write = zs_zpool_obj_write, 501 - .total_pages = zs_zpool_total_pages, 502 - }; 503 - 504 - MODULE_ALIAS("zpool-zsmalloc"); 505 - #endif /* CONFIG_ZPOOL */ 506 435 507 436 static inline bool __maybe_unused is_first_zpdesc(struct zpdesc *zpdesc) 508 437 { ··· 2175 2248 { 2176 2249 int rc __maybe_unused; 2177 2250 2178 - #ifdef CONFIG_ZPOOL 2179 - zpool_register_driver(&zs_zpool_driver); 2180 - #endif 2181 2251 #ifdef CONFIG_COMPACTION 2182 2252 rc = set_movable_ops(&zsmalloc_mops, PGTY_zsmalloc); 2183 2253 if (rc) ··· 2186 2262 2187 2263 static void __exit zs_exit(void) 2188 2264 { 2189 - #ifdef CONFIG_ZPOOL 2190 - zpool_unregister_driver(&zs_zpool_driver); 2191 - #endif 2192 2265 #ifdef CONFIG_COMPACTION 2193 2266 set_movable_ops(NULL, PGTY_zsmalloc); 2194 2267 #endif
-1
tools/testing/selftests/zram/README
··· 14 14 Kconfig required: 15 15 CONFIG_ZRAM=y 16 16 CONFIG_CRYPTO_LZ4=y 17 - CONFIG_ZPOOL=y 18 17 CONFIG_ZSMALLOC=y 19 18 20 19 ZRAM Testcases