lru_cache.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. /*
  2. lru_cache.c
  3. This file is part of DRBD by Philipp Reisner and Lars Ellenberg.
  4. Copyright (C) 2003-2008, LINBIT Information Technologies GmbH.
  5. Copyright (C) 2003-2008, Philipp Reisner <philipp.reisner@linbit.com>.
  6. Copyright (C) 2003-2008, Lars Ellenberg <lars.ellenberg@linbit.com>.
  7. drbd is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2, or (at your option)
  10. any later version.
  11. drbd is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with drbd; see the file COPYING. If not, write to
  17. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19. #include <linux/module.h>
  20. #include <linux/bitops.h>
  21. #include <linux/slab.h>
  22. #include <linux/string.h> /* for memset */
  23. #include <linux/seq_file.h> /* for seq_printf */
  24. #include <linux/lru_cache.h>
  25. MODULE_AUTHOR("Philipp Reisner <phil@linbit.com>, "
  26. "Lars Ellenberg <lars@linbit.com>");
  27. MODULE_DESCRIPTION("lru_cache - Track sets of hot objects");
  28. MODULE_LICENSE("GPL");
  29. /* this is developers aid only.
  30. * it catches concurrent access (lack of locking on the users part) */
  31. #define PARANOIA_ENTRY() do { \
  32. BUG_ON(!lc); \
  33. BUG_ON(!lc->nr_elements); \
  34. BUG_ON(test_and_set_bit(__LC_PARANOIA, &lc->flags)); \
  35. } while (0)
  36. #define RETURN(x...) do { \
  37. clear_bit_unlock(__LC_PARANOIA, &lc->flags); \
  38. return x ; } while (0)
  39. /* BUG() if e is not one of the elements tracked by lc */
  40. #define PARANOIA_LC_ELEMENT(lc, e) do { \
  41. struct lru_cache *lc_ = (lc); \
  42. struct lc_element *e_ = (e); \
  43. unsigned i = e_->lc_index; \
  44. BUG_ON(i >= lc_->nr_elements); \
  45. BUG_ON(lc_->lc_element[i] != e_); } while (0)
  46. /* We need to atomically
  47. * - try to grab the lock (set LC_LOCKED)
  48. * - only if there is no pending transaction
  49. * (neither LC_DIRTY nor LC_STARVING is set)
  50. * Because of PARANOIA_ENTRY() above abusing lc->flags as well,
  51. * it is not sufficient to just say
  52. * return 0 == cmpxchg(&lc->flags, 0, LC_LOCKED);
  53. */
  54. int lc_try_lock(struct lru_cache *lc)
  55. {
  56. unsigned long val;
  57. do {
  58. val = cmpxchg(&lc->flags, 0, LC_LOCKED);
  59. } while (unlikely (val == LC_PARANOIA));
  60. /* Spin until no-one is inside a PARANOIA_ENTRY()/RETURN() section. */
  61. return 0 == val;
  62. #if 0
  63. /* Alternative approach, spin in case someone enters or leaves a
  64. * PARANOIA_ENTRY()/RETURN() section. */
  65. unsigned long old, new, val;
  66. do {
  67. old = lc->flags & LC_PARANOIA;
  68. new = old | LC_LOCKED;
  69. val = cmpxchg(&lc->flags, old, new);
  70. } while (unlikely (val == (old ^ LC_PARANOIA)));
  71. return old == val;
  72. #endif
  73. }
  74. /**
  75. * lc_create - prepares to track objects in an active set
  76. * @name: descriptive name only used in lc_seq_printf_stats and lc_seq_dump_details
  77. * @max_pending_changes: maximum changes to accumulate until a transaction is required
  78. * @e_count: number of elements allowed to be active simultaneously
  79. * @e_size: size of the tracked objects
  80. * @e_off: offset to the &struct lc_element member in a tracked object
  81. *
  82. * Returns a pointer to a newly initialized struct lru_cache on success,
  83. * or NULL on (allocation) failure.
  84. */
  85. struct lru_cache *lc_create(const char *name, struct kmem_cache *cache,
  86. unsigned max_pending_changes,
  87. unsigned e_count, size_t e_size, size_t e_off)
  88. {
  89. struct hlist_head *slot = NULL;
  90. struct lc_element **element = NULL;
  91. struct lru_cache *lc;
  92. struct lc_element *e;
  93. unsigned cache_obj_size = kmem_cache_size(cache);
  94. unsigned i;
  95. WARN_ON(cache_obj_size < e_size);
  96. if (cache_obj_size < e_size)
  97. return NULL;
  98. /* e_count too big; would probably fail the allocation below anyways.
  99. * for typical use cases, e_count should be few thousand at most. */
  100. if (e_count > LC_MAX_ACTIVE)
  101. return NULL;
  102. slot = kcalloc(e_count, sizeof(struct hlist_head), GFP_KERNEL);
  103. if (!slot)
  104. goto out_fail;
  105. element = kzalloc(e_count * sizeof(struct lc_element *), GFP_KERNEL);
  106. if (!element)
  107. goto out_fail;
  108. lc = kzalloc(sizeof(*lc), GFP_KERNEL);
  109. if (!lc)
  110. goto out_fail;
  111. INIT_LIST_HEAD(&lc->in_use);
  112. INIT_LIST_HEAD(&lc->lru);
  113. INIT_LIST_HEAD(&lc->free);
  114. INIT_LIST_HEAD(&lc->to_be_changed);
  115. lc->name = name;
  116. lc->element_size = e_size;
  117. lc->element_off = e_off;
  118. lc->nr_elements = e_count;
  119. lc->max_pending_changes = max_pending_changes;
  120. lc->lc_cache = cache;
  121. lc->lc_element = element;
  122. lc->lc_slot = slot;
  123. /* preallocate all objects */
  124. for (i = 0; i < e_count; i++) {
  125. void *p = kmem_cache_alloc(cache, GFP_KERNEL);
  126. if (!p)
  127. break;
  128. memset(p, 0, lc->element_size);
  129. e = p + e_off;
  130. e->lc_index = i;
  131. e->lc_number = LC_FREE;
  132. e->lc_new_number = LC_FREE;
  133. list_add(&e->list, &lc->free);
  134. element[i] = e;
  135. }
  136. if (i == e_count)
  137. return lc;
  138. /* else: could not allocate all elements, give up */
  139. for (i--; i; i--) {
  140. void *p = element[i];
  141. kmem_cache_free(cache, p - e_off);
  142. }
  143. kfree(lc);
  144. out_fail:
  145. kfree(element);
  146. kfree(slot);
  147. return NULL;
  148. }
  149. void lc_free_by_index(struct lru_cache *lc, unsigned i)
  150. {
  151. void *p = lc->lc_element[i];
  152. WARN_ON(!p);
  153. if (p) {
  154. p -= lc->element_off;
  155. kmem_cache_free(lc->lc_cache, p);
  156. }
  157. }
  158. /**
  159. * lc_destroy - frees memory allocated by lc_create()
  160. * @lc: the lru cache to destroy
  161. */
  162. void lc_destroy(struct lru_cache *lc)
  163. {
  164. unsigned i;
  165. if (!lc)
  166. return;
  167. for (i = 0; i < lc->nr_elements; i++)
  168. lc_free_by_index(lc, i);
  169. kfree(lc->lc_element);
  170. kfree(lc->lc_slot);
  171. kfree(lc);
  172. }
  173. /**
  174. * lc_reset - does a full reset for @lc and the hash table slots.
  175. * @lc: the lru cache to operate on
  176. *
  177. * It is roughly the equivalent of re-allocating a fresh lru_cache object,
  178. * basically a short cut to lc_destroy(lc); lc = lc_create(...);
  179. */
  180. void lc_reset(struct lru_cache *lc)
  181. {
  182. unsigned i;
  183. INIT_LIST_HEAD(&lc->in_use);
  184. INIT_LIST_HEAD(&lc->lru);
  185. INIT_LIST_HEAD(&lc->free);
  186. INIT_LIST_HEAD(&lc->to_be_changed);
  187. lc->used = 0;
  188. lc->hits = 0;
  189. lc->misses = 0;
  190. lc->starving = 0;
  191. lc->locked = 0;
  192. lc->changed = 0;
  193. lc->pending_changes = 0;
  194. lc->flags = 0;
  195. memset(lc->lc_slot, 0, sizeof(struct hlist_head) * lc->nr_elements);
  196. for (i = 0; i < lc->nr_elements; i++) {
  197. struct lc_element *e = lc->lc_element[i];
  198. void *p = e;
  199. p -= lc->element_off;
  200. memset(p, 0, lc->element_size);
  201. /* re-init it */
  202. e->lc_index = i;
  203. e->lc_number = LC_FREE;
  204. e->lc_new_number = LC_FREE;
  205. list_add(&e->list, &lc->free);
  206. }
  207. }
  208. /**
  209. * lc_seq_printf_stats - print stats about @lc into @seq
  210. * @seq: the seq_file to print into
  211. * @lc: the lru cache to print statistics of
  212. */
  213. size_t lc_seq_printf_stats(struct seq_file *seq, struct lru_cache *lc)
  214. {
  215. /* NOTE:
  216. * total calls to lc_get are
  217. * (starving + hits + misses)
  218. * misses include "locked" count (update from an other thread in
  219. * progress) and "changed", when this in fact lead to an successful
  220. * update of the cache.
  221. */
  222. return seq_printf(seq, "\t%s: used:%u/%u "
  223. "hits:%lu misses:%lu starving:%lu locked:%lu changed:%lu\n",
  224. lc->name, lc->used, lc->nr_elements,
  225. lc->hits, lc->misses, lc->starving, lc->locked, lc->changed);
  226. }
  227. static struct hlist_head *lc_hash_slot(struct lru_cache *lc, unsigned int enr)
  228. {
  229. return lc->lc_slot + (enr % lc->nr_elements);
  230. }
  231. static struct lc_element *__lc_find(struct lru_cache *lc, unsigned int enr,
  232. bool include_changing)
  233. {
  234. struct hlist_node *n;
  235. struct lc_element *e;
  236. BUG_ON(!lc);
  237. BUG_ON(!lc->nr_elements);
  238. hlist_for_each_entry(e, n, lc_hash_slot(lc, enr), colision) {
  239. /* "about to be changed" elements, pending transaction commit,
  240. * are hashed by their "new number". "Normal" elements have
  241. * lc_number == lc_new_number. */
  242. if (e->lc_new_number != enr)
  243. continue;
  244. if (e->lc_new_number == e->lc_number || include_changing)
  245. return e;
  246. break;
  247. }
  248. return NULL;
  249. }
  250. /**
  251. * lc_find - find element by label, if present in the hash table
  252. * @lc: The lru_cache object
  253. * @enr: element number
  254. *
  255. * Returns the pointer to an element, if the element with the requested
  256. * "label" or element number is present in the hash table,
  257. * or NULL if not found. Does not change the refcnt.
  258. * Ignores elements that are "about to be used", i.e. not yet in the active
  259. * set, but still pending transaction commit.
  260. */
  261. struct lc_element *lc_find(struct lru_cache *lc, unsigned int enr)
  262. {
  263. return __lc_find(lc, enr, 0);
  264. }
  265. /**
  266. * lc_is_used - find element by label
  267. * @lc: The lru_cache object
  268. * @enr: element number
  269. *
  270. * Returns true, if the element with the requested "label" or element number is
  271. * present in the hash table, and is used (refcnt > 0).
  272. * Also finds elements that are not _currently_ used but only "about to be
  273. * used", i.e. on the "to_be_changed" list, pending transaction commit.
  274. */
  275. bool lc_is_used(struct lru_cache *lc, unsigned int enr)
  276. {
  277. struct lc_element *e = __lc_find(lc, enr, 1);
  278. return e && e->refcnt;
  279. }
  280. /**
  281. * lc_del - removes an element from the cache
  282. * @lc: The lru_cache object
  283. * @e: The element to remove
  284. *
  285. * @e must be unused (refcnt == 0). Moves @e from "lru" to "free" list,
  286. * sets @e->enr to %LC_FREE.
  287. */
  288. void lc_del(struct lru_cache *lc, struct lc_element *e)
  289. {
  290. PARANOIA_ENTRY();
  291. PARANOIA_LC_ELEMENT(lc, e);
  292. BUG_ON(e->refcnt);
  293. e->lc_number = e->lc_new_number = LC_FREE;
  294. hlist_del_init(&e->colision);
  295. list_move(&e->list, &lc->free);
  296. RETURN();
  297. }
  298. static struct lc_element *lc_prepare_for_change(struct lru_cache *lc, unsigned new_number)
  299. {
  300. struct list_head *n;
  301. struct lc_element *e;
  302. if (!list_empty(&lc->free))
  303. n = lc->free.next;
  304. else if (!list_empty(&lc->lru))
  305. n = lc->lru.prev;
  306. else
  307. return NULL;
  308. e = list_entry(n, struct lc_element, list);
  309. PARANOIA_LC_ELEMENT(lc, e);
  310. e->lc_new_number = new_number;
  311. if (!hlist_unhashed(&e->colision))
  312. __hlist_del(&e->colision);
  313. hlist_add_head(&e->colision, lc_hash_slot(lc, new_number));
  314. list_move(&e->list, &lc->to_be_changed);
  315. return e;
  316. }
  317. static int lc_unused_element_available(struct lru_cache *lc)
  318. {
  319. if (!list_empty(&lc->free))
  320. return 1; /* something on the free list */
  321. if (!list_empty(&lc->lru))
  322. return 1; /* something to evict */
  323. return 0;
  324. }
  325. static struct lc_element *__lc_get(struct lru_cache *lc, unsigned int enr, bool may_change)
  326. {
  327. struct lc_element *e;
  328. PARANOIA_ENTRY();
  329. if (lc->flags & LC_STARVING) {
  330. ++lc->starving;
  331. RETURN(NULL);
  332. }
  333. e = __lc_find(lc, enr, 1);
  334. /* if lc_new_number != lc_number,
  335. * this enr is currently being pulled in already,
  336. * and will be available once the pending transaction
  337. * has been committed. */
  338. if (e && e->lc_new_number == e->lc_number) {
  339. ++lc->hits;
  340. if (e->refcnt++ == 0)
  341. lc->used++;
  342. list_move(&e->list, &lc->in_use); /* Not evictable... */
  343. RETURN(e);
  344. }
  345. ++lc->misses;
  346. if (!may_change)
  347. RETURN(NULL);
  348. /* It has been found above, but on the "to_be_changed" list, not yet
  349. * committed. Don't pull it in twice, wait for the transaction, then
  350. * try again */
  351. if (e)
  352. RETURN(NULL);
  353. /* To avoid races with lc_try_lock(), first, mark us dirty
  354. * (using test_and_set_bit, as it implies memory barriers), ... */
  355. test_and_set_bit(__LC_DIRTY, &lc->flags);
  356. /* ... only then check if it is locked anyways. If lc_unlock clears
  357. * the dirty bit again, that's not a problem, we will come here again.
  358. */
  359. if (test_bit(__LC_LOCKED, &lc->flags)) {
  360. ++lc->locked;
  361. RETURN(NULL);
  362. }
  363. /* In case there is nothing available and we can not kick out
  364. * the LRU element, we have to wait ...
  365. */
  366. if (!lc_unused_element_available(lc)) {
  367. __set_bit(__LC_STARVING, &lc->flags);
  368. RETURN(NULL);
  369. }
  370. /* It was not present in the active set. We are going to recycle an
  371. * unused (or even "free") element, but we won't accumulate more than
  372. * max_pending_changes changes. */
  373. if (lc->pending_changes >= lc->max_pending_changes)
  374. RETURN(NULL);
  375. e = lc_prepare_for_change(lc, enr);
  376. BUG_ON(!e);
  377. clear_bit(__LC_STARVING, &lc->flags);
  378. BUG_ON(++e->refcnt != 1);
  379. lc->used++;
  380. lc->pending_changes++;
  381. RETURN(e);
  382. }
  383. /**
  384. * lc_get - get element by label, maybe change the active set
  385. * @lc: the lru cache to operate on
  386. * @enr: the label to look up
  387. *
  388. * Finds an element in the cache, increases its usage count,
  389. * "touches" and returns it.
  390. *
  391. * In case the requested number is not present, it needs to be added to the
  392. * cache. Therefore it is possible that an other element becomes evicted from
  393. * the cache. In either case, the user is notified so he is able to e.g. keep
  394. * a persistent log of the cache changes, and therefore the objects in use.
  395. *
  396. * Return values:
  397. * NULL
  398. * The cache was marked %LC_STARVING,
  399. * or the requested label was not in the active set
  400. * and a changing transaction is still pending (@lc was marked %LC_DIRTY).
  401. * Or no unused or free element could be recycled (@lc will be marked as
  402. * %LC_STARVING, blocking further lc_get() operations).
  403. *
  404. * pointer to the element with the REQUESTED element number.
  405. * In this case, it can be used right away
  406. *
  407. * pointer to an UNUSED element with some different element number,
  408. * where that different number may also be %LC_FREE.
  409. *
  410. * In this case, the cache is marked %LC_DIRTY,
  411. * so lc_try_lock() will no longer succeed.
  412. * The returned element pointer is moved to the "to_be_changed" list,
  413. * and registered with the new element number on the hash collision chains,
  414. * so it is possible to pick it up from lc_is_used().
  415. * Up to "max_pending_changes" (see lc_create()) can be accumulated.
  416. * The user now should do whatever housekeeping is necessary,
  417. * typically serialize on lc_try_lock_for_transaction(), then call
  418. * lc_committed(lc) and lc_unlock(), to finish the change.
  419. *
  420. * NOTE: The user needs to check the lc_number on EACH use, so he recognizes
  421. * any cache set change.
  422. */
  423. struct lc_element *lc_get(struct lru_cache *lc, unsigned int enr)
  424. {
  425. return __lc_get(lc, enr, 1);
  426. }
  427. /**
  428. * lc_try_get - get element by label, if present; do not change the active set
  429. * @lc: the lru cache to operate on
  430. * @enr: the label to look up
  431. *
  432. * Finds an element in the cache, increases its usage count,
  433. * "touches" and returns it.
  434. *
  435. * Return values:
  436. * NULL
  437. * The cache was marked %LC_STARVING,
  438. * or the requested label was not in the active set
  439. *
  440. * pointer to the element with the REQUESTED element number.
  441. * In this case, it can be used right away
  442. */
  443. struct lc_element *lc_try_get(struct lru_cache *lc, unsigned int enr)
  444. {
  445. return __lc_get(lc, enr, 0);
  446. }
  447. /**
  448. * lc_committed - tell @lc that pending changes have been recorded
  449. * @lc: the lru cache to operate on
  450. *
  451. * User is expected to serialize on explicit lc_try_lock_for_transaction()
  452. * before the transaction is started, and later needs to lc_unlock() explicitly
  453. * as well.
  454. */
  455. void lc_committed(struct lru_cache *lc)
  456. {
  457. struct lc_element *e, *tmp;
  458. PARANOIA_ENTRY();
  459. list_for_each_entry_safe(e, tmp, &lc->to_be_changed, list) {
  460. /* count number of changes, not number of transactions */
  461. ++lc->changed;
  462. e->lc_number = e->lc_new_number;
  463. list_move(&e->list, &lc->in_use);
  464. }
  465. lc->pending_changes = 0;
  466. RETURN();
  467. }
  468. /**
  469. * lc_put - give up refcnt of @e
  470. * @lc: the lru cache to operate on
  471. * @e: the element to put
  472. *
  473. * If refcnt reaches zero, the element is moved to the lru list,
  474. * and a %LC_STARVING (if set) is cleared.
  475. * Returns the new (post-decrement) refcnt.
  476. */
  477. unsigned int lc_put(struct lru_cache *lc, struct lc_element *e)
  478. {
  479. PARANOIA_ENTRY();
  480. PARANOIA_LC_ELEMENT(lc, e);
  481. BUG_ON(e->refcnt == 0);
  482. BUG_ON(e->lc_number != e->lc_new_number);
  483. if (--e->refcnt == 0) {
  484. /* move it to the front of LRU. */
  485. list_move(&e->list, &lc->lru);
  486. lc->used--;
  487. clear_bit_unlock(__LC_STARVING, &lc->flags);
  488. }
  489. RETURN(e->refcnt);
  490. }
  491. /**
  492. * lc_element_by_index
  493. * @lc: the lru cache to operate on
  494. * @i: the index of the element to return
  495. */
  496. struct lc_element *lc_element_by_index(struct lru_cache *lc, unsigned i)
  497. {
  498. BUG_ON(i >= lc->nr_elements);
  499. BUG_ON(lc->lc_element[i] == NULL);
  500. BUG_ON(lc->lc_element[i]->lc_index != i);
  501. return lc->lc_element[i];
  502. }
  503. /**
  504. * lc_index_of
  505. * @lc: the lru cache to operate on
  506. * @e: the element to query for its index position in lc->element
  507. */
  508. unsigned int lc_index_of(struct lru_cache *lc, struct lc_element *e)
  509. {
  510. PARANOIA_LC_ELEMENT(lc, e);
  511. return e->lc_index;
  512. }
  513. /**
  514. * lc_set - associate index with label
  515. * @lc: the lru cache to operate on
  516. * @enr: the label to set
  517. * @index: the element index to associate label with.
  518. *
  519. * Used to initialize the active set to some previously recorded state.
  520. */
  521. void lc_set(struct lru_cache *lc, unsigned int enr, int index)
  522. {
  523. struct lc_element *e;
  524. struct list_head *lh;
  525. if (index < 0 || index >= lc->nr_elements)
  526. return;
  527. e = lc_element_by_index(lc, index);
  528. BUG_ON(e->lc_number != e->lc_new_number);
  529. BUG_ON(e->refcnt != 0);
  530. e->lc_number = e->lc_new_number = enr;
  531. hlist_del_init(&e->colision);
  532. if (enr == LC_FREE)
  533. lh = &lc->free;
  534. else {
  535. hlist_add_head(&e->colision, lc_hash_slot(lc, enr));
  536. lh = &lc->lru;
  537. }
  538. list_move(&e->list, lh);
  539. }
  540. /**
  541. * lc_dump - Dump a complete LRU cache to seq in textual form.
  542. * @lc: the lru cache to operate on
  543. * @seq: the &struct seq_file pointer to seq_printf into
  544. * @utext: user supplied "heading" or other info
  545. * @detail: function pointer the user may provide to dump further details
  546. * of the object the lc_element is embedded in.
  547. */
  548. void lc_seq_dump_details(struct seq_file *seq, struct lru_cache *lc, char *utext,
  549. void (*detail) (struct seq_file *, struct lc_element *))
  550. {
  551. unsigned int nr_elements = lc->nr_elements;
  552. struct lc_element *e;
  553. int i;
  554. seq_printf(seq, "\tnn: lc_number refcnt %s\n ", utext);
  555. for (i = 0; i < nr_elements; i++) {
  556. e = lc_element_by_index(lc, i);
  557. if (e->lc_number == LC_FREE) {
  558. seq_printf(seq, "\t%2d: FREE\n", i);
  559. } else {
  560. seq_printf(seq, "\t%2d: %4u %4u ", i,
  561. e->lc_number, e->refcnt);
  562. detail(seq, e);
  563. }
  564. }
  565. }
  566. EXPORT_SYMBOL(lc_create);
  567. EXPORT_SYMBOL(lc_reset);
  568. EXPORT_SYMBOL(lc_destroy);
  569. EXPORT_SYMBOL(lc_set);
  570. EXPORT_SYMBOL(lc_del);
  571. EXPORT_SYMBOL(lc_try_get);
  572. EXPORT_SYMBOL(lc_find);
  573. EXPORT_SYMBOL(lc_get);
  574. EXPORT_SYMBOL(lc_put);
  575. EXPORT_SYMBOL(lc_committed);
  576. EXPORT_SYMBOL(lc_element_by_index);
  577. EXPORT_SYMBOL(lc_index_of);
  578. EXPORT_SYMBOL(lc_seq_printf_stats);
  579. EXPORT_SYMBOL(lc_seq_dump_details);
  580. EXPORT_SYMBOL(lc_try_lock);
  581. EXPORT_SYMBOL(lc_is_used);