slob.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  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_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 <trace/kmemtrace.h>
  69. #include <asm/atomic.h>
  70. /*
  71. * slob_block has a field 'units', which indicates size of block if +ve,
  72. * or offset of next block if -ve (in SLOB_UNITs).
  73. *
  74. * Free blocks of size 1 unit simply contain the offset of the next block.
  75. * Those with larger size contain their size in the first SLOB_UNIT of
  76. * memory, and the offset of the next free block in the second SLOB_UNIT.
  77. */
  78. #if PAGE_SIZE <= (32767 * 2)
  79. typedef s16 slobidx_t;
  80. #else
  81. typedef s32 slobidx_t;
  82. #endif
  83. struct slob_block {
  84. slobidx_t units;
  85. };
  86. typedef struct slob_block slob_t;
  87. /*
  88. * We use struct page fields to manage some slob allocation aspects,
  89. * however to avoid the horrible mess in include/linux/mm_types.h, we'll
  90. * just define our own struct page type variant here.
  91. */
  92. struct slob_page {
  93. union {
  94. struct {
  95. unsigned long flags; /* mandatory */
  96. atomic_t _count; /* mandatory */
  97. slobidx_t units; /* free units left in page */
  98. unsigned long pad[2];
  99. slob_t *free; /* first free slob_t in page */
  100. struct list_head list; /* linked list of free pages */
  101. };
  102. struct page page;
  103. };
  104. };
  105. static inline void struct_slob_page_wrong_size(void)
  106. { BUILD_BUG_ON(sizeof(struct slob_page) != sizeof(struct page)); }
  107. /*
  108. * free_slob_page: call before a slob_page is returned to the page allocator.
  109. */
  110. static inline void free_slob_page(struct slob_page *sp)
  111. {
  112. reset_page_mapcount(&sp->page);
  113. sp->page.mapping = NULL;
  114. }
  115. /*
  116. * All partially free slob pages go on these lists.
  117. */
  118. #define SLOB_BREAK1 256
  119. #define SLOB_BREAK2 1024
  120. static LIST_HEAD(free_slob_small);
  121. static LIST_HEAD(free_slob_medium);
  122. static LIST_HEAD(free_slob_large);
  123. /*
  124. * is_slob_page: True for all slob pages (false for bigblock pages)
  125. */
  126. static inline int is_slob_page(struct slob_page *sp)
  127. {
  128. return PageSlobPage((struct page *)sp);
  129. }
  130. static inline void set_slob_page(struct slob_page *sp)
  131. {
  132. __SetPageSlobPage((struct page *)sp);
  133. }
  134. static inline void clear_slob_page(struct slob_page *sp)
  135. {
  136. __ClearPageSlobPage((struct page *)sp);
  137. }
  138. static inline struct slob_page *slob_page(const void *addr)
  139. {
  140. return (struct slob_page *)virt_to_page(addr);
  141. }
  142. /*
  143. * slob_page_free: true for pages on free_slob_pages list.
  144. */
  145. static inline int slob_page_free(struct slob_page *sp)
  146. {
  147. return PageSlobFree((struct page *)sp);
  148. }
  149. static void set_slob_page_free(struct slob_page *sp, struct list_head *list)
  150. {
  151. list_add(&sp->list, list);
  152. __SetPageSlobFree((struct page *)sp);
  153. }
  154. static inline void clear_slob_page_free(struct slob_page *sp)
  155. {
  156. list_del(&sp->list);
  157. __ClearPageSlobFree((struct page *)sp);
  158. }
  159. #define SLOB_UNIT sizeof(slob_t)
  160. #define SLOB_UNITS(size) (((size) + SLOB_UNIT - 1)/SLOB_UNIT)
  161. #define SLOB_ALIGN L1_CACHE_BYTES
  162. /*
  163. * struct slob_rcu is inserted at the tail of allocated slob blocks, which
  164. * were created with a SLAB_DESTROY_BY_RCU slab. slob_rcu is used to free
  165. * the block using call_rcu.
  166. */
  167. struct slob_rcu {
  168. struct rcu_head head;
  169. int size;
  170. };
  171. /*
  172. * slob_lock protects all slob allocator structures.
  173. */
  174. static DEFINE_SPINLOCK(slob_lock);
  175. /*
  176. * Encode the given size and next info into a free slob block s.
  177. */
  178. static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
  179. {
  180. slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
  181. slobidx_t offset = next - base;
  182. if (size > 1) {
  183. s[0].units = size;
  184. s[1].units = offset;
  185. } else
  186. s[0].units = -offset;
  187. }
  188. /*
  189. * Return the size of a slob block.
  190. */
  191. static slobidx_t slob_units(slob_t *s)
  192. {
  193. if (s->units > 0)
  194. return s->units;
  195. return 1;
  196. }
  197. /*
  198. * Return the next free slob block pointer after this one.
  199. */
  200. static slob_t *slob_next(slob_t *s)
  201. {
  202. slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
  203. slobidx_t next;
  204. if (s[0].units < 0)
  205. next = -s[0].units;
  206. else
  207. next = s[1].units;
  208. return base+next;
  209. }
  210. /*
  211. * Returns true if s is the last free block in its page.
  212. */
  213. static int slob_last(slob_t *s)
  214. {
  215. return !((unsigned long)slob_next(s) & ~PAGE_MASK);
  216. }
  217. static void *slob_new_pages(gfp_t gfp, int order, int node)
  218. {
  219. void *page;
  220. #ifdef CONFIG_NUMA
  221. if (node != -1)
  222. page = alloc_pages_node(node, gfp, order);
  223. else
  224. #endif
  225. page = alloc_pages(gfp, order);
  226. if (!page)
  227. return NULL;
  228. return page_address(page);
  229. }
  230. static void slob_free_pages(void *b, int order)
  231. {
  232. if (current->reclaim_state)
  233. current->reclaim_state->reclaimed_slab += 1 << order;
  234. free_pages((unsigned long)b, order);
  235. }
  236. /*
  237. * Allocate a slob block within a given slob_page sp.
  238. */
  239. static void *slob_page_alloc(struct slob_page *sp, size_t size, int align)
  240. {
  241. slob_t *prev, *cur, *aligned = NULL;
  242. int delta = 0, units = SLOB_UNITS(size);
  243. for (prev = NULL, cur = sp->free; ; prev = cur, cur = slob_next(cur)) {
  244. slobidx_t avail = slob_units(cur);
  245. if (align) {
  246. aligned = (slob_t *)ALIGN((unsigned long)cur, align);
  247. delta = aligned - cur;
  248. }
  249. if (avail >= units + delta) { /* room enough? */
  250. slob_t *next;
  251. if (delta) { /* need to fragment head to align? */
  252. next = slob_next(cur);
  253. set_slob(aligned, avail - delta, next);
  254. set_slob(cur, delta, aligned);
  255. prev = cur;
  256. cur = aligned;
  257. avail = slob_units(cur);
  258. }
  259. next = slob_next(cur);
  260. if (avail == units) { /* exact fit? unlink. */
  261. if (prev)
  262. set_slob(prev, slob_units(prev), next);
  263. else
  264. sp->free = next;
  265. } else { /* fragment */
  266. if (prev)
  267. set_slob(prev, slob_units(prev), cur + units);
  268. else
  269. sp->free = cur + units;
  270. set_slob(cur + units, avail - units, next);
  271. }
  272. sp->units -= units;
  273. if (!sp->units)
  274. clear_slob_page_free(sp);
  275. return cur;
  276. }
  277. if (slob_last(cur))
  278. return NULL;
  279. }
  280. }
  281. /*
  282. * slob_alloc: entry point into the slob allocator.
  283. */
  284. static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
  285. {
  286. struct slob_page *sp;
  287. struct list_head *prev;
  288. struct list_head *slob_list;
  289. slob_t *b = NULL;
  290. unsigned long flags;
  291. if (size < SLOB_BREAK1)
  292. slob_list = &free_slob_small;
  293. else if (size < SLOB_BREAK2)
  294. slob_list = &free_slob_medium;
  295. else
  296. slob_list = &free_slob_large;
  297. spin_lock_irqsave(&slob_lock, flags);
  298. /* Iterate through each partially free page, try to find room */
  299. list_for_each_entry(sp, slob_list, list) {
  300. #ifdef CONFIG_NUMA
  301. /*
  302. * If there's a node specification, search for a partial
  303. * page with a matching node id in the freelist.
  304. */
  305. if (node != -1 && page_to_nid(&sp->page) != node)
  306. continue;
  307. #endif
  308. /* Enough room on this page? */
  309. if (sp->units < SLOB_UNITS(size))
  310. continue;
  311. /* Attempt to alloc */
  312. prev = sp->list.prev;
  313. b = slob_page_alloc(sp, size, align);
  314. if (!b)
  315. continue;
  316. /* Improve fragment distribution and reduce our average
  317. * search time by starting our next search here. (see
  318. * Knuth vol 1, sec 2.5, pg 449) */
  319. if (prev != slob_list->prev &&
  320. slob_list->next != prev->next)
  321. list_move_tail(slob_list, prev->next);
  322. break;
  323. }
  324. spin_unlock_irqrestore(&slob_lock, flags);
  325. /* Not enough space: must allocate a new page */
  326. if (!b) {
  327. b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
  328. if (!b)
  329. return NULL;
  330. sp = slob_page(b);
  331. set_slob_page(sp);
  332. spin_lock_irqsave(&slob_lock, flags);
  333. sp->units = SLOB_UNITS(PAGE_SIZE);
  334. sp->free = b;
  335. INIT_LIST_HEAD(&sp->list);
  336. set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
  337. set_slob_page_free(sp, slob_list);
  338. b = slob_page_alloc(sp, size, align);
  339. BUG_ON(!b);
  340. spin_unlock_irqrestore(&slob_lock, flags);
  341. }
  342. if (unlikely((gfp & __GFP_ZERO) && b))
  343. memset(b, 0, size);
  344. return b;
  345. }
  346. /*
  347. * slob_free: entry point into the slob allocator.
  348. */
  349. static void slob_free(void *block, int size)
  350. {
  351. struct slob_page *sp;
  352. slob_t *prev, *next, *b = (slob_t *)block;
  353. slobidx_t units;
  354. unsigned long flags;
  355. if (unlikely(ZERO_OR_NULL_PTR(block)))
  356. return;
  357. BUG_ON(!size);
  358. sp = slob_page(block);
  359. units = SLOB_UNITS(size);
  360. spin_lock_irqsave(&slob_lock, flags);
  361. if (sp->units + units == SLOB_UNITS(PAGE_SIZE)) {
  362. /* Go directly to page allocator. Do not pass slob allocator */
  363. if (slob_page_free(sp))
  364. clear_slob_page_free(sp);
  365. spin_unlock_irqrestore(&slob_lock, flags);
  366. clear_slob_page(sp);
  367. free_slob_page(sp);
  368. slob_free_pages(b, 0);
  369. return;
  370. }
  371. if (!slob_page_free(sp)) {
  372. /* This slob page is about to become partially free. Easy! */
  373. sp->units = units;
  374. sp->free = b;
  375. set_slob(b, units,
  376. (void *)((unsigned long)(b +
  377. SLOB_UNITS(PAGE_SIZE)) & PAGE_MASK));
  378. set_slob_page_free(sp, &free_slob_small);
  379. goto out;
  380. }
  381. /*
  382. * Otherwise the page is already partially free, so find reinsertion
  383. * point.
  384. */
  385. sp->units += units;
  386. if (b < sp->free) {
  387. if (b + units == sp->free) {
  388. units += slob_units(sp->free);
  389. sp->free = slob_next(sp->free);
  390. }
  391. set_slob(b, units, sp->free);
  392. sp->free = b;
  393. } else {
  394. prev = sp->free;
  395. next = slob_next(prev);
  396. while (b > next) {
  397. prev = next;
  398. next = slob_next(prev);
  399. }
  400. if (!slob_last(prev) && b + units == next) {
  401. units += slob_units(next);
  402. set_slob(b, units, slob_next(next));
  403. } else
  404. set_slob(b, units, next);
  405. if (prev + slob_units(prev) == b) {
  406. units = slob_units(b) + slob_units(prev);
  407. set_slob(prev, units, slob_next(b));
  408. } else
  409. set_slob(prev, slob_units(prev), b);
  410. }
  411. out:
  412. spin_unlock_irqrestore(&slob_lock, flags);
  413. }
  414. /*
  415. * End of slob allocator proper. Begin kmem_cache_alloc and kmalloc frontend.
  416. */
  417. #ifndef ARCH_KMALLOC_MINALIGN
  418. #define ARCH_KMALLOC_MINALIGN __alignof__(unsigned long)
  419. #endif
  420. #ifndef ARCH_SLAB_MINALIGN
  421. #define ARCH_SLAB_MINALIGN __alignof__(unsigned long)
  422. #endif
  423. void *__kmalloc_node(size_t size, gfp_t gfp, int node)
  424. {
  425. unsigned int *m;
  426. int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
  427. void *ret;
  428. lockdep_trace_alloc(gfp);
  429. if (size < PAGE_SIZE - align) {
  430. if (!size)
  431. return ZERO_SIZE_PTR;
  432. m = slob_alloc(size + align, gfp, align, node);
  433. if (!m)
  434. return NULL;
  435. *m = size;
  436. ret = (void *)m + align;
  437. trace_kmalloc_node(_RET_IP_, ret,
  438. size, size + align, gfp, node);
  439. } else {
  440. unsigned int order = get_order(size);
  441. ret = slob_new_pages(gfp | __GFP_COMP, get_order(size), node);
  442. if (ret) {
  443. struct page *page;
  444. page = virt_to_page(ret);
  445. page->private = size;
  446. }
  447. trace_kmalloc_node(_RET_IP_, ret,
  448. size, PAGE_SIZE << order, gfp, node);
  449. }
  450. return ret;
  451. }
  452. EXPORT_SYMBOL(__kmalloc_node);
  453. void kfree(const void *block)
  454. {
  455. struct slob_page *sp;
  456. trace_kfree(_RET_IP_, block);
  457. if (unlikely(ZERO_OR_NULL_PTR(block)))
  458. return;
  459. sp = slob_page(block);
  460. if (is_slob_page(sp)) {
  461. int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
  462. unsigned int *m = (unsigned int *)(block - align);
  463. slob_free(m, *m + align);
  464. } else
  465. put_page(&sp->page);
  466. }
  467. EXPORT_SYMBOL(kfree);
  468. /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
  469. size_t ksize(const void *block)
  470. {
  471. struct slob_page *sp;
  472. BUG_ON(!block);
  473. if (unlikely(block == ZERO_SIZE_PTR))
  474. return 0;
  475. sp = slob_page(block);
  476. if (is_slob_page(sp)) {
  477. int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
  478. unsigned int *m = (unsigned int *)(block - align);
  479. return SLOB_UNITS(*m) * SLOB_UNIT;
  480. } else
  481. return sp->page.private;
  482. }
  483. EXPORT_SYMBOL(ksize);
  484. struct kmem_cache {
  485. unsigned int size, align;
  486. unsigned long flags;
  487. const char *name;
  488. void (*ctor)(void *);
  489. };
  490. struct kmem_cache *kmem_cache_create(const char *name, size_t size,
  491. size_t align, unsigned long flags, void (*ctor)(void *))
  492. {
  493. struct kmem_cache *c;
  494. c = slob_alloc(sizeof(struct kmem_cache),
  495. GFP_KERNEL, ARCH_KMALLOC_MINALIGN, -1);
  496. if (c) {
  497. c->name = name;
  498. c->size = size;
  499. if (flags & SLAB_DESTROY_BY_RCU) {
  500. /* leave room for rcu footer at the end of object */
  501. c->size += sizeof(struct slob_rcu);
  502. }
  503. c->flags = flags;
  504. c->ctor = ctor;
  505. /* ignore alignment unless it's forced */
  506. c->align = (flags & SLAB_HWCACHE_ALIGN) ? SLOB_ALIGN : 0;
  507. if (c->align < ARCH_SLAB_MINALIGN)
  508. c->align = ARCH_SLAB_MINALIGN;
  509. if (c->align < align)
  510. c->align = align;
  511. } else if (flags & SLAB_PANIC)
  512. panic("Cannot create slab cache %s\n", name);
  513. return c;
  514. }
  515. EXPORT_SYMBOL(kmem_cache_create);
  516. void kmem_cache_destroy(struct kmem_cache *c)
  517. {
  518. slob_free(c, sizeof(struct kmem_cache));
  519. }
  520. EXPORT_SYMBOL(kmem_cache_destroy);
  521. void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
  522. {
  523. void *b;
  524. if (c->size < PAGE_SIZE) {
  525. b = slob_alloc(c->size, flags, c->align, node);
  526. trace_kmem_cache_alloc_node(_RET_IP_, b, c->size,
  527. SLOB_UNITS(c->size) * SLOB_UNIT,
  528. flags, node);
  529. } else {
  530. b = slob_new_pages(flags, get_order(c->size), node);
  531. trace_kmem_cache_alloc_node(_RET_IP_, b, c->size,
  532. PAGE_SIZE << get_order(c->size),
  533. flags, node);
  534. }
  535. if (c->ctor)
  536. c->ctor(b);
  537. return b;
  538. }
  539. EXPORT_SYMBOL(kmem_cache_alloc_node);
  540. static void __kmem_cache_free(void *b, int size)
  541. {
  542. if (size < PAGE_SIZE)
  543. slob_free(b, size);
  544. else
  545. slob_free_pages(b, get_order(size));
  546. }
  547. static void kmem_rcu_free(struct rcu_head *head)
  548. {
  549. struct slob_rcu *slob_rcu = (struct slob_rcu *)head;
  550. void *b = (void *)slob_rcu - (slob_rcu->size - sizeof(struct slob_rcu));
  551. __kmem_cache_free(b, slob_rcu->size);
  552. }
  553. void kmem_cache_free(struct kmem_cache *c, void *b)
  554. {
  555. if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
  556. struct slob_rcu *slob_rcu;
  557. slob_rcu = b + (c->size - sizeof(struct slob_rcu));
  558. INIT_RCU_HEAD(&slob_rcu->head);
  559. slob_rcu->size = c->size;
  560. call_rcu(&slob_rcu->head, kmem_rcu_free);
  561. } else {
  562. __kmem_cache_free(b, c->size);
  563. }
  564. trace_kmem_cache_free(_RET_IP_, b);
  565. }
  566. EXPORT_SYMBOL(kmem_cache_free);
  567. unsigned int kmem_cache_size(struct kmem_cache *c)
  568. {
  569. return c->size;
  570. }
  571. EXPORT_SYMBOL(kmem_cache_size);
  572. const char *kmem_cache_name(struct kmem_cache *c)
  573. {
  574. return c->name;
  575. }
  576. EXPORT_SYMBOL(kmem_cache_name);
  577. int kmem_cache_shrink(struct kmem_cache *d)
  578. {
  579. return 0;
  580. }
  581. EXPORT_SYMBOL(kmem_cache_shrink);
  582. int kmem_ptr_validate(struct kmem_cache *a, const void *b)
  583. {
  584. return 0;
  585. }
  586. static unsigned int slob_ready __read_mostly;
  587. int slab_is_available(void)
  588. {
  589. return slob_ready;
  590. }
  591. void __init kmem_cache_init(void)
  592. {
  593. slob_ready = 1;
  594. }