zswap.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314
  1. /*
  2. * zswap.c - zswap driver file
  3. *
  4. * zswap is a backend for frontswap that takes pages that are in the process
  5. * of being swapped out and attempts to compress and store them in a
  6. * RAM-based memory pool. This can result in a significant I/O reduction on
  7. * the swap device and, in the case where decompressing from RAM is faster
  8. * than reading from the swap device, can also improve workload performance.
  9. *
  10. * Copyright (C) 2012 Seth Jennings <sjenning@linux.vnet.ibm.com>
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License
  14. * as published by the Free Software Foundation; either version 2
  15. * of the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. */
  22. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  23. #include <linux/module.h>
  24. #include <linux/cpu.h>
  25. #include <linux/highmem.h>
  26. #include <linux/slab.h>
  27. #include <linux/spinlock.h>
  28. #include <linux/types.h>
  29. #include <linux/atomic.h>
  30. #include <linux/frontswap.h>
  31. #include <linux/rbtree.h>
  32. #include <linux/swap.h>
  33. #include <linux/crypto.h>
  34. #include <linux/mempool.h>
  35. #include <linux/zpool.h>
  36. #include <linux/mm_types.h>
  37. #include <linux/page-flags.h>
  38. #include <linux/swapops.h>
  39. #include <linux/writeback.h>
  40. #include <linux/pagemap.h>
  41. /*********************************
  42. * statistics
  43. **********************************/
  44. /* Total bytes used by the compressed storage */
  45. static u64 zswap_pool_total_size;
  46. /* The number of compressed pages currently stored in zswap */
  47. static atomic_t zswap_stored_pages = ATOMIC_INIT(0);
  48. /*
  49. * The statistics below are not protected from concurrent access for
  50. * performance reasons so they may not be a 100% accurate. However,
  51. * they do provide useful information on roughly how many times a
  52. * certain event is occurring.
  53. */
  54. /* Pool limit was hit (see zswap_max_pool_percent) */
  55. static u64 zswap_pool_limit_hit;
  56. /* Pages written back when pool limit was reached */
  57. static u64 zswap_written_back_pages;
  58. /* Store failed due to a reclaim failure after pool limit was reached */
  59. static u64 zswap_reject_reclaim_fail;
  60. /* Compressed page was too big for the allocator to (optimally) store */
  61. static u64 zswap_reject_compress_poor;
  62. /* Store failed because underlying allocator could not get memory */
  63. static u64 zswap_reject_alloc_fail;
  64. /* Store failed because the entry metadata could not be allocated (rare) */
  65. static u64 zswap_reject_kmemcache_fail;
  66. /* Duplicate store was encountered (rare) */
  67. static u64 zswap_duplicate_entry;
  68. /*********************************
  69. * tunables
  70. **********************************/
  71. /* Enable/disable zswap (disabled by default) */
  72. static bool zswap_enabled;
  73. static int zswap_enabled_param_set(const char *,
  74. const struct kernel_param *);
  75. static struct kernel_param_ops zswap_enabled_param_ops = {
  76. .set = zswap_enabled_param_set,
  77. .get = param_get_bool,
  78. };
  79. module_param_cb(enabled, &zswap_enabled_param_ops, &zswap_enabled, 0644);
  80. /* Crypto compressor to use */
  81. #define ZSWAP_COMPRESSOR_DEFAULT "lzo"
  82. static char *zswap_compressor = ZSWAP_COMPRESSOR_DEFAULT;
  83. static int zswap_compressor_param_set(const char *,
  84. const struct kernel_param *);
  85. static struct kernel_param_ops zswap_compressor_param_ops = {
  86. .set = zswap_compressor_param_set,
  87. .get = param_get_charp,
  88. .free = param_free_charp,
  89. };
  90. module_param_cb(compressor, &zswap_compressor_param_ops,
  91. &zswap_compressor, 0644);
  92. /* Compressed storage zpool to use */
  93. #define ZSWAP_ZPOOL_DEFAULT "zbud"
  94. static char *zswap_zpool_type = ZSWAP_ZPOOL_DEFAULT;
  95. static int zswap_zpool_param_set(const char *, const struct kernel_param *);
  96. static struct kernel_param_ops zswap_zpool_param_ops = {
  97. .set = zswap_zpool_param_set,
  98. .get = param_get_charp,
  99. .free = param_free_charp,
  100. };
  101. module_param_cb(zpool, &zswap_zpool_param_ops, &zswap_zpool_type, 0644);
  102. /* The maximum percentage of memory that the compressed pool can occupy */
  103. static unsigned int zswap_max_pool_percent = 20;
  104. module_param_named(max_pool_percent, zswap_max_pool_percent, uint, 0644);
  105. /*********************************
  106. * data structures
  107. **********************************/
  108. struct zswap_pool {
  109. struct zpool *zpool;
  110. struct crypto_comp * __percpu *tfm;
  111. struct kref kref;
  112. struct list_head list;
  113. struct work_struct work;
  114. struct notifier_block notifier;
  115. char tfm_name[CRYPTO_MAX_ALG_NAME];
  116. };
  117. /*
  118. * struct zswap_entry
  119. *
  120. * This structure contains the metadata for tracking a single compressed
  121. * page within zswap.
  122. *
  123. * rbnode - links the entry into red-black tree for the appropriate swap type
  124. * offset - the swap offset for the entry. Index into the red-black tree.
  125. * refcount - the number of outstanding reference to the entry. This is needed
  126. * to protect against premature freeing of the entry by code
  127. * concurrent calls to load, invalidate, and writeback. The lock
  128. * for the zswap_tree structure that contains the entry must
  129. * be held while changing the refcount. Since the lock must
  130. * be held, there is no reason to also make refcount atomic.
  131. * length - the length in bytes of the compressed page data. Needed during
  132. * decompression
  133. * pool - the zswap_pool the entry's data is in
  134. * handle - zpool allocation handle that stores the compressed page data
  135. */
  136. struct zswap_entry {
  137. struct rb_node rbnode;
  138. pgoff_t offset;
  139. int refcount;
  140. unsigned int length;
  141. struct zswap_pool *pool;
  142. unsigned long handle;
  143. };
  144. struct zswap_header {
  145. swp_entry_t swpentry;
  146. };
  147. /*
  148. * The tree lock in the zswap_tree struct protects a few things:
  149. * - the rbtree
  150. * - the refcount field of each entry in the tree
  151. */
  152. struct zswap_tree {
  153. struct rb_root rbroot;
  154. spinlock_t lock;
  155. };
  156. static struct zswap_tree *zswap_trees[MAX_SWAPFILES];
  157. /* RCU-protected iteration */
  158. static LIST_HEAD(zswap_pools);
  159. /* protects zswap_pools list modification */
  160. static DEFINE_SPINLOCK(zswap_pools_lock);
  161. /* pool counter to provide unique names to zpool */
  162. static atomic_t zswap_pools_count = ATOMIC_INIT(0);
  163. /* used by param callback function */
  164. static bool zswap_init_started;
  165. /* fatal error during init */
  166. static bool zswap_init_failed;
  167. /*********************************
  168. * helpers and fwd declarations
  169. **********************************/
  170. #define zswap_pool_debug(msg, p) \
  171. pr_debug("%s pool %s/%s\n", msg, (p)->tfm_name, \
  172. zpool_get_type((p)->zpool))
  173. static int zswap_writeback_entry(struct zpool *pool, unsigned long handle);
  174. static int zswap_pool_get(struct zswap_pool *pool);
  175. static void zswap_pool_put(struct zswap_pool *pool);
  176. static const struct zpool_ops zswap_zpool_ops = {
  177. .evict = zswap_writeback_entry
  178. };
  179. static bool zswap_is_full(void)
  180. {
  181. return totalram_pages * zswap_max_pool_percent / 100 <
  182. DIV_ROUND_UP(zswap_pool_total_size, PAGE_SIZE);
  183. }
  184. static void zswap_update_total_size(void)
  185. {
  186. struct zswap_pool *pool;
  187. u64 total = 0;
  188. rcu_read_lock();
  189. list_for_each_entry_rcu(pool, &zswap_pools, list)
  190. total += zpool_get_total_size(pool->zpool);
  191. rcu_read_unlock();
  192. zswap_pool_total_size = total;
  193. }
  194. /*********************************
  195. * zswap entry functions
  196. **********************************/
  197. static struct kmem_cache *zswap_entry_cache;
  198. static int __init zswap_entry_cache_create(void)
  199. {
  200. zswap_entry_cache = KMEM_CACHE(zswap_entry, 0);
  201. return zswap_entry_cache == NULL;
  202. }
  203. static void __init zswap_entry_cache_destroy(void)
  204. {
  205. kmem_cache_destroy(zswap_entry_cache);
  206. }
  207. static struct zswap_entry *zswap_entry_cache_alloc(gfp_t gfp)
  208. {
  209. struct zswap_entry *entry;
  210. entry = kmem_cache_alloc(zswap_entry_cache, gfp);
  211. if (!entry)
  212. return NULL;
  213. entry->refcount = 1;
  214. RB_CLEAR_NODE(&entry->rbnode);
  215. return entry;
  216. }
  217. static void zswap_entry_cache_free(struct zswap_entry *entry)
  218. {
  219. kmem_cache_free(zswap_entry_cache, entry);
  220. }
  221. /*********************************
  222. * rbtree functions
  223. **********************************/
  224. static struct zswap_entry *zswap_rb_search(struct rb_root *root, pgoff_t offset)
  225. {
  226. struct rb_node *node = root->rb_node;
  227. struct zswap_entry *entry;
  228. while (node) {
  229. entry = rb_entry(node, struct zswap_entry, rbnode);
  230. if (entry->offset > offset)
  231. node = node->rb_left;
  232. else if (entry->offset < offset)
  233. node = node->rb_right;
  234. else
  235. return entry;
  236. }
  237. return NULL;
  238. }
  239. /*
  240. * In the case that a entry with the same offset is found, a pointer to
  241. * the existing entry is stored in dupentry and the function returns -EEXIST
  242. */
  243. static int zswap_rb_insert(struct rb_root *root, struct zswap_entry *entry,
  244. struct zswap_entry **dupentry)
  245. {
  246. struct rb_node **link = &root->rb_node, *parent = NULL;
  247. struct zswap_entry *myentry;
  248. while (*link) {
  249. parent = *link;
  250. myentry = rb_entry(parent, struct zswap_entry, rbnode);
  251. if (myentry->offset > entry->offset)
  252. link = &(*link)->rb_left;
  253. else if (myentry->offset < entry->offset)
  254. link = &(*link)->rb_right;
  255. else {
  256. *dupentry = myentry;
  257. return -EEXIST;
  258. }
  259. }
  260. rb_link_node(&entry->rbnode, parent, link);
  261. rb_insert_color(&entry->rbnode, root);
  262. return 0;
  263. }
  264. static void zswap_rb_erase(struct rb_root *root, struct zswap_entry *entry)
  265. {
  266. if (!RB_EMPTY_NODE(&entry->rbnode)) {
  267. rb_erase(&entry->rbnode, root);
  268. RB_CLEAR_NODE(&entry->rbnode);
  269. }
  270. }
  271. /*
  272. * Carries out the common pattern of freeing and entry's zpool allocation,
  273. * freeing the entry itself, and decrementing the number of stored pages.
  274. */
  275. static void zswap_free_entry(struct zswap_entry *entry)
  276. {
  277. zpool_free(entry->pool->zpool, entry->handle);
  278. zswap_pool_put(entry->pool);
  279. zswap_entry_cache_free(entry);
  280. atomic_dec(&zswap_stored_pages);
  281. zswap_update_total_size();
  282. }
  283. /* caller must hold the tree lock */
  284. static void zswap_entry_get(struct zswap_entry *entry)
  285. {
  286. entry->refcount++;
  287. }
  288. /* caller must hold the tree lock
  289. * remove from the tree and free it, if nobody reference the entry
  290. */
  291. static void zswap_entry_put(struct zswap_tree *tree,
  292. struct zswap_entry *entry)
  293. {
  294. int refcount = --entry->refcount;
  295. BUG_ON(refcount < 0);
  296. if (refcount == 0) {
  297. zswap_rb_erase(&tree->rbroot, entry);
  298. zswap_free_entry(entry);
  299. }
  300. }
  301. /* caller must hold the tree lock */
  302. static struct zswap_entry *zswap_entry_find_get(struct rb_root *root,
  303. pgoff_t offset)
  304. {
  305. struct zswap_entry *entry;
  306. entry = zswap_rb_search(root, offset);
  307. if (entry)
  308. zswap_entry_get(entry);
  309. return entry;
  310. }
  311. /*********************************
  312. * per-cpu code
  313. **********************************/
  314. static DEFINE_PER_CPU(u8 *, zswap_dstmem);
  315. static int __zswap_cpu_dstmem_notifier(unsigned long action, unsigned long cpu)
  316. {
  317. u8 *dst;
  318. switch (action) {
  319. case CPU_UP_PREPARE:
  320. dst = kmalloc_node(PAGE_SIZE * 2, GFP_KERNEL, cpu_to_node(cpu));
  321. if (!dst) {
  322. pr_err("can't allocate compressor buffer\n");
  323. return NOTIFY_BAD;
  324. }
  325. per_cpu(zswap_dstmem, cpu) = dst;
  326. break;
  327. case CPU_DEAD:
  328. case CPU_UP_CANCELED:
  329. dst = per_cpu(zswap_dstmem, cpu);
  330. kfree(dst);
  331. per_cpu(zswap_dstmem, cpu) = NULL;
  332. break;
  333. default:
  334. break;
  335. }
  336. return NOTIFY_OK;
  337. }
  338. static int zswap_cpu_dstmem_notifier(struct notifier_block *nb,
  339. unsigned long action, void *pcpu)
  340. {
  341. return __zswap_cpu_dstmem_notifier(action, (unsigned long)pcpu);
  342. }
  343. static struct notifier_block zswap_dstmem_notifier = {
  344. .notifier_call = zswap_cpu_dstmem_notifier,
  345. };
  346. static int __init zswap_cpu_dstmem_init(void)
  347. {
  348. unsigned long cpu;
  349. cpu_notifier_register_begin();
  350. for_each_online_cpu(cpu)
  351. if (__zswap_cpu_dstmem_notifier(CPU_UP_PREPARE, cpu) ==
  352. NOTIFY_BAD)
  353. goto cleanup;
  354. __register_cpu_notifier(&zswap_dstmem_notifier);
  355. cpu_notifier_register_done();
  356. return 0;
  357. cleanup:
  358. for_each_online_cpu(cpu)
  359. __zswap_cpu_dstmem_notifier(CPU_UP_CANCELED, cpu);
  360. cpu_notifier_register_done();
  361. return -ENOMEM;
  362. }
  363. static void zswap_cpu_dstmem_destroy(void)
  364. {
  365. unsigned long cpu;
  366. cpu_notifier_register_begin();
  367. for_each_online_cpu(cpu)
  368. __zswap_cpu_dstmem_notifier(CPU_UP_CANCELED, cpu);
  369. __unregister_cpu_notifier(&zswap_dstmem_notifier);
  370. cpu_notifier_register_done();
  371. }
  372. static int __zswap_cpu_comp_notifier(struct zswap_pool *pool,
  373. unsigned long action, unsigned long cpu)
  374. {
  375. struct crypto_comp *tfm;
  376. switch (action) {
  377. case CPU_UP_PREPARE:
  378. if (WARN_ON(*per_cpu_ptr(pool->tfm, cpu)))
  379. break;
  380. tfm = crypto_alloc_comp(pool->tfm_name, 0, 0);
  381. if (IS_ERR_OR_NULL(tfm)) {
  382. pr_err("could not alloc crypto comp %s : %ld\n",
  383. pool->tfm_name, PTR_ERR(tfm));
  384. return NOTIFY_BAD;
  385. }
  386. *per_cpu_ptr(pool->tfm, cpu) = tfm;
  387. break;
  388. case CPU_DEAD:
  389. case CPU_UP_CANCELED:
  390. tfm = *per_cpu_ptr(pool->tfm, cpu);
  391. if (!IS_ERR_OR_NULL(tfm))
  392. crypto_free_comp(tfm);
  393. *per_cpu_ptr(pool->tfm, cpu) = NULL;
  394. break;
  395. default:
  396. break;
  397. }
  398. return NOTIFY_OK;
  399. }
  400. static int zswap_cpu_comp_notifier(struct notifier_block *nb,
  401. unsigned long action, void *pcpu)
  402. {
  403. unsigned long cpu = (unsigned long)pcpu;
  404. struct zswap_pool *pool = container_of(nb, typeof(*pool), notifier);
  405. return __zswap_cpu_comp_notifier(pool, action, cpu);
  406. }
  407. static int zswap_cpu_comp_init(struct zswap_pool *pool)
  408. {
  409. unsigned long cpu;
  410. memset(&pool->notifier, 0, sizeof(pool->notifier));
  411. pool->notifier.notifier_call = zswap_cpu_comp_notifier;
  412. cpu_notifier_register_begin();
  413. for_each_online_cpu(cpu)
  414. if (__zswap_cpu_comp_notifier(pool, CPU_UP_PREPARE, cpu) ==
  415. NOTIFY_BAD)
  416. goto cleanup;
  417. __register_cpu_notifier(&pool->notifier);
  418. cpu_notifier_register_done();
  419. return 0;
  420. cleanup:
  421. for_each_online_cpu(cpu)
  422. __zswap_cpu_comp_notifier(pool, CPU_UP_CANCELED, cpu);
  423. cpu_notifier_register_done();
  424. return -ENOMEM;
  425. }
  426. static void zswap_cpu_comp_destroy(struct zswap_pool *pool)
  427. {
  428. unsigned long cpu;
  429. cpu_notifier_register_begin();
  430. for_each_online_cpu(cpu)
  431. __zswap_cpu_comp_notifier(pool, CPU_UP_CANCELED, cpu);
  432. __unregister_cpu_notifier(&pool->notifier);
  433. cpu_notifier_register_done();
  434. }
  435. /*********************************
  436. * pool functions
  437. **********************************/
  438. static struct zswap_pool *__zswap_pool_current(void)
  439. {
  440. struct zswap_pool *pool;
  441. pool = list_first_or_null_rcu(&zswap_pools, typeof(*pool), list);
  442. WARN_ON(!pool);
  443. return pool;
  444. }
  445. static struct zswap_pool *zswap_pool_current(void)
  446. {
  447. assert_spin_locked(&zswap_pools_lock);
  448. return __zswap_pool_current();
  449. }
  450. static struct zswap_pool *zswap_pool_current_get(void)
  451. {
  452. struct zswap_pool *pool;
  453. rcu_read_lock();
  454. pool = __zswap_pool_current();
  455. if (!pool || !zswap_pool_get(pool))
  456. pool = NULL;
  457. rcu_read_unlock();
  458. return pool;
  459. }
  460. static struct zswap_pool *zswap_pool_last_get(void)
  461. {
  462. struct zswap_pool *pool, *last = NULL;
  463. rcu_read_lock();
  464. list_for_each_entry_rcu(pool, &zswap_pools, list)
  465. last = pool;
  466. if (!WARN_ON(!last) && !zswap_pool_get(last))
  467. last = NULL;
  468. rcu_read_unlock();
  469. return last;
  470. }
  471. /* type and compressor must be null-terminated */
  472. static struct zswap_pool *zswap_pool_find_get(char *type, char *compressor)
  473. {
  474. struct zswap_pool *pool;
  475. assert_spin_locked(&zswap_pools_lock);
  476. list_for_each_entry_rcu(pool, &zswap_pools, list) {
  477. if (strcmp(pool->tfm_name, compressor))
  478. continue;
  479. if (strcmp(zpool_get_type(pool->zpool), type))
  480. continue;
  481. /* if we can't get it, it's about to be destroyed */
  482. if (!zswap_pool_get(pool))
  483. continue;
  484. return pool;
  485. }
  486. return NULL;
  487. }
  488. static struct zswap_pool *zswap_pool_create(char *type, char *compressor)
  489. {
  490. struct zswap_pool *pool;
  491. char name[38]; /* 'zswap' + 32 char (max) num + \0 */
  492. gfp_t gfp = __GFP_NORETRY | __GFP_NOWARN | __GFP_KSWAPD_RECLAIM;
  493. pool = kzalloc(sizeof(*pool), GFP_KERNEL);
  494. if (!pool) {
  495. pr_err("pool alloc failed\n");
  496. return NULL;
  497. }
  498. /* unique name for each pool specifically required by zsmalloc */
  499. snprintf(name, 38, "zswap%x", atomic_inc_return(&zswap_pools_count));
  500. pool->zpool = zpool_create_pool(type, name, gfp, &zswap_zpool_ops);
  501. if (!pool->zpool) {
  502. pr_err("%s zpool not available\n", type);
  503. goto error;
  504. }
  505. pr_debug("using %s zpool\n", zpool_get_type(pool->zpool));
  506. strlcpy(pool->tfm_name, compressor, sizeof(pool->tfm_name));
  507. pool->tfm = alloc_percpu(struct crypto_comp *);
  508. if (!pool->tfm) {
  509. pr_err("percpu alloc failed\n");
  510. goto error;
  511. }
  512. if (zswap_cpu_comp_init(pool))
  513. goto error;
  514. pr_debug("using %s compressor\n", pool->tfm_name);
  515. /* being the current pool takes 1 ref; this func expects the
  516. * caller to always add the new pool as the current pool
  517. */
  518. kref_init(&pool->kref);
  519. INIT_LIST_HEAD(&pool->list);
  520. zswap_pool_debug("created", pool);
  521. return pool;
  522. error:
  523. free_percpu(pool->tfm);
  524. if (pool->zpool)
  525. zpool_destroy_pool(pool->zpool);
  526. kfree(pool);
  527. return NULL;
  528. }
  529. static __init struct zswap_pool *__zswap_pool_create_fallback(void)
  530. {
  531. if (!crypto_has_comp(zswap_compressor, 0, 0)) {
  532. if (!strcmp(zswap_compressor, ZSWAP_COMPRESSOR_DEFAULT)) {
  533. pr_err("default compressor %s not available\n",
  534. zswap_compressor);
  535. return NULL;
  536. }
  537. pr_err("compressor %s not available, using default %s\n",
  538. zswap_compressor, ZSWAP_COMPRESSOR_DEFAULT);
  539. param_free_charp(&zswap_compressor);
  540. zswap_compressor = ZSWAP_COMPRESSOR_DEFAULT;
  541. }
  542. if (!zpool_has_pool(zswap_zpool_type)) {
  543. if (!strcmp(zswap_zpool_type, ZSWAP_ZPOOL_DEFAULT)) {
  544. pr_err("default zpool %s not available\n",
  545. zswap_zpool_type);
  546. return NULL;
  547. }
  548. pr_err("zpool %s not available, using default %s\n",
  549. zswap_zpool_type, ZSWAP_ZPOOL_DEFAULT);
  550. param_free_charp(&zswap_zpool_type);
  551. zswap_zpool_type = ZSWAP_ZPOOL_DEFAULT;
  552. }
  553. return zswap_pool_create(zswap_zpool_type, zswap_compressor);
  554. }
  555. static void zswap_pool_destroy(struct zswap_pool *pool)
  556. {
  557. zswap_pool_debug("destroying", pool);
  558. zswap_cpu_comp_destroy(pool);
  559. free_percpu(pool->tfm);
  560. zpool_destroy_pool(pool->zpool);
  561. kfree(pool);
  562. }
  563. static int __must_check zswap_pool_get(struct zswap_pool *pool)
  564. {
  565. return kref_get_unless_zero(&pool->kref);
  566. }
  567. static void __zswap_pool_release(struct work_struct *work)
  568. {
  569. struct zswap_pool *pool = container_of(work, typeof(*pool), work);
  570. synchronize_rcu();
  571. /* nobody should have been able to get a kref... */
  572. WARN_ON(kref_get_unless_zero(&pool->kref));
  573. /* pool is now off zswap_pools list and has no references. */
  574. zswap_pool_destroy(pool);
  575. }
  576. static void __zswap_pool_empty(struct kref *kref)
  577. {
  578. struct zswap_pool *pool;
  579. pool = container_of(kref, typeof(*pool), kref);
  580. spin_lock(&zswap_pools_lock);
  581. WARN_ON(pool == zswap_pool_current());
  582. list_del_rcu(&pool->list);
  583. INIT_WORK(&pool->work, __zswap_pool_release);
  584. schedule_work(&pool->work);
  585. spin_unlock(&zswap_pools_lock);
  586. }
  587. static void zswap_pool_put(struct zswap_pool *pool)
  588. {
  589. kref_put(&pool->kref, __zswap_pool_empty);
  590. }
  591. /*********************************
  592. * param callbacks
  593. **********************************/
  594. /* val must be a null-terminated string */
  595. static int __zswap_param_set(const char *val, const struct kernel_param *kp,
  596. char *type, char *compressor)
  597. {
  598. struct zswap_pool *pool, *put_pool = NULL;
  599. char *s = strstrip((char *)val);
  600. int ret;
  601. if (zswap_init_failed) {
  602. pr_err("can't set param, initialization failed\n");
  603. return -ENODEV;
  604. }
  605. /* no change required */
  606. if (!strcmp(s, *(char **)kp->arg))
  607. return 0;
  608. /* if this is load-time (pre-init) param setting,
  609. * don't create a pool; that's done during init.
  610. */
  611. if (!zswap_init_started)
  612. return param_set_charp(s, kp);
  613. if (!type) {
  614. if (!zpool_has_pool(s)) {
  615. pr_err("zpool %s not available\n", s);
  616. return -ENOENT;
  617. }
  618. type = s;
  619. } else if (!compressor) {
  620. if (!crypto_has_comp(s, 0, 0)) {
  621. pr_err("compressor %s not available\n", s);
  622. return -ENOENT;
  623. }
  624. compressor = s;
  625. } else {
  626. WARN_ON(1);
  627. return -EINVAL;
  628. }
  629. spin_lock(&zswap_pools_lock);
  630. pool = zswap_pool_find_get(type, compressor);
  631. if (pool) {
  632. zswap_pool_debug("using existing", pool);
  633. WARN_ON(pool == zswap_pool_current());
  634. list_del_rcu(&pool->list);
  635. }
  636. spin_unlock(&zswap_pools_lock);
  637. if (!pool)
  638. pool = zswap_pool_create(type, compressor);
  639. if (pool)
  640. ret = param_set_charp(s, kp);
  641. else
  642. ret = -EINVAL;
  643. spin_lock(&zswap_pools_lock);
  644. if (!ret) {
  645. put_pool = zswap_pool_current();
  646. list_add_rcu(&pool->list, &zswap_pools);
  647. } else if (pool) {
  648. /* add the possibly pre-existing pool to the end of the pools
  649. * list; if it's new (and empty) then it'll be removed and
  650. * destroyed by the put after we drop the lock
  651. */
  652. list_add_tail_rcu(&pool->list, &zswap_pools);
  653. put_pool = pool;
  654. }
  655. spin_unlock(&zswap_pools_lock);
  656. /* drop the ref from either the old current pool,
  657. * or the new pool we failed to add
  658. */
  659. if (put_pool)
  660. zswap_pool_put(put_pool);
  661. return ret;
  662. }
  663. static int zswap_compressor_param_set(const char *val,
  664. const struct kernel_param *kp)
  665. {
  666. return __zswap_param_set(val, kp, zswap_zpool_type, NULL);
  667. }
  668. static int zswap_zpool_param_set(const char *val,
  669. const struct kernel_param *kp)
  670. {
  671. return __zswap_param_set(val, kp, NULL, zswap_compressor);
  672. }
  673. static int zswap_enabled_param_set(const char *val,
  674. const struct kernel_param *kp)
  675. {
  676. if (zswap_init_failed) {
  677. pr_err("can't enable, initialization failed\n");
  678. return -ENODEV;
  679. }
  680. return param_set_bool(val, kp);
  681. }
  682. /*********************************
  683. * writeback code
  684. **********************************/
  685. /* return enum for zswap_get_swap_cache_page */
  686. enum zswap_get_swap_ret {
  687. ZSWAP_SWAPCACHE_NEW,
  688. ZSWAP_SWAPCACHE_EXIST,
  689. ZSWAP_SWAPCACHE_FAIL,
  690. };
  691. /*
  692. * zswap_get_swap_cache_page
  693. *
  694. * This is an adaption of read_swap_cache_async()
  695. *
  696. * This function tries to find a page with the given swap entry
  697. * in the swapper_space address space (the swap cache). If the page
  698. * is found, it is returned in retpage. Otherwise, a page is allocated,
  699. * added to the swap cache, and returned in retpage.
  700. *
  701. * If success, the swap cache page is returned in retpage
  702. * Returns ZSWAP_SWAPCACHE_EXIST if page was already in the swap cache
  703. * Returns ZSWAP_SWAPCACHE_NEW if the new page needs to be populated,
  704. * the new page is added to swapcache and locked
  705. * Returns ZSWAP_SWAPCACHE_FAIL on error
  706. */
  707. static int zswap_get_swap_cache_page(swp_entry_t entry,
  708. struct page **retpage)
  709. {
  710. bool page_was_allocated;
  711. *retpage = __read_swap_cache_async(entry, GFP_KERNEL,
  712. NULL, 0, &page_was_allocated);
  713. if (page_was_allocated)
  714. return ZSWAP_SWAPCACHE_NEW;
  715. if (!*retpage)
  716. return ZSWAP_SWAPCACHE_FAIL;
  717. return ZSWAP_SWAPCACHE_EXIST;
  718. }
  719. /*
  720. * Attempts to free an entry by adding a page to the swap cache,
  721. * decompressing the entry data into the page, and issuing a
  722. * bio write to write the page back to the swap device.
  723. *
  724. * This can be thought of as a "resumed writeback" of the page
  725. * to the swap device. We are basically resuming the same swap
  726. * writeback path that was intercepted with the frontswap_store()
  727. * in the first place. After the page has been decompressed into
  728. * the swap cache, the compressed version stored by zswap can be
  729. * freed.
  730. */
  731. static int zswap_writeback_entry(struct zpool *pool, unsigned long handle)
  732. {
  733. struct zswap_header *zhdr;
  734. swp_entry_t swpentry;
  735. struct zswap_tree *tree;
  736. pgoff_t offset;
  737. struct zswap_entry *entry;
  738. struct page *page;
  739. struct crypto_comp *tfm;
  740. u8 *src, *dst;
  741. unsigned int dlen;
  742. int ret;
  743. struct writeback_control wbc = {
  744. .sync_mode = WB_SYNC_NONE,
  745. };
  746. /* extract swpentry from data */
  747. zhdr = zpool_map_handle(pool, handle, ZPOOL_MM_RO);
  748. swpentry = zhdr->swpentry; /* here */
  749. zpool_unmap_handle(pool, handle);
  750. tree = zswap_trees[swp_type(swpentry)];
  751. offset = swp_offset(swpentry);
  752. /* find and ref zswap entry */
  753. spin_lock(&tree->lock);
  754. entry = zswap_entry_find_get(&tree->rbroot, offset);
  755. if (!entry) {
  756. /* entry was invalidated */
  757. spin_unlock(&tree->lock);
  758. return 0;
  759. }
  760. spin_unlock(&tree->lock);
  761. BUG_ON(offset != entry->offset);
  762. /* try to allocate swap cache page */
  763. switch (zswap_get_swap_cache_page(swpentry, &page)) {
  764. case ZSWAP_SWAPCACHE_FAIL: /* no memory or invalidate happened */
  765. ret = -ENOMEM;
  766. goto fail;
  767. case ZSWAP_SWAPCACHE_EXIST:
  768. /* page is already in the swap cache, ignore for now */
  769. put_page(page);
  770. ret = -EEXIST;
  771. goto fail;
  772. case ZSWAP_SWAPCACHE_NEW: /* page is locked */
  773. /* decompress */
  774. dlen = PAGE_SIZE;
  775. src = (u8 *)zpool_map_handle(entry->pool->zpool, entry->handle,
  776. ZPOOL_MM_RO) + sizeof(struct zswap_header);
  777. dst = kmap_atomic(page);
  778. tfm = *get_cpu_ptr(entry->pool->tfm);
  779. ret = crypto_comp_decompress(tfm, src, entry->length,
  780. dst, &dlen);
  781. put_cpu_ptr(entry->pool->tfm);
  782. kunmap_atomic(dst);
  783. zpool_unmap_handle(entry->pool->zpool, entry->handle);
  784. BUG_ON(ret);
  785. BUG_ON(dlen != PAGE_SIZE);
  786. /* page is up to date */
  787. SetPageUptodate(page);
  788. }
  789. /* move it to the tail of the inactive list after end_writeback */
  790. SetPageReclaim(page);
  791. /* start writeback */
  792. __swap_writepage(page, &wbc, end_swap_bio_write);
  793. put_page(page);
  794. zswap_written_back_pages++;
  795. spin_lock(&tree->lock);
  796. /* drop local reference */
  797. zswap_entry_put(tree, entry);
  798. /*
  799. * There are two possible situations for entry here:
  800. * (1) refcount is 1(normal case), entry is valid and on the tree
  801. * (2) refcount is 0, entry is freed and not on the tree
  802. * because invalidate happened during writeback
  803. * search the tree and free the entry if find entry
  804. */
  805. if (entry == zswap_rb_search(&tree->rbroot, offset))
  806. zswap_entry_put(tree, entry);
  807. spin_unlock(&tree->lock);
  808. goto end;
  809. /*
  810. * if we get here due to ZSWAP_SWAPCACHE_EXIST
  811. * a load may happening concurrently
  812. * it is safe and okay to not free the entry
  813. * if we free the entry in the following put
  814. * it it either okay to return !0
  815. */
  816. fail:
  817. spin_lock(&tree->lock);
  818. zswap_entry_put(tree, entry);
  819. spin_unlock(&tree->lock);
  820. end:
  821. return ret;
  822. }
  823. static int zswap_shrink(void)
  824. {
  825. struct zswap_pool *pool;
  826. int ret;
  827. pool = zswap_pool_last_get();
  828. if (!pool)
  829. return -ENOENT;
  830. ret = zpool_shrink(pool->zpool, 1, NULL);
  831. zswap_pool_put(pool);
  832. return ret;
  833. }
  834. /*********************************
  835. * frontswap hooks
  836. **********************************/
  837. /* attempts to compress and store an single page */
  838. static int zswap_frontswap_store(unsigned type, pgoff_t offset,
  839. struct page *page)
  840. {
  841. struct zswap_tree *tree = zswap_trees[type];
  842. struct zswap_entry *entry, *dupentry;
  843. struct crypto_comp *tfm;
  844. int ret;
  845. unsigned int dlen = PAGE_SIZE, len;
  846. unsigned long handle;
  847. char *buf;
  848. u8 *src, *dst;
  849. struct zswap_header *zhdr;
  850. if (!zswap_enabled || !tree) {
  851. ret = -ENODEV;
  852. goto reject;
  853. }
  854. /* reclaim space if needed */
  855. if (zswap_is_full()) {
  856. zswap_pool_limit_hit++;
  857. if (zswap_shrink()) {
  858. zswap_reject_reclaim_fail++;
  859. ret = -ENOMEM;
  860. goto reject;
  861. }
  862. }
  863. /* allocate entry */
  864. entry = zswap_entry_cache_alloc(GFP_KERNEL);
  865. if (!entry) {
  866. zswap_reject_kmemcache_fail++;
  867. ret = -ENOMEM;
  868. goto reject;
  869. }
  870. /* if entry is successfully added, it keeps the reference */
  871. entry->pool = zswap_pool_current_get();
  872. if (!entry->pool) {
  873. ret = -EINVAL;
  874. goto freepage;
  875. }
  876. /* compress */
  877. dst = get_cpu_var(zswap_dstmem);
  878. tfm = *get_cpu_ptr(entry->pool->tfm);
  879. src = kmap_atomic(page);
  880. ret = crypto_comp_compress(tfm, src, PAGE_SIZE, dst, &dlen);
  881. kunmap_atomic(src);
  882. put_cpu_ptr(entry->pool->tfm);
  883. if (ret) {
  884. ret = -EINVAL;
  885. goto put_dstmem;
  886. }
  887. /* store */
  888. len = dlen + sizeof(struct zswap_header);
  889. ret = zpool_malloc(entry->pool->zpool, len,
  890. __GFP_NORETRY | __GFP_NOWARN | __GFP_KSWAPD_RECLAIM,
  891. &handle);
  892. if (ret == -ENOSPC) {
  893. zswap_reject_compress_poor++;
  894. goto put_dstmem;
  895. }
  896. if (ret) {
  897. zswap_reject_alloc_fail++;
  898. goto put_dstmem;
  899. }
  900. zhdr = zpool_map_handle(entry->pool->zpool, handle, ZPOOL_MM_RW);
  901. zhdr->swpentry = swp_entry(type, offset);
  902. buf = (u8 *)(zhdr + 1);
  903. memcpy(buf, dst, dlen);
  904. zpool_unmap_handle(entry->pool->zpool, handle);
  905. put_cpu_var(zswap_dstmem);
  906. /* populate entry */
  907. entry->offset = offset;
  908. entry->handle = handle;
  909. entry->length = dlen;
  910. /* map */
  911. spin_lock(&tree->lock);
  912. do {
  913. ret = zswap_rb_insert(&tree->rbroot, entry, &dupentry);
  914. if (ret == -EEXIST) {
  915. zswap_duplicate_entry++;
  916. /* remove from rbtree */
  917. zswap_rb_erase(&tree->rbroot, dupentry);
  918. zswap_entry_put(tree, dupentry);
  919. }
  920. } while (ret == -EEXIST);
  921. spin_unlock(&tree->lock);
  922. /* update stats */
  923. atomic_inc(&zswap_stored_pages);
  924. zswap_update_total_size();
  925. return 0;
  926. put_dstmem:
  927. put_cpu_var(zswap_dstmem);
  928. zswap_pool_put(entry->pool);
  929. freepage:
  930. zswap_entry_cache_free(entry);
  931. reject:
  932. return ret;
  933. }
  934. /*
  935. * returns 0 if the page was successfully decompressed
  936. * return -1 on entry not found or error
  937. */
  938. static int zswap_frontswap_load(unsigned type, pgoff_t offset,
  939. struct page *page)
  940. {
  941. struct zswap_tree *tree = zswap_trees[type];
  942. struct zswap_entry *entry;
  943. struct crypto_comp *tfm;
  944. u8 *src, *dst;
  945. unsigned int dlen;
  946. int ret;
  947. /* find */
  948. spin_lock(&tree->lock);
  949. entry = zswap_entry_find_get(&tree->rbroot, offset);
  950. if (!entry) {
  951. /* entry was written back */
  952. spin_unlock(&tree->lock);
  953. return -1;
  954. }
  955. spin_unlock(&tree->lock);
  956. /* decompress */
  957. dlen = PAGE_SIZE;
  958. src = (u8 *)zpool_map_handle(entry->pool->zpool, entry->handle,
  959. ZPOOL_MM_RO) + sizeof(struct zswap_header);
  960. dst = kmap_atomic(page);
  961. tfm = *get_cpu_ptr(entry->pool->tfm);
  962. ret = crypto_comp_decompress(tfm, src, entry->length, dst, &dlen);
  963. put_cpu_ptr(entry->pool->tfm);
  964. kunmap_atomic(dst);
  965. zpool_unmap_handle(entry->pool->zpool, entry->handle);
  966. BUG_ON(ret);
  967. spin_lock(&tree->lock);
  968. zswap_entry_put(tree, entry);
  969. spin_unlock(&tree->lock);
  970. return 0;
  971. }
  972. /* frees an entry in zswap */
  973. static void zswap_frontswap_invalidate_page(unsigned type, pgoff_t offset)
  974. {
  975. struct zswap_tree *tree = zswap_trees[type];
  976. struct zswap_entry *entry;
  977. /* find */
  978. spin_lock(&tree->lock);
  979. entry = zswap_rb_search(&tree->rbroot, offset);
  980. if (!entry) {
  981. /* entry was written back */
  982. spin_unlock(&tree->lock);
  983. return;
  984. }
  985. /* remove from rbtree */
  986. zswap_rb_erase(&tree->rbroot, entry);
  987. /* drop the initial reference from entry creation */
  988. zswap_entry_put(tree, entry);
  989. spin_unlock(&tree->lock);
  990. }
  991. /* frees all zswap entries for the given swap type */
  992. static void zswap_frontswap_invalidate_area(unsigned type)
  993. {
  994. struct zswap_tree *tree = zswap_trees[type];
  995. struct zswap_entry *entry, *n;
  996. if (!tree)
  997. return;
  998. /* walk the tree and free everything */
  999. spin_lock(&tree->lock);
  1000. rbtree_postorder_for_each_entry_safe(entry, n, &tree->rbroot, rbnode)
  1001. zswap_free_entry(entry);
  1002. tree->rbroot = RB_ROOT;
  1003. spin_unlock(&tree->lock);
  1004. kfree(tree);
  1005. zswap_trees[type] = NULL;
  1006. }
  1007. static void zswap_frontswap_init(unsigned type)
  1008. {
  1009. struct zswap_tree *tree;
  1010. tree = kzalloc(sizeof(struct zswap_tree), GFP_KERNEL);
  1011. if (!tree) {
  1012. pr_err("alloc failed, zswap disabled for swap type %d\n", type);
  1013. return;
  1014. }
  1015. tree->rbroot = RB_ROOT;
  1016. spin_lock_init(&tree->lock);
  1017. zswap_trees[type] = tree;
  1018. }
  1019. static struct frontswap_ops zswap_frontswap_ops = {
  1020. .store = zswap_frontswap_store,
  1021. .load = zswap_frontswap_load,
  1022. .invalidate_page = zswap_frontswap_invalidate_page,
  1023. .invalidate_area = zswap_frontswap_invalidate_area,
  1024. .init = zswap_frontswap_init
  1025. };
  1026. /*********************************
  1027. * debugfs functions
  1028. **********************************/
  1029. #ifdef CONFIG_DEBUG_FS
  1030. #include <linux/debugfs.h>
  1031. static struct dentry *zswap_debugfs_root;
  1032. static int __init zswap_debugfs_init(void)
  1033. {
  1034. if (!debugfs_initialized())
  1035. return -ENODEV;
  1036. zswap_debugfs_root = debugfs_create_dir("zswap", NULL);
  1037. if (!zswap_debugfs_root)
  1038. return -ENOMEM;
  1039. debugfs_create_u64("pool_limit_hit", S_IRUGO,
  1040. zswap_debugfs_root, &zswap_pool_limit_hit);
  1041. debugfs_create_u64("reject_reclaim_fail", S_IRUGO,
  1042. zswap_debugfs_root, &zswap_reject_reclaim_fail);
  1043. debugfs_create_u64("reject_alloc_fail", S_IRUGO,
  1044. zswap_debugfs_root, &zswap_reject_alloc_fail);
  1045. debugfs_create_u64("reject_kmemcache_fail", S_IRUGO,
  1046. zswap_debugfs_root, &zswap_reject_kmemcache_fail);
  1047. debugfs_create_u64("reject_compress_poor", S_IRUGO,
  1048. zswap_debugfs_root, &zswap_reject_compress_poor);
  1049. debugfs_create_u64("written_back_pages", S_IRUGO,
  1050. zswap_debugfs_root, &zswap_written_back_pages);
  1051. debugfs_create_u64("duplicate_entry", S_IRUGO,
  1052. zswap_debugfs_root, &zswap_duplicate_entry);
  1053. debugfs_create_u64("pool_total_size", S_IRUGO,
  1054. zswap_debugfs_root, &zswap_pool_total_size);
  1055. debugfs_create_atomic_t("stored_pages", S_IRUGO,
  1056. zswap_debugfs_root, &zswap_stored_pages);
  1057. return 0;
  1058. }
  1059. static void __exit zswap_debugfs_exit(void)
  1060. {
  1061. debugfs_remove_recursive(zswap_debugfs_root);
  1062. }
  1063. #else
  1064. static int __init zswap_debugfs_init(void)
  1065. {
  1066. return 0;
  1067. }
  1068. static void __exit zswap_debugfs_exit(void) { }
  1069. #endif
  1070. /*********************************
  1071. * module init and exit
  1072. **********************************/
  1073. static int __init init_zswap(void)
  1074. {
  1075. struct zswap_pool *pool;
  1076. zswap_init_started = true;
  1077. if (zswap_entry_cache_create()) {
  1078. pr_err("entry cache creation failed\n");
  1079. goto cache_fail;
  1080. }
  1081. if (zswap_cpu_dstmem_init()) {
  1082. pr_err("dstmem alloc failed\n");
  1083. goto dstmem_fail;
  1084. }
  1085. pool = __zswap_pool_create_fallback();
  1086. if (!pool) {
  1087. pr_err("pool creation failed\n");
  1088. goto pool_fail;
  1089. }
  1090. pr_info("loaded using pool %s/%s\n", pool->tfm_name,
  1091. zpool_get_type(pool->zpool));
  1092. list_add(&pool->list, &zswap_pools);
  1093. frontswap_register_ops(&zswap_frontswap_ops);
  1094. if (zswap_debugfs_init())
  1095. pr_warn("debugfs initialization failed\n");
  1096. return 0;
  1097. pool_fail:
  1098. zswap_cpu_dstmem_destroy();
  1099. dstmem_fail:
  1100. zswap_entry_cache_destroy();
  1101. cache_fail:
  1102. /* if built-in, we aren't unloaded on failure; don't allow use */
  1103. zswap_init_failed = true;
  1104. zswap_enabled = false;
  1105. return -ENOMEM;
  1106. }
  1107. /* must be late so crypto has time to come up */
  1108. late_initcall(init_zswap);
  1109. MODULE_LICENSE("GPL");
  1110. MODULE_AUTHOR("Seth Jennings <sjennings@variantweb.net>");
  1111. MODULE_DESCRIPTION("Compressed cache for swap pages");