slob.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. /*
  2. * SLOB Allocator: Simple List Of Blocks
  3. *
  4. * Matt Mackall <mpm@selenic.com> 12/30/03
  5. *
  6. * NUMA support by Paul Mundt, 2007.
  7. *
  8. * How SLOB works:
  9. *
  10. * The core of SLOB is a traditional K&R style heap allocator, with
  11. * support for returning aligned objects. The granularity of this
  12. * allocator is as little as 2 bytes, however typically most architectures
  13. * will require 4 bytes on 32-bit and 8 bytes on 64-bit.
  14. *
  15. * The slob heap is a set of linked list of pages from alloc_pages(),
  16. * and within each page, there is a singly-linked list of free blocks
  17. * (slob_t). The heap is grown on demand. To reduce fragmentation,
  18. * heap pages are segregated into three lists, with objects less than
  19. * 256 bytes, objects less than 1024 bytes, and all other objects.
  20. *
  21. * Allocation from heap involves first searching for a page with
  22. * sufficient free blocks (using a next-fit-like approach) followed by
  23. * a first-fit scan of the page. Deallocation inserts objects back
  24. * into the free list in address order, so this is effectively an
  25. * address-ordered first fit.
  26. *
  27. * Above this is an implementation of kmalloc/kfree. Blocks returned
  28. * from kmalloc are prepended with a 4-byte header with the kmalloc size.
  29. * If kmalloc is asked for objects of PAGE_SIZE or larger, it calls
  30. * alloc_pages() directly, allocating compound pages so the page order
  31. * does not have to be separately tracked, and also stores the exact
  32. * allocation size in page->private so that it can be used to accurately
  33. * provide ksize(). These objects are detected in kfree() because slob_page()
  34. * is false for them.
  35. *
  36. * SLAB is emulated on top of SLOB by simply calling constructors and
  37. * destructors for every SLAB allocation. Objects are returned with the
  38. * 4-byte alignment unless the SLAB_HWCACHE_ALIGN flag is set, in which
  39. * case the low-level allocator will fragment blocks to create the proper
  40. * alignment. Again, objects of page-size or greater are allocated by
  41. * calling alloc_pages(). As SLAB objects know their size, no separate
  42. * size bookkeeping is necessary and there is essentially no allocation
  43. * space overhead, and compound pages aren't needed for multi-page
  44. * allocations.
  45. *
  46. * NUMA support in SLOB is fairly simplistic, pushing most of the real
  47. * logic down to the page allocator, and simply doing the node accounting
  48. * on the upper levels. In the event that a node id is explicitly
  49. * provided, alloc_pages_exact_node() with the specified node id is used
  50. * instead. The common case (or when the node id isn't explicitly provided)
  51. * will default to the current node, as per numa_node_id().
  52. *
  53. * Node aware pages are still inserted in to the global freelist, and
  54. * these are scanned for by matching against the node id encoded in the
  55. * page flags. As a result, block allocations that can be satisfied from
  56. * the freelist will only be done so on pages residing on the same node,
  57. * in order to prevent random node placement.
  58. */
  59. #include <linux/kernel.h>
  60. #include <linux/slab.h>
  61. #include <linux/mm.h>
  62. #include <linux/swap.h> /* struct reclaim_state */
  63. #include <linux/cache.h>
  64. #include <linux/init.h>
  65. #include <linux/module.h>
  66. #include <linux/rcupdate.h>
  67. #include <linux/list.h>
  68. #include <linux/kmemleak.h>
  69. #include <trace/events/kmem.h>
  70. #include <asm/atomic.h>
  71. /*
  72. * slob_block has a field 'units', which indicates size of block if +ve,
  73. * or offset of next block if -ve (in SLOB_UNITs).
  74. *
  75. * Free blocks of size 1 unit simply contain the offset of the next block.
  76. * Those with larger size contain their size in the first SLOB_UNIT of
  77. * memory, and the offset of the next free block in the second SLOB_UNIT.
  78. */
  79. #if PAGE_SIZE <= (32767 * 2)
  80. typedef s16 slobidx_t;
  81. #else
  82. typedef s32 slobidx_t;
  83. #endif
  84. struct slob_block {
  85. slobidx_t units;
  86. };
  87. typedef struct slob_block slob_t;
  88. /*
  89. * We use struct page fields to manage some slob allocation aspects,
  90. * however to avoid the horrible mess in include/linux/mm_types.h, we'll
  91. * just define our own struct page type variant here.
  92. */
  93. struct slob_page {
  94. union {
  95. struct {
  96. unsigned long flags; /* mandatory */
  97. atomic_t _count; /* mandatory */
  98. slobidx_t units; /* free units left in page */
  99. unsigned long pad[2];
  100. slob_t *free; /* first free slob_t in page */
  101. struct list_head list; /* linked list of free pages */
  102. };
  103. struct page page;
  104. };
  105. };
  106. static inline void struct_slob_page_wrong_size(void)
  107. { BUILD_BUG_ON(sizeof(struct slob_page) != sizeof(struct page)); }
  108. /*
  109. * free_slob_page: call before a slob_page is returned to the page allocator.
  110. */
  111. static inline void free_slob_page(struct slob_page *sp)
  112. {
  113. reset_page_mapcount(&sp->page);
  114. sp->page.mapping = NULL;
  115. }
  116. /*
  117. * All partially free slob pages go on these lists.
  118. */
  119. #define SLOB_BREAK1 256
  120. #define SLOB_BREAK2 1024
  121. static LIST_HEAD(free_slob_small);
  122. static LIST_HEAD(free_slob_medium);
  123. static LIST_HEAD(free_slob_large);
  124. /*
  125. * is_slob_page: True for all slob pages (false for bigblock pages)
  126. */
  127. static inline int is_slob_page(struct slob_page *sp)
  128. {
  129. return PageSlab((struct page *)sp);
  130. }
  131. static inline void set_slob_page(struct slob_page *sp)
  132. {
  133. __SetPageSlab((struct page *)sp);
  134. }
  135. static inline void clear_slob_page(struct slob_page *sp)
  136. {
  137. __ClearPageSlab((struct page *)sp);
  138. }
  139. static inline struct slob_page *slob_page(const void *addr)
  140. {
  141. return (struct slob_page *)virt_to_page(addr);
  142. }
  143. /*
  144. * slob_page_free: true for pages on free_slob_pages list.
  145. */
  146. static inline int slob_page_free(struct slob_page *sp)
  147. {
  148. return PageSlobFree((struct page *)sp);
  149. }
  150. static void set_slob_page_free(struct slob_page *sp, struct list_head *list)
  151. {
  152. list_add(&sp->list, list);
  153. __SetPageSlobFree((struct page *)sp);
  154. }
  155. static inline void clear_slob_page_free(struct slob_page *sp)
  156. {
  157. list_del(&sp->list);
  158. __ClearPageSlobFree((struct page *)sp);
  159. }
  160. #define SLOB_UNIT sizeof(slob_t)
  161. #define SLOB_UNITS(size) (((size) + SLOB_UNIT - 1)/SLOB_UNIT)
  162. #define SLOB_ALIGN L1_CACHE_BYTES
  163. /*
  164. * struct slob_rcu is inserted at the tail of allocated slob blocks, which
  165. * were created with a SLAB_DESTROY_BY_RCU slab. slob_rcu is used to free
  166. * the block using call_rcu.
  167. */
  168. struct slob_rcu {
  169. struct rcu_head head;
  170. int size;
  171. };
  172. /*
  173. * slob_lock protects all slob allocator structures.
  174. */
  175. static DEFINE_SPINLOCK(slob_lock);
  176. /*
  177. * Encode the given size and next info into a free slob block s.
  178. */
  179. static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
  180. {
  181. slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
  182. slobidx_t offset = next - base;
  183. if (size > 1) {
  184. s[0].units = size;
  185. s[1].units = offset;
  186. } else
  187. s[0].units = -offset;
  188. }
  189. /*
  190. * Return the size of a slob block.
  191. */
  192. static slobidx_t slob_units(slob_t *s)
  193. {
  194. if (s->units > 0)
  195. return s->units;
  196. return 1;
  197. }
  198. /*
  199. * Return the next free slob block pointer after this one.
  200. */
  201. static slob_t *slob_next(slob_t *s)
  202. {
  203. slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
  204. slobidx_t next;
  205. if (s[0].units < 0)
  206. next = -s[0].units;
  207. else
  208. next = s[1].units;
  209. return base+next;
  210. }
  211. /*
  212. * Returns true if s is the last free block in its page.
  213. */
  214. static int slob_last(slob_t *s)
  215. {
  216. return !((unsigned long)slob_next(s) & ~PAGE_MASK);
  217. }
  218. static void *slob_new_pages(gfp_t gfp, int order, int node)
  219. {
  220. void *page;
  221. #ifdef CONFIG_NUMA
  222. if (node != -1)
  223. page = alloc_pages_exact_node(node, gfp, order);
  224. else
  225. #endif
  226. page = alloc_pages(gfp, order);
  227. if (!page)
  228. return NULL;
  229. return page_address(page);
  230. }
  231. static void slob_free_pages(void *b, int order)
  232. {
  233. if (current->reclaim_state)
  234. current->reclaim_state->reclaimed_slab += 1 << order;
  235. free_pages((unsigned long)b, order);
  236. }
  237. /*
  238. * Allocate a slob block within a given slob_page sp.
  239. */
  240. static void *slob_page_alloc(struct slob_page *sp, size_t size, int align)
  241. {
  242. slob_t *prev, *cur, *aligned = NULL;
  243. int delta = 0, units = SLOB_UNITS(size);
  244. for (prev = NULL, cur = sp->free; ; prev = cur, cur = slob_next(cur)) {
  245. slobidx_t avail = slob_units(cur);
  246. if (align) {
  247. aligned = (slob_t *)ALIGN((unsigned long)cur, align);
  248. delta = aligned - cur;
  249. }
  250. if (avail >= units + delta) { /* room enough? */
  251. slob_t *next;
  252. if (delta) { /* need to fragment head to align? */
  253. next = slob_next(cur);
  254. set_slob(aligned, avail - delta, next);
  255. set_slob(cur, delta, aligned);
  256. prev = cur;
  257. cur = aligned;
  258. avail = slob_units(cur);
  259. }
  260. next = slob_next(cur);
  261. if (avail == units) { /* exact fit? unlink. */
  262. if (prev)
  263. set_slob(prev, slob_units(prev), next);
  264. else
  265. sp->free = next;
  266. } else { /* fragment */
  267. if (prev)
  268. set_slob(prev, slob_units(prev), cur + units);
  269. else
  270. sp->free = cur + units;
  271. set_slob(cur + units, avail - units, next);
  272. }
  273. sp->units -= units;
  274. if (!sp->units)
  275. clear_slob_page_free(sp);
  276. return cur;
  277. }
  278. if (slob_last(cur))
  279. return NULL;
  280. }
  281. }
  282. /*
  283. * slob_alloc: entry point into the slob allocator.
  284. */
  285. static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
  286. {
  287. struct slob_page *sp;
  288. struct list_head *prev;
  289. struct list_head *slob_list;
  290. slob_t *b = NULL;
  291. unsigned long flags;
  292. if (size < SLOB_BREAK1)
  293. slob_list = &free_slob_small;
  294. else if (size < SLOB_BREAK2)
  295. slob_list = &free_slob_medium;
  296. else
  297. slob_list = &free_slob_large;
  298. spin_lock_irqsave(&slob_lock, flags);
  299. /* Iterate through each partially free page, try to find room */
  300. list_for_each_entry(sp, slob_list, list) {
  301. #ifdef CONFIG_NUMA
  302. /*
  303. * If there's a node specification, search for a partial
  304. * page with a matching node id in the freelist.
  305. */
  306. if (node != -1 && page_to_nid(&sp->page) != node)
  307. continue;
  308. #endif
  309. /* Enough room on this page? */
  310. if (sp->units < SLOB_UNITS(size))
  311. continue;
  312. /* Attempt to alloc */
  313. prev = sp->list.prev;
  314. b = slob_page_alloc(sp, size, align);
  315. if (!b)
  316. continue;
  317. /* Improve fragment distribution and reduce our average
  318. * search time by starting our next search here. (see
  319. * Knuth vol 1, sec 2.5, pg 449) */
  320. if (prev != slob_list->prev &&
  321. slob_list->next != prev->next)
  322. list_move_tail(slob_list, prev->next);
  323. break;
  324. }
  325. spin_unlock_irqrestore(&slob_lock, flags);
  326. /* Not enough space: must allocate a new page */
  327. if (!b) {
  328. b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
  329. if (!b)
  330. return NULL;
  331. sp = slob_page(b);
  332. set_slob_page(sp);
  333. spin_lock_irqsave(&slob_lock, flags);
  334. sp->units = SLOB_UNITS(PAGE_SIZE);
  335. sp->free = b;
  336. INIT_LIST_HEAD(&sp->list);
  337. set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
  338. set_slob_page_free(sp, slob_list);
  339. b = slob_page_alloc(sp, size, align);
  340. BUG_ON(!b);
  341. spin_unlock_irqrestore(&slob_lock, flags);
  342. }
  343. if (unlikely((gfp & __GFP_ZERO) && b))
  344. memset(b, 0, size);
  345. return b;
  346. }
  347. /*
  348. * slob_free: entry point into the slob allocator.
  349. */
  350. static void slob_free(void *block, int size)
  351. {
  352. struct slob_page *sp;
  353. slob_t *prev, *next, *b = (slob_t *)block;
  354. slobidx_t units;
  355. unsigned long flags;
  356. struct list_head *slob_list;
  357. if (unlikely(ZERO_OR_NULL_PTR(block)))
  358. return;
  359. BUG_ON(!size);
  360. sp = slob_page(block);
  361. units = SLOB_UNITS(size);
  362. spin_lock_irqsave(&slob_lock, flags);
  363. if (sp->units + units == SLOB_UNITS(PAGE_SIZE)) {
  364. /* Go directly to page allocator. Do not pass slob allocator */
  365. if (slob_page_free(sp))
  366. clear_slob_page_free(sp);
  367. spin_unlock_irqrestore(&slob_lock, flags);
  368. clear_slob_page(sp);
  369. free_slob_page(sp);
  370. slob_free_pages(b, 0);
  371. return;
  372. }
  373. if (!slob_page_free(sp)) {
  374. /* This slob page is about to become partially free. Easy! */
  375. sp->units = units;
  376. sp->free = b;
  377. set_slob(b, units,
  378. (void *)((unsigned long)(b +
  379. SLOB_UNITS(PAGE_SIZE)) & PAGE_MASK));
  380. if (size < SLOB_BREAK1)
  381. slob_list = &free_slob_small;
  382. else if (size < SLOB_BREAK2)
  383. slob_list = &free_slob_medium;
  384. else
  385. slob_list = &free_slob_large;
  386. set_slob_page_free(sp, slob_list);
  387. goto out;
  388. }
  389. /*
  390. * Otherwise the page is already partially free, so find reinsertion
  391. * point.
  392. */
  393. sp->units += units;
  394. if (b < sp->free) {
  395. if (b + units == sp->free) {
  396. units += slob_units(sp->free);
  397. sp->free = slob_next(sp->free);
  398. }
  399. set_slob(b, units, sp->free);
  400. sp->free = b;
  401. } else {
  402. prev = sp->free;
  403. next = slob_next(prev);
  404. while (b > next) {
  405. prev = next;
  406. next = slob_next(prev);
  407. }
  408. if (!slob_last(prev) && b + units == next) {
  409. units += slob_units(next);
  410. set_slob(b, units, slob_next(next));
  411. } else
  412. set_slob(b, units, next);
  413. if (prev + slob_units(prev) == b) {
  414. units = slob_units(b) + slob_units(prev);
  415. set_slob(prev, units, slob_next(b));
  416. } else
  417. set_slob(prev, slob_units(prev), b);
  418. }
  419. out:
  420. spin_unlock_irqrestore(&slob_lock, flags);
  421. }
  422. /*
  423. * End of slob allocator proper. Begin kmem_cache_alloc and kmalloc frontend.
  424. */
  425. void *__kmalloc_node(size_t size, gfp_t gfp, int node)
  426. {
  427. unsigned int *m;
  428. int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
  429. void *ret;
  430. lockdep_trace_alloc(gfp);
  431. if (size < PAGE_SIZE - align) {
  432. if (!size)
  433. return ZERO_SIZE_PTR;
  434. m = slob_alloc(size + align, gfp, align, node);
  435. if (!m)
  436. return NULL;
  437. *m = size;
  438. ret = (void *)m + align;
  439. trace_kmalloc_node(_RET_IP_, ret,
  440. size, size + align, gfp, node);
  441. } else {
  442. unsigned int order = get_order(size);
  443. if (likely(order))
  444. gfp |= __GFP_COMP;
  445. ret = slob_new_pages(gfp, order, node);
  446. if (ret) {
  447. struct page *page;
  448. page = virt_to_page(ret);
  449. page->private = size;
  450. }
  451. trace_kmalloc_node(_RET_IP_, ret,
  452. size, PAGE_SIZE << order, gfp, node);
  453. }
  454. kmemleak_alloc(ret, size, 1, gfp);
  455. return ret;
  456. }
  457. EXPORT_SYMBOL(__kmalloc_node);
  458. void kfree(const void *block)
  459. {
  460. struct slob_page *sp;
  461. trace_kfree(_RET_IP_, block);
  462. if (unlikely(ZERO_OR_NULL_PTR(block)))
  463. return;
  464. kmemleak_free(block);
  465. sp = slob_page(block);
  466. if (is_slob_page(sp)) {
  467. int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
  468. unsigned int *m = (unsigned int *)(block - align);
  469. slob_free(m, *m + align);
  470. } else
  471. put_page(&sp->page);
  472. }
  473. EXPORT_SYMBOL(kfree);
  474. /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
  475. size_t ksize(const void *block)
  476. {
  477. struct slob_page *sp;
  478. BUG_ON(!block);
  479. if (unlikely(block == ZERO_SIZE_PTR))
  480. return 0;
  481. sp = slob_page(block);
  482. if (is_slob_page(sp)) {
  483. int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
  484. unsigned int *m = (unsigned int *)(block - align);
  485. return SLOB_UNITS(*m) * SLOB_UNIT;
  486. } else
  487. return sp->page.private;
  488. }
  489. EXPORT_SYMBOL(ksize);
  490. struct kmem_cache {
  491. unsigned int size, align;
  492. unsigned long flags;
  493. const char *name;
  494. void (*ctor)(void *);
  495. };
  496. struct kmem_cache *kmem_cache_create(const char *name, size_t size,
  497. size_t align, unsigned long flags, void (*ctor)(void *))
  498. {
  499. struct kmem_cache *c;
  500. c = slob_alloc(sizeof(struct kmem_cache),
  501. GFP_KERNEL, ARCH_KMALLOC_MINALIGN, -1);
  502. if (c) {
  503. c->name = name;
  504. c->size = size;
  505. if (flags & SLAB_DESTROY_BY_RCU) {
  506. /* leave room for rcu footer at the end of object */
  507. c->size += sizeof(struct slob_rcu);
  508. }
  509. c->flags = flags;
  510. c->ctor = ctor;
  511. /* ignore alignment unless it's forced */
  512. c->align = (flags & SLAB_HWCACHE_ALIGN) ? SLOB_ALIGN : 0;
  513. if (c->align < ARCH_SLAB_MINALIGN)
  514. c->align = ARCH_SLAB_MINALIGN;
  515. if (c->align < align)
  516. c->align = align;
  517. } else if (flags & SLAB_PANIC)
  518. panic("Cannot create slab cache %s\n", name);
  519. kmemleak_alloc(c, sizeof(struct kmem_cache), 1, GFP_KERNEL);
  520. return c;
  521. }
  522. EXPORT_SYMBOL(kmem_cache_create);
  523. void kmem_cache_destroy(struct kmem_cache *c)
  524. {
  525. kmemleak_free(c);
  526. if (c->flags & SLAB_DESTROY_BY_RCU)
  527. rcu_barrier();
  528. slob_free(c, sizeof(struct kmem_cache));
  529. }
  530. EXPORT_SYMBOL(kmem_cache_destroy);
  531. void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
  532. {
  533. void *b;
  534. if (c->size < PAGE_SIZE) {
  535. b = slob_alloc(c->size, flags, c->align, node);
  536. trace_kmem_cache_alloc_node(_RET_IP_, b, c->size,
  537. SLOB_UNITS(c->size) * SLOB_UNIT,
  538. flags, node);
  539. } else {
  540. b = slob_new_pages(flags, get_order(c->size), node);
  541. trace_kmem_cache_alloc_node(_RET_IP_, b, c->size,
  542. PAGE_SIZE << get_order(c->size),
  543. flags, node);
  544. }
  545. if (c->ctor)
  546. c->ctor(b);
  547. kmemleak_alloc_recursive(b, c->size, 1, c->flags, flags);
  548. return b;
  549. }
  550. EXPORT_SYMBOL(kmem_cache_alloc_node);
  551. static void __kmem_cache_free(void *b, int size)
  552. {
  553. if (size < PAGE_SIZE)
  554. slob_free(b, size);
  555. else
  556. slob_free_pages(b, get_order(size));
  557. }
  558. static void kmem_rcu_free(struct rcu_head *head)
  559. {
  560. struct slob_rcu *slob_rcu = (struct slob_rcu *)head;
  561. void *b = (void *)slob_rcu - (slob_rcu->size - sizeof(struct slob_rcu));
  562. __kmem_cache_free(b, slob_rcu->size);
  563. }
  564. void kmem_cache_free(struct kmem_cache *c, void *b)
  565. {
  566. kmemleak_free_recursive(b, c->flags);
  567. if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
  568. struct slob_rcu *slob_rcu;
  569. slob_rcu = b + (c->size - sizeof(struct slob_rcu));
  570. slob_rcu->size = c->size;
  571. call_rcu(&slob_rcu->head, kmem_rcu_free);
  572. } else {
  573. __kmem_cache_free(b, c->size);
  574. }
  575. trace_kmem_cache_free(_RET_IP_, b);
  576. }
  577. EXPORT_SYMBOL(kmem_cache_free);
  578. unsigned int kmem_cache_size(struct kmem_cache *c)
  579. {
  580. return c->size;
  581. }
  582. EXPORT_SYMBOL(kmem_cache_size);
  583. int kmem_cache_shrink(struct kmem_cache *d)
  584. {
  585. return 0;
  586. }
  587. EXPORT_SYMBOL(kmem_cache_shrink);
  588. static unsigned int slob_ready __read_mostly;
  589. int slab_is_available(void)
  590. {
  591. return slob_ready;
  592. }
  593. void __init kmem_cache_init(void)
  594. {
  595. slob_ready = 1;
  596. }
  597. void __init kmem_cache_init_late(void)
  598. {
  599. /* Nothing to do */
  600. }