zbud.c 18 KB

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