2019-05-22 07:51:37 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2009-09-25 23:07:19 +00:00
|
|
|
/*
|
|
|
|
lru_cache.c
|
|
|
|
|
|
|
|
This file is part of DRBD by Philipp Reisner and Lars Ellenberg.
|
|
|
|
|
|
|
|
Copyright (C) 2003-2008, LINBIT Information Technologies GmbH.
|
|
|
|
Copyright (C) 2003-2008, Philipp Reisner <philipp.reisner@linbit.com>.
|
|
|
|
Copyright (C) 2003-2008, Lars Ellenberg <lars.ellenberg@linbit.com>.
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/bitops.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/string.h> /* for memset */
|
|
|
|
#include <linux/seq_file.h> /* for seq_printf */
|
|
|
|
#include <linux/lru_cache.h>
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Philipp Reisner <phil@linbit.com>, "
|
|
|
|
"Lars Ellenberg <lars@linbit.com>");
|
|
|
|
MODULE_DESCRIPTION("lru_cache - Track sets of hot objects");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
/* this is developers aid only.
|
|
|
|
* it catches concurrent access (lack of locking on the users part) */
|
|
|
|
#define PARANOIA_ENTRY() do { \
|
|
|
|
BUG_ON(!lc); \
|
|
|
|
BUG_ON(!lc->nr_elements); \
|
|
|
|
BUG_ON(test_and_set_bit(__LC_PARANOIA, &lc->flags)); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define RETURN(x...) do { \
|
2011-02-21 12:20:55 +00:00
|
|
|
clear_bit_unlock(__LC_PARANOIA, &lc->flags); \
|
|
|
|
return x ; } while (0)
|
2009-09-25 23:07:19 +00:00
|
|
|
|
|
|
|
/* BUG() if e is not one of the elements tracked by lc */
|
|
|
|
#define PARANOIA_LC_ELEMENT(lc, e) do { \
|
|
|
|
struct lru_cache *lc_ = (lc); \
|
|
|
|
struct lc_element *e_ = (e); \
|
|
|
|
unsigned i = e_->lc_index; \
|
|
|
|
BUG_ON(i >= lc_->nr_elements); \
|
|
|
|
BUG_ON(lc_->lc_element[i] != e_); } while (0)
|
|
|
|
|
2011-02-21 12:21:01 +00:00
|
|
|
|
|
|
|
/* We need to atomically
|
|
|
|
* - try to grab the lock (set LC_LOCKED)
|
|
|
|
* - only if there is no pending transaction
|
|
|
|
* (neither LC_DIRTY nor LC_STARVING is set)
|
|
|
|
* Because of PARANOIA_ENTRY() above abusing lc->flags as well,
|
|
|
|
* it is not sufficient to just say
|
|
|
|
* return 0 == cmpxchg(&lc->flags, 0, LC_LOCKED);
|
|
|
|
*/
|
|
|
|
int lc_try_lock(struct lru_cache *lc)
|
|
|
|
{
|
|
|
|
unsigned long val;
|
|
|
|
do {
|
|
|
|
val = cmpxchg(&lc->flags, 0, LC_LOCKED);
|
|
|
|
} while (unlikely (val == LC_PARANOIA));
|
|
|
|
/* Spin until no-one is inside a PARANOIA_ENTRY()/RETURN() section. */
|
|
|
|
return 0 == val;
|
|
|
|
}
|
|
|
|
|
2009-09-25 23:07:19 +00:00
|
|
|
/**
|
|
|
|
* lc_create - prepares to track objects in an active set
|
|
|
|
* @name: descriptive name only used in lc_seq_printf_stats and lc_seq_dump_details
|
2021-04-16 22:46:26 +00:00
|
|
|
* @cache: cache root pointer
|
2011-02-21 12:21:01 +00:00
|
|
|
* @max_pending_changes: maximum changes to accumulate until a transaction is required
|
2009-09-25 23:07:19 +00:00
|
|
|
* @e_count: number of elements allowed to be active simultaneously
|
|
|
|
* @e_size: size of the tracked objects
|
|
|
|
* @e_off: offset to the &struct lc_element member in a tracked object
|
|
|
|
*
|
|
|
|
* Returns a pointer to a newly initialized struct lru_cache on success,
|
|
|
|
* or NULL on (allocation) failure.
|
|
|
|
*/
|
|
|
|
struct lru_cache *lc_create(const char *name, struct kmem_cache *cache,
|
2011-02-21 12:21:01 +00:00
|
|
|
unsigned max_pending_changes,
|
2009-09-25 23:07:19 +00:00
|
|
|
unsigned e_count, size_t e_size, size_t e_off)
|
|
|
|
{
|
|
|
|
struct hlist_head *slot = NULL;
|
|
|
|
struct lc_element **element = NULL;
|
|
|
|
struct lru_cache *lc;
|
|
|
|
struct lc_element *e;
|
|
|
|
unsigned cache_obj_size = kmem_cache_size(cache);
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
WARN_ON(cache_obj_size < e_size);
|
|
|
|
if (cache_obj_size < e_size)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* e_count too big; would probably fail the allocation below anyways.
|
|
|
|
* for typical use cases, e_count should be few thousand at most. */
|
|
|
|
if (e_count > LC_MAX_ACTIVE)
|
|
|
|
return NULL;
|
|
|
|
|
2011-05-25 00:13:30 +00:00
|
|
|
slot = kcalloc(e_count, sizeof(struct hlist_head), GFP_KERNEL);
|
2009-09-25 23:07:19 +00:00
|
|
|
if (!slot)
|
|
|
|
goto out_fail;
|
treewide: kzalloc() -> kcalloc()
The kzalloc() function has a 2-factor argument form, kcalloc(). This
patch replaces cases of:
kzalloc(a * b, gfp)
with:
kcalloc(a * b, gfp)
as well as handling cases of:
kzalloc(a * b * c, gfp)
with:
kzalloc(array3_size(a, b, c), gfp)
as it's slightly less ugly than:
kzalloc_array(array_size(a, b), c, gfp)
This does, however, attempt to ignore constant size factors like:
kzalloc(4 * 1024, gfp)
though any constants defined via macros get caught up in the conversion.
Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.
The Coccinelle script used for this was:
// Fix redundant parens around sizeof().
@@
type TYPE;
expression THING, E;
@@
(
kzalloc(
- (sizeof(TYPE)) * E
+ sizeof(TYPE) * E
, ...)
|
kzalloc(
- (sizeof(THING)) * E
+ sizeof(THING) * E
, ...)
)
// Drop single-byte sizes and redundant parens.
@@
expression COUNT;
typedef u8;
typedef __u8;
@@
(
kzalloc(
- sizeof(u8) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(__u8) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(char) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(unsigned char) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(u8) * COUNT
+ COUNT
, ...)
|
kzalloc(
- sizeof(__u8) * COUNT
+ COUNT
, ...)
|
kzalloc(
- sizeof(char) * COUNT
+ COUNT
, ...)
|
kzalloc(
- sizeof(unsigned char) * COUNT
+ COUNT
, ...)
)
// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@
(
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * (COUNT_ID)
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * COUNT_ID
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * (COUNT_CONST)
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * COUNT_CONST
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * (COUNT_ID)
+ COUNT_ID, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * COUNT_ID
+ COUNT_ID, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * (COUNT_CONST)
+ COUNT_CONST, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * COUNT_CONST
+ COUNT_CONST, sizeof(THING)
, ...)
)
// 2-factor product, only identifiers.
@@
identifier SIZE, COUNT;
@@
- kzalloc
+ kcalloc
(
- SIZE * COUNT
+ COUNT, SIZE
, ...)
// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@
(
kzalloc(
- sizeof(TYPE) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(TYPE) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(TYPE) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(TYPE) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(THING) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kzalloc(
- sizeof(THING) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kzalloc(
- sizeof(THING) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kzalloc(
- sizeof(THING) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
)
// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@
(
kzalloc(
- sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kzalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kzalloc(
- sizeof(THING1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kzalloc(
- sizeof(THING1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kzalloc(
- sizeof(TYPE1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
|
kzalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
)
// 3-factor product, only identifiers, with redundant parens removed.
@@
identifier STRIDE, SIZE, COUNT;
@@
(
kzalloc(
- (COUNT) * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- (COUNT) * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- (COUNT) * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- (COUNT) * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
)
// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression E1, E2, E3;
constant C1, C2, C3;
@@
(
kzalloc(C1 * C2 * C3, ...)
|
kzalloc(
- (E1) * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
|
kzalloc(
- (E1) * (E2) * E3
+ array3_size(E1, E2, E3)
, ...)
|
kzalloc(
- (E1) * (E2) * (E3)
+ array3_size(E1, E2, E3)
, ...)
|
kzalloc(
- E1 * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
)
// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@
(
kzalloc(sizeof(THING) * C2, ...)
|
kzalloc(sizeof(TYPE) * C2, ...)
|
kzalloc(C1 * C2 * C3, ...)
|
kzalloc(C1 * C2, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * (E2)
+ E2, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * E2
+ E2, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * (E2)
+ E2, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * E2
+ E2, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- (E1) * E2
+ E1, E2
, ...)
|
- kzalloc
+ kcalloc
(
- (E1) * (E2)
+ E1, E2
, ...)
|
- kzalloc
+ kcalloc
(
- E1 * E2
+ E1, E2
, ...)
)
Signed-off-by: Kees Cook <keescook@chromium.org>
2018-06-12 21:03:40 +00:00
|
|
|
element = kcalloc(e_count, sizeof(struct lc_element *), GFP_KERNEL);
|
2009-09-25 23:07:19 +00:00
|
|
|
if (!element)
|
|
|
|
goto out_fail;
|
|
|
|
|
|
|
|
lc = kzalloc(sizeof(*lc), GFP_KERNEL);
|
|
|
|
if (!lc)
|
|
|
|
goto out_fail;
|
|
|
|
|
|
|
|
INIT_LIST_HEAD(&lc->in_use);
|
|
|
|
INIT_LIST_HEAD(&lc->lru);
|
|
|
|
INIT_LIST_HEAD(&lc->free);
|
2011-02-21 12:21:01 +00:00
|
|
|
INIT_LIST_HEAD(&lc->to_be_changed);
|
2009-09-25 23:07:19 +00:00
|
|
|
|
|
|
|
lc->name = name;
|
|
|
|
lc->element_size = e_size;
|
|
|
|
lc->element_off = e_off;
|
|
|
|
lc->nr_elements = e_count;
|
2011-02-21 12:21:01 +00:00
|
|
|
lc->max_pending_changes = max_pending_changes;
|
2009-09-25 23:07:19 +00:00
|
|
|
lc->lc_cache = cache;
|
|
|
|
lc->lc_element = element;
|
|
|
|
lc->lc_slot = slot;
|
|
|
|
|
|
|
|
/* preallocate all objects */
|
|
|
|
for (i = 0; i < e_count; i++) {
|
|
|
|
void *p = kmem_cache_alloc(cache, GFP_KERNEL);
|
|
|
|
if (!p)
|
|
|
|
break;
|
|
|
|
memset(p, 0, lc->element_size);
|
|
|
|
e = p + e_off;
|
|
|
|
e->lc_index = i;
|
|
|
|
e->lc_number = LC_FREE;
|
2011-02-21 12:21:01 +00:00
|
|
|
e->lc_new_number = LC_FREE;
|
2009-09-25 23:07:19 +00:00
|
|
|
list_add(&e->list, &lc->free);
|
|
|
|
element[i] = e;
|
|
|
|
}
|
|
|
|
if (i == e_count)
|
|
|
|
return lc;
|
|
|
|
|
|
|
|
/* else: could not allocate all elements, give up */
|
2022-06-18 08:25:21 +00:00
|
|
|
while (i) {
|
|
|
|
void *p = element[--i];
|
2009-09-25 23:07:19 +00:00
|
|
|
kmem_cache_free(cache, p - e_off);
|
|
|
|
}
|
|
|
|
kfree(lc);
|
|
|
|
out_fail:
|
|
|
|
kfree(element);
|
|
|
|
kfree(slot);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-02-27 08:46:18 +00:00
|
|
|
static void lc_free_by_index(struct lru_cache *lc, unsigned i)
|
2009-09-25 23:07:19 +00:00
|
|
|
{
|
|
|
|
void *p = lc->lc_element[i];
|
|
|
|
WARN_ON(!p);
|
|
|
|
if (p) {
|
|
|
|
p -= lc->element_off;
|
|
|
|
kmem_cache_free(lc->lc_cache, p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* lc_destroy - frees memory allocated by lc_create()
|
|
|
|
* @lc: the lru cache to destroy
|
|
|
|
*/
|
|
|
|
void lc_destroy(struct lru_cache *lc)
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
if (!lc)
|
|
|
|
return;
|
|
|
|
for (i = 0; i < lc->nr_elements; i++)
|
|
|
|
lc_free_by_index(lc, i);
|
|
|
|
kfree(lc->lc_element);
|
|
|
|
kfree(lc->lc_slot);
|
|
|
|
kfree(lc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* lc_reset - does a full reset for @lc and the hash table slots.
|
|
|
|
* @lc: the lru cache to operate on
|
|
|
|
*
|
|
|
|
* It is roughly the equivalent of re-allocating a fresh lru_cache object,
|
|
|
|
* basically a short cut to lc_destroy(lc); lc = lc_create(...);
|
|
|
|
*/
|
|
|
|
void lc_reset(struct lru_cache *lc)
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
INIT_LIST_HEAD(&lc->in_use);
|
|
|
|
INIT_LIST_HEAD(&lc->lru);
|
|
|
|
INIT_LIST_HEAD(&lc->free);
|
2011-02-21 12:21:01 +00:00
|
|
|
INIT_LIST_HEAD(&lc->to_be_changed);
|
2009-09-25 23:07:19 +00:00
|
|
|
lc->used = 0;
|
|
|
|
lc->hits = 0;
|
|
|
|
lc->misses = 0;
|
|
|
|
lc->starving = 0;
|
2011-02-21 12:21:01 +00:00
|
|
|
lc->locked = 0;
|
2009-09-25 23:07:19 +00:00
|
|
|
lc->changed = 0;
|
2011-02-21 12:21:01 +00:00
|
|
|
lc->pending_changes = 0;
|
2009-09-25 23:07:19 +00:00
|
|
|
lc->flags = 0;
|
|
|
|
memset(lc->lc_slot, 0, sizeof(struct hlist_head) * lc->nr_elements);
|
|
|
|
|
|
|
|
for (i = 0; i < lc->nr_elements; i++) {
|
|
|
|
struct lc_element *e = lc->lc_element[i];
|
|
|
|
void *p = e;
|
|
|
|
p -= lc->element_off;
|
|
|
|
memset(p, 0, lc->element_size);
|
|
|
|
/* re-init it */
|
|
|
|
e->lc_index = i;
|
|
|
|
e->lc_number = LC_FREE;
|
2011-02-21 12:21:01 +00:00
|
|
|
e->lc_new_number = LC_FREE;
|
2009-09-25 23:07:19 +00:00
|
|
|
list_add(&e->list, &lc->free);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* lc_seq_printf_stats - print stats about @lc into @seq
|
|
|
|
* @seq: the seq_file to print into
|
|
|
|
* @lc: the lru cache to print statistics of
|
|
|
|
*/
|
2015-04-16 08:17:51 +00:00
|
|
|
void lc_seq_printf_stats(struct seq_file *seq, struct lru_cache *lc)
|
2009-09-25 23:07:19 +00:00
|
|
|
{
|
|
|
|
/* NOTE:
|
|
|
|
* total calls to lc_get are
|
|
|
|
* (starving + hits + misses)
|
2011-02-21 12:21:01 +00:00
|
|
|
* misses include "locked" count (update from an other thread in
|
2009-09-25 23:07:19 +00:00
|
|
|
* progress) and "changed", when this in fact lead to an successful
|
|
|
|
* update of the cache.
|
|
|
|
*/
|
2015-04-15 23:18:25 +00:00
|
|
|
seq_printf(seq, "\t%s: used:%u/%u hits:%lu misses:%lu starving:%lu locked:%lu changed:%lu\n",
|
|
|
|
lc->name, lc->used, lc->nr_elements,
|
|
|
|
lc->hits, lc->misses, lc->starving, lc->locked, lc->changed);
|
2009-09-25 23:07:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct hlist_head *lc_hash_slot(struct lru_cache *lc, unsigned int enr)
|
|
|
|
{
|
|
|
|
return lc->lc_slot + (enr % lc->nr_elements);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-21 12:21:01 +00:00
|
|
|
static struct lc_element *__lc_find(struct lru_cache *lc, unsigned int enr,
|
|
|
|
bool include_changing)
|
2009-09-25 23:07:19 +00:00
|
|
|
{
|
|
|
|
struct lc_element *e;
|
|
|
|
|
|
|
|
BUG_ON(!lc);
|
|
|
|
BUG_ON(!lc->nr_elements);
|
hlist: drop the node parameter from iterators
I'm not sure why, but the hlist for each entry iterators were conceived
list_for_each_entry(pos, head, member)
The hlist ones were greedy and wanted an extra parameter:
hlist_for_each_entry(tpos, pos, head, member)
Why did they need an extra pos parameter? I'm not quite sure. Not only
they don't really need it, it also prevents the iterator from looking
exactly like the list iterator, which is unfortunate.
Besides the semantic patch, there was some manual work required:
- Fix up the actual hlist iterators in linux/list.h
- Fix up the declaration of other iterators based on the hlist ones.
- A very small amount of places were using the 'node' parameter, this
was modified to use 'obj->member' instead.
- Coccinelle didn't handle the hlist_for_each_entry_safe iterator
properly, so those had to be fixed up manually.
The semantic patch which is mostly the work of Peter Senna Tschudin is here:
@@
iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;
type T;
expression a,c,d,e;
identifier b;
statement S;
@@
-T b;
<+... when != b
(
hlist_for_each_entry(a,
- b,
c, d) S
|
hlist_for_each_entry_continue(a,
- b,
c) S
|
hlist_for_each_entry_from(a,
- b,
c) S
|
hlist_for_each_entry_rcu(a,
- b,
c, d) S
|
hlist_for_each_entry_rcu_bh(a,
- b,
c, d) S
|
hlist_for_each_entry_continue_rcu_bh(a,
- b,
c) S
|
for_each_busy_worker(a, c,
- b,
d) S
|
ax25_uid_for_each(a,
- b,
c) S
|
ax25_for_each(a,
- b,
c) S
|
inet_bind_bucket_for_each(a,
- b,
c) S
|
sctp_for_each_hentry(a,
- b,
c) S
|
sk_for_each(a,
- b,
c) S
|
sk_for_each_rcu(a,
- b,
c) S
|
sk_for_each_from
-(a, b)
+(a)
S
+ sk_for_each_from(a) S
|
sk_for_each_safe(a,
- b,
c, d) S
|
sk_for_each_bound(a,
- b,
c) S
|
hlist_for_each_entry_safe(a,
- b,
c, d, e) S
|
hlist_for_each_entry_continue_rcu(a,
- b,
c) S
|
nr_neigh_for_each(a,
- b,
c) S
|
nr_neigh_for_each_safe(a,
- b,
c, d) S
|
nr_node_for_each(a,
- b,
c) S
|
nr_node_for_each_safe(a,
- b,
c, d) S
|
- for_each_gfn_sp(a, c, d, b) S
+ for_each_gfn_sp(a, c, d) S
|
- for_each_gfn_indirect_valid_sp(a, c, d, b) S
+ for_each_gfn_indirect_valid_sp(a, c, d) S
|
for_each_host(a,
- b,
c) S
|
for_each_host_safe(a,
- b,
c, d) S
|
for_each_mesh_entry(a,
- b,
c, d) S
)
...+>
[akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
[akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
[akpm@linux-foundation.org: checkpatch fixes]
[akpm@linux-foundation.org: fix warnings]
[akpm@linux-foudnation.org: redo intrusive kvm changes]
Tested-by: Peter Senna Tschudin <peter.senna@gmail.com>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-02-28 01:06:00 +00:00
|
|
|
hlist_for_each_entry(e, lc_hash_slot(lc, enr), colision) {
|
2011-02-21 12:21:01 +00:00
|
|
|
/* "about to be changed" elements, pending transaction commit,
|
|
|
|
* are hashed by their "new number". "Normal" elements have
|
|
|
|
* lc_number == lc_new_number. */
|
|
|
|
if (e->lc_new_number != enr)
|
|
|
|
continue;
|
|
|
|
if (e->lc_new_number == e->lc_number || include_changing)
|
2009-09-25 23:07:19 +00:00
|
|
|
return e;
|
2011-02-21 12:21:01 +00:00
|
|
|
break;
|
2009-09-25 23:07:19 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-02-21 12:21:01 +00:00
|
|
|
/**
|
|
|
|
* lc_find - find element by label, if present in the hash table
|
|
|
|
* @lc: The lru_cache object
|
|
|
|
* @enr: element number
|
|
|
|
*
|
|
|
|
* Returns the pointer to an element, if the element with the requested
|
|
|
|
* "label" or element number is present in the hash table,
|
|
|
|
* or NULL if not found. Does not change the refcnt.
|
|
|
|
* Ignores elements that are "about to be used", i.e. not yet in the active
|
|
|
|
* set, but still pending transaction commit.
|
|
|
|
*/
|
|
|
|
struct lc_element *lc_find(struct lru_cache *lc, unsigned int enr)
|
2009-09-25 23:07:19 +00:00
|
|
|
{
|
2011-02-21 12:21:01 +00:00
|
|
|
return __lc_find(lc, enr, 0);
|
|
|
|
}
|
2009-09-25 23:07:19 +00:00
|
|
|
|
2011-02-21 12:21:01 +00:00
|
|
|
/**
|
|
|
|
* lc_is_used - find element by label
|
|
|
|
* @lc: The lru_cache object
|
|
|
|
* @enr: element number
|
|
|
|
*
|
|
|
|
* Returns true, if the element with the requested "label" or element number is
|
|
|
|
* present in the hash table, and is used (refcnt > 0).
|
|
|
|
* Also finds elements that are not _currently_ used but only "about to be
|
|
|
|
* used", i.e. on the "to_be_changed" list, pending transaction commit.
|
|
|
|
*/
|
|
|
|
bool lc_is_used(struct lru_cache *lc, unsigned int enr)
|
|
|
|
{
|
|
|
|
struct lc_element *e = __lc_find(lc, enr, 1);
|
|
|
|
return e && e->refcnt;
|
2009-09-25 23:07:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* lc_del - removes an element from the cache
|
|
|
|
* @lc: The lru_cache object
|
|
|
|
* @e: The element to remove
|
|
|
|
*
|
|
|
|
* @e must be unused (refcnt == 0). Moves @e from "lru" to "free" list,
|
|
|
|
* sets @e->enr to %LC_FREE.
|
|
|
|
*/
|
|
|
|
void lc_del(struct lru_cache *lc, struct lc_element *e)
|
|
|
|
{
|
|
|
|
PARANOIA_ENTRY();
|
|
|
|
PARANOIA_LC_ELEMENT(lc, e);
|
|
|
|
BUG_ON(e->refcnt);
|
|
|
|
|
2011-02-21 12:21:01 +00:00
|
|
|
e->lc_number = e->lc_new_number = LC_FREE;
|
2009-09-25 23:07:19 +00:00
|
|
|
hlist_del_init(&e->colision);
|
|
|
|
list_move(&e->list, &lc->free);
|
|
|
|
RETURN();
|
|
|
|
}
|
|
|
|
|
2011-02-21 12:21:01 +00:00
|
|
|
static struct lc_element *lc_prepare_for_change(struct lru_cache *lc, unsigned new_number)
|
2009-09-25 23:07:19 +00:00
|
|
|
{
|
|
|
|
struct list_head *n;
|
2011-02-21 12:21:01 +00:00
|
|
|
struct lc_element *e;
|
|
|
|
|
|
|
|
if (!list_empty(&lc->free))
|
|
|
|
n = lc->free.next;
|
|
|
|
else if (!list_empty(&lc->lru))
|
|
|
|
n = lc->lru.prev;
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
e = list_entry(n, struct lc_element, list);
|
|
|
|
PARANOIA_LC_ELEMENT(lc, e);
|
2009-09-25 23:07:19 +00:00
|
|
|
|
2011-02-21 12:21:01 +00:00
|
|
|
e->lc_new_number = new_number;
|
|
|
|
if (!hlist_unhashed(&e->colision))
|
|
|
|
__hlist_del(&e->colision);
|
|
|
|
hlist_add_head(&e->colision, lc_hash_slot(lc, new_number));
|
|
|
|
list_move(&e->list, &lc->to_be_changed);
|
2009-09-25 23:07:19 +00:00
|
|
|
|
2011-02-21 12:21:01 +00:00
|
|
|
return e;
|
2009-09-25 23:07:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int lc_unused_element_available(struct lru_cache *lc)
|
|
|
|
{
|
|
|
|
if (!list_empty(&lc->free))
|
|
|
|
return 1; /* something on the free list */
|
|
|
|
if (!list_empty(&lc->lru))
|
|
|
|
return 1; /* something to evict */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-03-23 04:17:36 +00:00
|
|
|
/* used as internal flags to __lc_get */
|
|
|
|
enum {
|
|
|
|
LC_GET_MAY_CHANGE = 1,
|
|
|
|
LC_GET_MAY_USE_UNCOMMITTED = 2,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct lc_element *__lc_get(struct lru_cache *lc, unsigned int enr, unsigned int flags)
|
2009-09-25 23:07:19 +00:00
|
|
|
{
|
|
|
|
struct lc_element *e;
|
|
|
|
|
|
|
|
PARANOIA_ENTRY();
|
2022-11-22 13:42:58 +00:00
|
|
|
if (test_bit(__LC_STARVING, &lc->flags)) {
|
2009-09-25 23:07:19 +00:00
|
|
|
++lc->starving;
|
|
|
|
RETURN(NULL);
|
|
|
|
}
|
|
|
|
|
2011-02-21 12:21:01 +00:00
|
|
|
e = __lc_find(lc, enr, 1);
|
|
|
|
/* if lc_new_number != lc_number,
|
|
|
|
* this enr is currently being pulled in already,
|
|
|
|
* and will be available once the pending transaction
|
|
|
|
* has been committed. */
|
2013-03-23 04:17:36 +00:00
|
|
|
if (e) {
|
|
|
|
if (e->lc_new_number != e->lc_number) {
|
|
|
|
/* It has been found above, but on the "to_be_changed"
|
|
|
|
* list, not yet committed. Don't pull it in twice,
|
|
|
|
* wait for the transaction, then try again...
|
|
|
|
*/
|
|
|
|
if (!(flags & LC_GET_MAY_USE_UNCOMMITTED))
|
|
|
|
RETURN(NULL);
|
|
|
|
/* ... unless the caller is aware of the implications,
|
|
|
|
* probably preparing a cumulative transaction. */
|
|
|
|
++e->refcnt;
|
|
|
|
++lc->hits;
|
|
|
|
RETURN(e);
|
|
|
|
}
|
|
|
|
/* else: lc_new_number == lc_number; a real hit. */
|
2009-09-25 23:07:19 +00:00
|
|
|
++lc->hits;
|
|
|
|
if (e->refcnt++ == 0)
|
|
|
|
lc->used++;
|
|
|
|
list_move(&e->list, &lc->in_use); /* Not evictable... */
|
|
|
|
RETURN(e);
|
|
|
|
}
|
2013-03-23 04:17:36 +00:00
|
|
|
/* e == NULL */
|
2009-09-25 23:07:19 +00:00
|
|
|
|
|
|
|
++lc->misses;
|
2013-03-23 04:17:36 +00:00
|
|
|
if (!(flags & LC_GET_MAY_CHANGE))
|
2011-02-21 12:21:01 +00:00
|
|
|
RETURN(NULL);
|
|
|
|
|
|
|
|
/* To avoid races with lc_try_lock(), first, mark us dirty
|
|
|
|
* (using test_and_set_bit, as it implies memory barriers), ... */
|
|
|
|
test_and_set_bit(__LC_DIRTY, &lc->flags);
|
|
|
|
|
|
|
|
/* ... only then check if it is locked anyways. If lc_unlock clears
|
|
|
|
* the dirty bit again, that's not a problem, we will come here again.
|
|
|
|
*/
|
|
|
|
if (test_bit(__LC_LOCKED, &lc->flags)) {
|
|
|
|
++lc->locked;
|
|
|
|
RETURN(NULL);
|
|
|
|
}
|
|
|
|
|
2009-09-25 23:07:19 +00:00
|
|
|
/* In case there is nothing available and we can not kick out
|
|
|
|
* the LRU element, we have to wait ...
|
|
|
|
*/
|
|
|
|
if (!lc_unused_element_available(lc)) {
|
2022-11-22 13:42:58 +00:00
|
|
|
set_bit(__LC_STARVING, &lc->flags);
|
2009-09-25 23:07:19 +00:00
|
|
|
RETURN(NULL);
|
|
|
|
}
|
|
|
|
|
2011-02-21 12:21:01 +00:00
|
|
|
/* It was not present in the active set. We are going to recycle an
|
|
|
|
* unused (or even "free") element, but we won't accumulate more than
|
|
|
|
* max_pending_changes changes. */
|
|
|
|
if (lc->pending_changes >= lc->max_pending_changes)
|
2009-09-25 23:07:19 +00:00
|
|
|
RETURN(NULL);
|
|
|
|
|
2011-02-21 12:21:01 +00:00
|
|
|
e = lc_prepare_for_change(lc, enr);
|
2009-09-25 23:07:19 +00:00
|
|
|
BUG_ON(!e);
|
|
|
|
|
|
|
|
clear_bit(__LC_STARVING, &lc->flags);
|
|
|
|
BUG_ON(++e->refcnt != 1);
|
|
|
|
lc->used++;
|
2011-02-21 12:21:01 +00:00
|
|
|
lc->pending_changes++;
|
2009-09-25 23:07:19 +00:00
|
|
|
|
|
|
|
RETURN(e);
|
|
|
|
}
|
|
|
|
|
2011-02-21 12:20:58 +00:00
|
|
|
/**
|
|
|
|
* lc_get - get element by label, maybe change the active set
|
|
|
|
* @lc: the lru cache to operate on
|
|
|
|
* @enr: the label to look up
|
|
|
|
*
|
|
|
|
* Finds an element in the cache, increases its usage count,
|
|
|
|
* "touches" and returns it.
|
|
|
|
*
|
|
|
|
* In case the requested number is not present, it needs to be added to the
|
|
|
|
* cache. Therefore it is possible that an other element becomes evicted from
|
|
|
|
* the cache. In either case, the user is notified so he is able to e.g. keep
|
|
|
|
* a persistent log of the cache changes, and therefore the objects in use.
|
|
|
|
*
|
|
|
|
* Return values:
|
|
|
|
* NULL
|
|
|
|
* The cache was marked %LC_STARVING,
|
|
|
|
* or the requested label was not in the active set
|
|
|
|
* and a changing transaction is still pending (@lc was marked %LC_DIRTY).
|
|
|
|
* Or no unused or free element could be recycled (@lc will be marked as
|
|
|
|
* %LC_STARVING, blocking further lc_get() operations).
|
|
|
|
*
|
|
|
|
* pointer to the element with the REQUESTED element number.
|
|
|
|
* In this case, it can be used right away
|
|
|
|
*
|
|
|
|
* pointer to an UNUSED element with some different element number,
|
|
|
|
* where that different number may also be %LC_FREE.
|
|
|
|
*
|
2011-02-21 12:21:01 +00:00
|
|
|
* In this case, the cache is marked %LC_DIRTY,
|
|
|
|
* so lc_try_lock() will no longer succeed.
|
|
|
|
* The returned element pointer is moved to the "to_be_changed" list,
|
|
|
|
* and registered with the new element number on the hash collision chains,
|
|
|
|
* so it is possible to pick it up from lc_is_used().
|
|
|
|
* Up to "max_pending_changes" (see lc_create()) can be accumulated.
|
|
|
|
* The user now should do whatever housekeeping is necessary,
|
|
|
|
* typically serialize on lc_try_lock_for_transaction(), then call
|
|
|
|
* lc_committed(lc) and lc_unlock(), to finish the change.
|
2011-02-21 12:20:58 +00:00
|
|
|
*
|
|
|
|
* NOTE: The user needs to check the lc_number on EACH use, so he recognizes
|
|
|
|
* any cache set change.
|
2009-09-25 23:07:19 +00:00
|
|
|
*/
|
2011-02-21 12:20:58 +00:00
|
|
|
struct lc_element *lc_get(struct lru_cache *lc, unsigned int enr)
|
2009-09-25 23:07:19 +00:00
|
|
|
{
|
2013-03-23 04:17:36 +00:00
|
|
|
return __lc_get(lc, enr, LC_GET_MAY_CHANGE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* lc_get_cumulative - like lc_get; also finds to-be-changed elements
|
|
|
|
* @lc: the lru cache to operate on
|
|
|
|
* @enr: the label to look up
|
|
|
|
*
|
|
|
|
* Unlike lc_get this also returns the element for @enr, if it is belonging to
|
|
|
|
* a pending transaction, so the return values are like for lc_get(),
|
|
|
|
* plus:
|
|
|
|
*
|
|
|
|
* pointer to an element already on the "to_be_changed" list.
|
|
|
|
* In this case, the cache was already marked %LC_DIRTY.
|
|
|
|
*
|
|
|
|
* Caller needs to make sure that the pending transaction is completed,
|
|
|
|
* before proceeding to actually use this element.
|
|
|
|
*/
|
|
|
|
struct lc_element *lc_get_cumulative(struct lru_cache *lc, unsigned int enr)
|
|
|
|
{
|
|
|
|
return __lc_get(lc, enr, LC_GET_MAY_CHANGE|LC_GET_MAY_USE_UNCOMMITTED);
|
2011-02-21 12:20:58 +00:00
|
|
|
}
|
2009-09-25 23:07:19 +00:00
|
|
|
|
2011-02-21 12:20:58 +00:00
|
|
|
/**
|
|
|
|
* lc_try_get - get element by label, if present; do not change the active set
|
|
|
|
* @lc: the lru cache to operate on
|
|
|
|
* @enr: the label to look up
|
|
|
|
*
|
|
|
|
* Finds an element in the cache, increases its usage count,
|
|
|
|
* "touches" and returns it.
|
|
|
|
*
|
|
|
|
* Return values:
|
|
|
|
* NULL
|
|
|
|
* The cache was marked %LC_STARVING,
|
|
|
|
* or the requested label was not in the active set
|
|
|
|
*
|
|
|
|
* pointer to the element with the REQUESTED element number.
|
|
|
|
* In this case, it can be used right away
|
|
|
|
*/
|
|
|
|
struct lc_element *lc_try_get(struct lru_cache *lc, unsigned int enr)
|
|
|
|
{
|
|
|
|
return __lc_get(lc, enr, 0);
|
2009-09-25 23:07:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-02-21 12:21:01 +00:00
|
|
|
* lc_committed - tell @lc that pending changes have been recorded
|
2009-09-25 23:07:19 +00:00
|
|
|
* @lc: the lru cache to operate on
|
2011-02-21 12:21:01 +00:00
|
|
|
*
|
|
|
|
* User is expected to serialize on explicit lc_try_lock_for_transaction()
|
|
|
|
* before the transaction is started, and later needs to lc_unlock() explicitly
|
|
|
|
* as well.
|
2009-09-25 23:07:19 +00:00
|
|
|
*/
|
2011-02-21 12:21:01 +00:00
|
|
|
void lc_committed(struct lru_cache *lc)
|
2009-09-25 23:07:19 +00:00
|
|
|
{
|
2011-02-21 12:21:01 +00:00
|
|
|
struct lc_element *e, *tmp;
|
|
|
|
|
2009-09-25 23:07:19 +00:00
|
|
|
PARANOIA_ENTRY();
|
2011-02-21 12:21:01 +00:00
|
|
|
list_for_each_entry_safe(e, tmp, &lc->to_be_changed, list) {
|
|
|
|
/* count number of changes, not number of transactions */
|
|
|
|
++lc->changed;
|
|
|
|
e->lc_number = e->lc_new_number;
|
|
|
|
list_move(&e->list, &lc->in_use);
|
|
|
|
}
|
|
|
|
lc->pending_changes = 0;
|
2009-09-25 23:07:19 +00:00
|
|
|
RETURN();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* lc_put - give up refcnt of @e
|
|
|
|
* @lc: the lru cache to operate on
|
|
|
|
* @e: the element to put
|
|
|
|
*
|
|
|
|
* If refcnt reaches zero, the element is moved to the lru list,
|
|
|
|
* and a %LC_STARVING (if set) is cleared.
|
|
|
|
* Returns the new (post-decrement) refcnt.
|
|
|
|
*/
|
|
|
|
unsigned int lc_put(struct lru_cache *lc, struct lc_element *e)
|
|
|
|
{
|
|
|
|
PARANOIA_ENTRY();
|
|
|
|
PARANOIA_LC_ELEMENT(lc, e);
|
|
|
|
BUG_ON(e->refcnt == 0);
|
2011-02-21 12:21:01 +00:00
|
|
|
BUG_ON(e->lc_number != e->lc_new_number);
|
2009-09-25 23:07:19 +00:00
|
|
|
if (--e->refcnt == 0) {
|
|
|
|
/* move it to the front of LRU. */
|
|
|
|
list_move(&e->list, &lc->lru);
|
|
|
|
lc->used--;
|
2011-02-21 12:20:55 +00:00
|
|
|
clear_bit_unlock(__LC_STARVING, &lc->flags);
|
2009-09-25 23:07:19 +00:00
|
|
|
}
|
|
|
|
RETURN(e->refcnt);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* lc_element_by_index
|
|
|
|
* @lc: the lru cache to operate on
|
|
|
|
* @i: the index of the element to return
|
|
|
|
*/
|
|
|
|
struct lc_element *lc_element_by_index(struct lru_cache *lc, unsigned i)
|
|
|
|
{
|
|
|
|
BUG_ON(i >= lc->nr_elements);
|
|
|
|
BUG_ON(lc->lc_element[i] == NULL);
|
|
|
|
BUG_ON(lc->lc_element[i]->lc_index != i);
|
|
|
|
return lc->lc_element[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-04-16 22:46:26 +00:00
|
|
|
* lc_seq_dump_details - Dump a complete LRU cache to seq in textual form.
|
2009-09-25 23:07:19 +00:00
|
|
|
* @lc: the lru cache to operate on
|
|
|
|
* @seq: the &struct seq_file pointer to seq_printf into
|
2014-05-08 11:39:35 +00:00
|
|
|
* @utext: user supplied additional "heading" or other info
|
2009-09-25 23:07:19 +00:00
|
|
|
* @detail: function pointer the user may provide to dump further details
|
2014-05-08 11:39:35 +00:00
|
|
|
* of the object the lc_element is embedded in. May be NULL.
|
|
|
|
* Note: a leading space ' ' and trailing newline '\n' is implied.
|
2009-09-25 23:07:19 +00:00
|
|
|
*/
|
|
|
|
void lc_seq_dump_details(struct seq_file *seq, struct lru_cache *lc, char *utext,
|
|
|
|
void (*detail) (struct seq_file *, struct lc_element *))
|
|
|
|
{
|
|
|
|
unsigned int nr_elements = lc->nr_elements;
|
|
|
|
struct lc_element *e;
|
|
|
|
int i;
|
|
|
|
|
2014-05-08 11:39:35 +00:00
|
|
|
seq_printf(seq, "\tnn: lc_number (new nr) refcnt %s\n ", utext);
|
2009-09-25 23:07:19 +00:00
|
|
|
for (i = 0; i < nr_elements; i++) {
|
|
|
|
e = lc_element_by_index(lc, i);
|
2014-05-08 11:39:35 +00:00
|
|
|
if (e->lc_number != e->lc_new_number)
|
|
|
|
seq_printf(seq, "\t%5d: %6d %8d %6d ",
|
|
|
|
i, e->lc_number, e->lc_new_number, e->refcnt);
|
|
|
|
else
|
|
|
|
seq_printf(seq, "\t%5d: %6d %-8s %6d ",
|
|
|
|
i, e->lc_number, "-\"-", e->refcnt);
|
|
|
|
if (detail)
|
2009-09-25 23:07:19 +00:00
|
|
|
detail(seq, e);
|
2014-05-08 11:39:35 +00:00
|
|
|
seq_putc(seq, '\n');
|
2009-09-25 23:07:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_SYMBOL(lc_create);
|
|
|
|
EXPORT_SYMBOL(lc_reset);
|
|
|
|
EXPORT_SYMBOL(lc_destroy);
|
|
|
|
EXPORT_SYMBOL(lc_del);
|
|
|
|
EXPORT_SYMBOL(lc_try_get);
|
|
|
|
EXPORT_SYMBOL(lc_find);
|
|
|
|
EXPORT_SYMBOL(lc_get);
|
|
|
|
EXPORT_SYMBOL(lc_put);
|
2011-02-21 12:21:01 +00:00
|
|
|
EXPORT_SYMBOL(lc_committed);
|
2009-09-25 23:07:19 +00:00
|
|
|
EXPORT_SYMBOL(lc_element_by_index);
|
|
|
|
EXPORT_SYMBOL(lc_seq_printf_stats);
|
|
|
|
EXPORT_SYMBOL(lc_seq_dump_details);
|
2011-02-21 12:21:01 +00:00
|
|
|
EXPORT_SYMBOL(lc_try_lock);
|
|
|
|
EXPORT_SYMBOL(lc_is_used);
|
2013-03-23 04:17:36 +00:00
|
|
|
EXPORT_SYMBOL(lc_get_cumulative);
|