zbud.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * zbud.c
  4. *
  5. * Copyright (C) 2013, Seth Jennings, IBM
  6. *
  7. * Concepts based on zcache internal zbud allocator by Dan Magenheimer.
  8. *
  9. * zbud is an special purpose allocator for storing compressed pages. Contrary
  10. * to what its name may suggest, zbud is not a buddy allocator, but rather an
  11. * allocator that "buddies" two compressed pages together in a single memory
  12. * page.
  13. *
  14. * While this design limits storage density, it has simple and deterministic
  15. * reclaim properties that make it preferable to a higher density approach when
  16. * reclaim will be used.
  17. *
  18. * zbud works by storing compressed pages, or "zpages", together in pairs in a
  19. * single memory page called a "zbud page". The first buddy is "left
  20. * justified" at the beginning of the zbud page, and the last buddy is "right
  21. * justified" at the end of the zbud page. The benefit is that if either
  22. * buddy is freed, the freed buddy space, coalesced with whatever slack space
  23. * that existed between the buddies, results in the largest possible free region
  24. * within the zbud page.
  25. *
  26. * zbud also provides an attractive lower bound on density. The ratio of zpages
  27. * to zbud pages can not be less than 1. This ensures that zbud can never "do
  28. * harm" by using more pages to store zpages than the uncompressed zpages would
  29. * have used on their own.
  30. *
  31. * zbud pages are divided into "chunks". The size of the chunks is fixed at
  32. * compile time and determined by NCHUNKS_ORDER below. Dividing zbud pages
  33. * into chunks allows organizing unbuddied zbud pages into a manageable number
  34. * of unbuddied lists according to the number of free chunks available in the
  35. * zbud page.
  36. *
  37. * The zbud API differs from that of conventional allocators in that the
  38. * allocation function, zbud_alloc(), returns an opaque handle to the user,
  39. * not a dereferenceable pointer. The user must map the handle using
  40. * zbud_map() in order to get a usable pointer by which to access the
  41. * allocation data and unmap the handle with zbud_unmap() when operations
  42. * on the allocation data are complete.
  43. */
  44. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  45. #include <linux/atomic.h>
  46. #include <linux/list.h>
  47. #include <linux/mm.h>
  48. #include <linux/module.h>
  49. #include <linux/preempt.h>
  50. #include <linux/slab.h>
  51. #include <linux/spinlock.h>
  52. #include <linux/zbud.h>
  53. #include <linux/zpool.h>
  54. /*****************
  55. * Structures
  56. *****************/
  57. /*
  58. * NCHUNKS_ORDER determines the internal allocation granularity, effectively
  59. * adjusting internal fragmentation. It also determines the number of
  60. * freelists maintained in each pool. NCHUNKS_ORDER of 6 means that the
  61. * allocation granularity will be in chunks of size PAGE_SIZE/64. As one chunk
  62. * in allocated page is occupied by zbud header, NCHUNKS will be calculated to
  63. * 63 which shows the max number of free chunks in zbud page, also there will be
  64. * 63 freelists per pool.
  65. */
  66. #define NCHUNKS_ORDER 6
  67. #define CHUNK_SHIFT (PAGE_SHIFT - NCHUNKS_ORDER)
  68. #define CHUNK_SIZE (1 << CHUNK_SHIFT)
  69. #define ZHDR_SIZE_ALIGNED CHUNK_SIZE
  70. #define NCHUNKS ((PAGE_SIZE - ZHDR_SIZE_ALIGNED) >> CHUNK_SHIFT)
  71. /**
  72. * struct zbud_pool - stores metadata for each zbud pool
  73. * @lock: protects all pool fields and first|last_chunk fields of any
  74. * zbud page in the pool
  75. * @unbuddied: array of lists tracking zbud pages that only contain one buddy;
  76. * the lists each zbud page is added to depends on the size of
  77. * its free region.
  78. * @buddied: list tracking the zbud pages that contain two buddies;
  79. * these zbud pages are full
  80. * @lru: list tracking the zbud pages in LRU order by most recently
  81. * added buddy.
  82. * @pages_nr: number of zbud pages in the pool.
  83. * @ops: pointer to a structure of user defined operations specified at
  84. * pool creation time.
  85. *
  86. * This structure is allocated at pool creation time and maintains metadata
  87. * pertaining to a particular zbud pool.
  88. */
  89. struct zbud_pool {
  90. spinlock_t lock;
  91. struct list_head unbuddied[NCHUNKS];
  92. struct list_head buddied;
  93. struct list_head lru;
  94. u64 pages_nr;
  95. const struct zbud_ops *ops;
  96. #ifdef CONFIG_ZPOOL
  97. struct zpool *zpool;
  98. const struct zpool_ops *zpool_ops;
  99. #endif
  100. };
  101. /*
  102. * struct zbud_header - zbud page metadata occupying the first chunk of each
  103. * zbud page.
  104. * @buddy: links the zbud page into the unbuddied/buddied lists in the pool
  105. * @lru: links the zbud page into the lru list in the pool
  106. * @first_chunks: the size of the first buddy in chunks, 0 if free
  107. * @last_chunks: the size of the last buddy in chunks, 0 if free
  108. */
  109. struct zbud_header {
  110. struct list_head buddy;
  111. struct list_head lru;
  112. unsigned int first_chunks;
  113. unsigned int last_chunks;
  114. bool under_reclaim;
  115. };
  116. /*****************
  117. * zpool
  118. ****************/
  119. #ifdef CONFIG_ZPOOL
  120. static int zbud_zpool_evict(struct zbud_pool *pool, unsigned long handle)
  121. {
  122. if (pool->zpool && pool->zpool_ops && pool->zpool_ops->evict)
  123. return pool->zpool_ops->evict(pool->zpool, handle);
  124. else
  125. return -ENOENT;
  126. }
  127. static const struct zbud_ops zbud_zpool_ops = {
  128. .evict = zbud_zpool_evict
  129. };
  130. static void *zbud_zpool_create(const char *name, gfp_t gfp,
  131. const struct zpool_ops *zpool_ops,
  132. struct zpool *zpool)
  133. {
  134. struct zbud_pool *pool;
  135. pool = zbud_create_pool(gfp, zpool_ops ? &zbud_zpool_ops : NULL);
  136. if (pool) {
  137. pool->zpool = zpool;
  138. pool->zpool_ops = zpool_ops;
  139. }
  140. return pool;
  141. }
  142. static void zbud_zpool_destroy(void *pool)
  143. {
  144. zbud_destroy_pool(pool);
  145. }
  146. static int zbud_zpool_malloc(void *pool, size_t size, gfp_t gfp,
  147. unsigned long *handle)
  148. {
  149. return zbud_alloc(pool, size, gfp, handle);
  150. }
  151. static void zbud_zpool_free(void *pool, unsigned long handle)
  152. {
  153. zbud_free(pool, handle);
  154. }
  155. static int zbud_zpool_shrink(void *pool, unsigned int pages,
  156. unsigned int *reclaimed)
  157. {
  158. unsigned int total = 0;
  159. int ret = -EINVAL;
  160. while (total < pages) {
  161. ret = zbud_reclaim_page(pool, 8);
  162. if (ret < 0)
  163. break;
  164. total++;
  165. }
  166. if (reclaimed)
  167. *reclaimed = total;
  168. return ret;
  169. }
  170. static void *zbud_zpool_map(void *pool, unsigned long handle,
  171. enum zpool_mapmode mm)
  172. {
  173. return zbud_map(pool, handle);
  174. }
  175. static void zbud_zpool_unmap(void *pool, unsigned long handle)
  176. {
  177. zbud_unmap(pool, handle);
  178. }
  179. static u64 zbud_zpool_total_size(void *pool)
  180. {
  181. return zbud_get_pool_size(pool) * PAGE_SIZE;
  182. }
  183. static struct zpool_driver zbud_zpool_driver = {
  184. .type = "zbud",
  185. .owner = THIS_MODULE,
  186. .create = zbud_zpool_create,
  187. .destroy = zbud_zpool_destroy,
  188. .malloc = zbud_zpool_malloc,
  189. .free = zbud_zpool_free,
  190. .shrink = zbud_zpool_shrink,
  191. .map = zbud_zpool_map,
  192. .unmap = zbud_zpool_unmap,
  193. .total_size = zbud_zpool_total_size,
  194. };
  195. MODULE_ALIAS("zpool-zbud");
  196. #endif /* CONFIG_ZPOOL */
  197. /*****************
  198. * Helpers
  199. *****************/
  200. /* Just to make the code easier to read */
  201. enum buddy {
  202. FIRST,
  203. LAST
  204. };
  205. /* Converts an allocation size in bytes to size in zbud chunks */
  206. static int size_to_chunks(size_t size)
  207. {
  208. return (size + CHUNK_SIZE - 1) >> CHUNK_SHIFT;
  209. }
  210. #define for_each_unbuddied_list(_iter, _begin) \
  211. for ((_iter) = (_begin); (_iter) < NCHUNKS; (_iter)++)
  212. /* Initializes the zbud header of a newly allocated zbud page */
  213. static struct zbud_header *init_zbud_page(struct page *page)
  214. {
  215. struct zbud_header *zhdr = page_address(page);
  216. zhdr->first_chunks = 0;
  217. zhdr->last_chunks = 0;
  218. INIT_LIST_HEAD(&zhdr->buddy);
  219. INIT_LIST_HEAD(&zhdr->lru);
  220. zhdr->under_reclaim = false;
  221. return zhdr;
  222. }
  223. /* Resets the struct page fields and frees the page */
  224. static void free_zbud_page(struct zbud_header *zhdr)
  225. {
  226. __free_page(virt_to_page(zhdr));
  227. }
  228. /*
  229. * Encodes the handle of a particular buddy within a zbud page
  230. * Pool lock should be held as this function accesses first|last_chunks
  231. */
  232. static unsigned long encode_handle(struct zbud_header *zhdr, enum buddy bud)
  233. {
  234. unsigned long handle;
  235. /*
  236. * For now, the encoded handle is actually just the pointer to the data
  237. * but this might not always be the case. A little information hiding.
  238. * Add CHUNK_SIZE to the handle if it is the first allocation to jump
  239. * over the zbud header in the first chunk.
  240. */
  241. handle = (unsigned long)zhdr;
  242. if (bud == FIRST)
  243. /* skip over zbud header */
  244. handle += ZHDR_SIZE_ALIGNED;
  245. else /* bud == LAST */
  246. handle += PAGE_SIZE - (zhdr->last_chunks << CHUNK_SHIFT);
  247. return handle;
  248. }
  249. /* Returns the zbud page where a given handle is stored */
  250. static struct zbud_header *handle_to_zbud_header(unsigned long handle)
  251. {
  252. return (struct zbud_header *)(handle & PAGE_MASK);
  253. }
  254. /* Returns the number of free chunks in a zbud page */
  255. static int num_free_chunks(struct zbud_header *zhdr)
  256. {
  257. /*
  258. * Rather than branch for different situations, just use the fact that
  259. * free buddies have a length of zero to simplify everything.
  260. */
  261. return NCHUNKS - zhdr->first_chunks - zhdr->last_chunks;
  262. }
  263. /*****************
  264. * API Functions
  265. *****************/
  266. /**
  267. * zbud_create_pool() - create a new zbud pool
  268. * @gfp: gfp flags when allocating the zbud pool structure
  269. * @ops: user-defined operations for the zbud pool
  270. *
  271. * Return: pointer to the new zbud pool or NULL if the metadata allocation
  272. * failed.
  273. */
  274. struct zbud_pool *zbud_create_pool(gfp_t gfp, const struct zbud_ops *ops)
  275. {
  276. struct zbud_pool *pool;
  277. int i;
  278. pool = kzalloc(sizeof(struct zbud_pool), gfp);
  279. if (!pool)
  280. return NULL;
  281. spin_lock_init(&pool->lock);
  282. for_each_unbuddied_list(i, 0)
  283. INIT_LIST_HEAD(&pool->unbuddied[i]);
  284. INIT_LIST_HEAD(&pool->buddied);
  285. INIT_LIST_HEAD(&pool->lru);
  286. pool->pages_nr = 0;
  287. pool->ops = ops;
  288. return pool;
  289. }
  290. /**
  291. * zbud_destroy_pool() - destroys an existing zbud pool
  292. * @pool: the zbud pool to be destroyed
  293. *
  294. * The pool should be emptied before this function is called.
  295. */
  296. void zbud_destroy_pool(struct zbud_pool *pool)
  297. {
  298. kfree(pool);
  299. }
  300. /**
  301. * zbud_alloc() - allocates a region of a given size
  302. * @pool: zbud pool from which to allocate
  303. * @size: size in bytes of the desired allocation
  304. * @gfp: gfp flags used if the pool needs to grow
  305. * @handle: handle of the new allocation
  306. *
  307. * This function will attempt to find a free region in the pool large enough to
  308. * satisfy the allocation request. A search of the unbuddied lists is
  309. * performed first. If no suitable free region is found, then a new page is
  310. * allocated and added to the pool to satisfy the request.
  311. *
  312. * gfp should not set __GFP_HIGHMEM as highmem pages cannot be used
  313. * as zbud pool pages.
  314. *
  315. * Return: 0 if success and handle is set, otherwise -EINVAL if the size or
  316. * gfp arguments are invalid or -ENOMEM if the pool was unable to allocate
  317. * a new page.
  318. */
  319. int zbud_alloc(struct zbud_pool *pool, size_t size, gfp_t gfp,
  320. unsigned long *handle)
  321. {
  322. int chunks, i, freechunks;
  323. struct zbud_header *zhdr = NULL;
  324. enum buddy bud;
  325. struct page *page;
  326. if (!size || (gfp & __GFP_HIGHMEM))
  327. return -EINVAL;
  328. if (size > PAGE_SIZE - ZHDR_SIZE_ALIGNED - CHUNK_SIZE)
  329. return -ENOSPC;
  330. chunks = size_to_chunks(size);
  331. spin_lock(&pool->lock);
  332. /* First, try to find an unbuddied zbud page. */
  333. for_each_unbuddied_list(i, chunks) {
  334. if (!list_empty(&pool->unbuddied[i])) {
  335. zhdr = list_first_entry(&pool->unbuddied[i],
  336. struct zbud_header, buddy);
  337. list_del(&zhdr->buddy);
  338. if (zhdr->first_chunks == 0)
  339. bud = FIRST;
  340. else
  341. bud = LAST;
  342. goto found;
  343. }
  344. }
  345. /* Couldn't find unbuddied zbud page, create new one */
  346. spin_unlock(&pool->lock);
  347. page = alloc_page(gfp);
  348. if (!page)
  349. return -ENOMEM;
  350. spin_lock(&pool->lock);
  351. pool->pages_nr++;
  352. zhdr = init_zbud_page(page);
  353. bud = FIRST;
  354. found:
  355. if (bud == FIRST)
  356. zhdr->first_chunks = chunks;
  357. else
  358. zhdr->last_chunks = chunks;
  359. if (zhdr->first_chunks == 0 || zhdr->last_chunks == 0) {
  360. /* Add to unbuddied list */
  361. freechunks = num_free_chunks(zhdr);
  362. list_add(&zhdr->buddy, &pool->unbuddied[freechunks]);
  363. } else {
  364. /* Add to buddied list */
  365. list_add(&zhdr->buddy, &pool->buddied);
  366. }
  367. /* Add/move zbud page to beginning of LRU */
  368. if (!list_empty(&zhdr->lru))
  369. list_del(&zhdr->lru);
  370. list_add(&zhdr->lru, &pool->lru);
  371. *handle = encode_handle(zhdr, bud);
  372. spin_unlock(&pool->lock);
  373. return 0;
  374. }
  375. /**
  376. * zbud_free() - frees the allocation associated with the given handle
  377. * @pool: pool in which the allocation resided
  378. * @handle: handle associated with the allocation returned by zbud_alloc()
  379. *
  380. * In the case that the zbud page in which the allocation resides is under
  381. * reclaim, as indicated by the PG_reclaim flag being set, this function
  382. * only sets the first|last_chunks to 0. The page is actually freed
  383. * once both buddies are evicted (see zbud_reclaim_page() below).
  384. */
  385. void zbud_free(struct zbud_pool *pool, unsigned long handle)
  386. {
  387. struct zbud_header *zhdr;
  388. int freechunks;
  389. spin_lock(&pool->lock);
  390. zhdr = handle_to_zbud_header(handle);
  391. /* If first buddy, handle will be page aligned */
  392. if ((handle - ZHDR_SIZE_ALIGNED) & ~PAGE_MASK)
  393. zhdr->last_chunks = 0;
  394. else
  395. zhdr->first_chunks = 0;
  396. if (zhdr->under_reclaim) {
  397. /* zbud page is under reclaim, reclaim will free */
  398. spin_unlock(&pool->lock);
  399. return;
  400. }
  401. /* Remove from existing buddy list */
  402. list_del(&zhdr->buddy);
  403. if (zhdr->first_chunks == 0 && zhdr->last_chunks == 0) {
  404. /* zbud page is empty, free */
  405. list_del(&zhdr->lru);
  406. free_zbud_page(zhdr);
  407. pool->pages_nr--;
  408. } else {
  409. /* Add to unbuddied list */
  410. freechunks = num_free_chunks(zhdr);
  411. list_add(&zhdr->buddy, &pool->unbuddied[freechunks]);
  412. }
  413. spin_unlock(&pool->lock);
  414. }
  415. /**
  416. * zbud_reclaim_page() - evicts allocations from a pool page and frees it
  417. * @pool: pool from which a page will attempt to be evicted
  418. * @retries: number of pages on the LRU list for which eviction will
  419. * be attempted before failing
  420. *
  421. * zbud reclaim is different from normal system reclaim in that the reclaim is
  422. * done from the bottom, up. This is because only the bottom layer, zbud, has
  423. * information on how the allocations are organized within each zbud page. This
  424. * has the potential to create interesting locking situations between zbud and
  425. * the user, however.
  426. *
  427. * To avoid these, this is how zbud_reclaim_page() should be called:
  428. *
  429. * The user detects a page should be reclaimed and calls zbud_reclaim_page().
  430. * zbud_reclaim_page() will remove a zbud page from the pool LRU list and call
  431. * the user-defined eviction handler with the pool and handle as arguments.
  432. *
  433. * If the handle can not be evicted, the eviction handler should return
  434. * non-zero. zbud_reclaim_page() will add the zbud page back to the
  435. * appropriate list and try the next zbud page on the LRU up to
  436. * a user defined number of retries.
  437. *
  438. * If the handle is successfully evicted, the eviction handler should
  439. * return 0 _and_ should have called zbud_free() on the handle. zbud_free()
  440. * contains logic to delay freeing the page if the page is under reclaim,
  441. * as indicated by the setting of the PG_reclaim flag on the underlying page.
  442. *
  443. * If all buddies in the zbud page are successfully evicted, then the
  444. * zbud page can be freed.
  445. *
  446. * Returns: 0 if page is successfully freed, otherwise -EINVAL if there are
  447. * no pages to evict or an eviction handler is not registered, -EAGAIN if
  448. * the retry limit was hit.
  449. */
  450. int zbud_reclaim_page(struct zbud_pool *pool, unsigned int retries)
  451. {
  452. int i, ret, freechunks;
  453. struct zbud_header *zhdr;
  454. unsigned long first_handle = 0, last_handle = 0;
  455. spin_lock(&pool->lock);
  456. if (!pool->ops || !pool->ops->evict || list_empty(&pool->lru) ||
  457. retries == 0) {
  458. spin_unlock(&pool->lock);
  459. return -EINVAL;
  460. }
  461. for (i = 0; i < retries; i++) {
  462. zhdr = list_last_entry(&pool->lru, struct zbud_header, lru);
  463. list_del(&zhdr->lru);
  464. list_del(&zhdr->buddy);
  465. /* Protect zbud page against free */
  466. zhdr->under_reclaim = true;
  467. /*
  468. * We need encode the handles before unlocking, since we can
  469. * race with free that will set (first|last)_chunks to 0
  470. */
  471. first_handle = 0;
  472. last_handle = 0;
  473. if (zhdr->first_chunks)
  474. first_handle = encode_handle(zhdr, FIRST);
  475. if (zhdr->last_chunks)
  476. last_handle = encode_handle(zhdr, LAST);
  477. spin_unlock(&pool->lock);
  478. /* Issue the eviction callback(s) */
  479. if (first_handle) {
  480. ret = pool->ops->evict(pool, first_handle);
  481. if (ret)
  482. goto next;
  483. }
  484. if (last_handle) {
  485. ret = pool->ops->evict(pool, last_handle);
  486. if (ret)
  487. goto next;
  488. }
  489. next:
  490. spin_lock(&pool->lock);
  491. zhdr->under_reclaim = false;
  492. if (zhdr->first_chunks == 0 && zhdr->last_chunks == 0) {
  493. /*
  494. * Both buddies are now free, free the zbud page and
  495. * return success.
  496. */
  497. free_zbud_page(zhdr);
  498. pool->pages_nr--;
  499. spin_unlock(&pool->lock);
  500. return 0;
  501. } else if (zhdr->first_chunks == 0 ||
  502. zhdr->last_chunks == 0) {
  503. /* add to unbuddied list */
  504. freechunks = num_free_chunks(zhdr);
  505. list_add(&zhdr->buddy, &pool->unbuddied[freechunks]);
  506. } else {
  507. /* add to buddied list */
  508. list_add(&zhdr->buddy, &pool->buddied);
  509. }
  510. /* add to beginning of LRU */
  511. list_add(&zhdr->lru, &pool->lru);
  512. }
  513. spin_unlock(&pool->lock);
  514. return -EAGAIN;
  515. }
  516. /**
  517. * zbud_map() - maps the allocation associated with the given handle
  518. * @pool: pool in which the allocation resides
  519. * @handle: handle associated with the allocation to be mapped
  520. *
  521. * While trivial for zbud, the mapping functions for others allocators
  522. * implementing this allocation API could have more complex information encoded
  523. * in the handle and could create temporary mappings to make the data
  524. * accessible to the user.
  525. *
  526. * Returns: a pointer to the mapped allocation
  527. */
  528. void *zbud_map(struct zbud_pool *pool, unsigned long handle)
  529. {
  530. return (void *)(handle);
  531. }
  532. /**
  533. * zbud_unmap() - maps the allocation associated with the given handle
  534. * @pool: pool in which the allocation resides
  535. * @handle: handle associated with the allocation to be unmapped
  536. */
  537. void zbud_unmap(struct zbud_pool *pool, unsigned long handle)
  538. {
  539. }
  540. /**
  541. * zbud_get_pool_size() - gets the zbud pool size in pages
  542. * @pool: pool whose size is being queried
  543. *
  544. * Returns: size in pages of the given pool. The pool lock need not be
  545. * taken to access pages_nr.
  546. */
  547. u64 zbud_get_pool_size(struct zbud_pool *pool)
  548. {
  549. return pool->pages_nr;
  550. }
  551. static int __init init_zbud(void)
  552. {
  553. /* Make sure the zbud header will fit in one chunk */
  554. BUILD_BUG_ON(sizeof(struct zbud_header) > ZHDR_SIZE_ALIGNED);
  555. pr_info("loaded\n");
  556. #ifdef CONFIG_ZPOOL
  557. zpool_register_driver(&zbud_zpool_driver);
  558. #endif
  559. return 0;
  560. }
  561. static void __exit exit_zbud(void)
  562. {
  563. #ifdef CONFIG_ZPOOL
  564. zpool_unregister_driver(&zbud_zpool_driver);
  565. #endif
  566. pr_info("unloaded\n");
  567. }
  568. module_init(init_zbud);
  569. module_exit(exit_zbud);
  570. MODULE_LICENSE("GPL");
  571. MODULE_AUTHOR("Seth Jennings <sjennings@variantweb.net>");
  572. MODULE_DESCRIPTION("Buddy Allocator for Compressed Pages");