Loading...
Searching...
No Matches
cache Struct Reference

Simple cache. More...

## Data Fields

unsigned | split
| Split point between probed and precious entries (index of MRU probed entry).
unsigned | nprec
| Number of cached precious entries.
unsigned | ngprec
| Number of ghost precious entries.
unsigned | nprobe
| Number of cached probe entries.
unsigned | ngprobe
| Number of ghost probe entries.
unsigned | dprobe
| Desired number of cached probe entries.
unsigned | cap
| Total cache capacity.
unsigned | inflight
| Index of first in-flight entry.
unsigned | ninflight
| Number of in-flight entries.
kdump_attr_value_t | hits
| Cache hits.
kdump_attr_value_t | misses
| Cache misses.
size_t | elemsize
| Element data size.
void * | data
| Actual cache data.
cache_entry_cleanup_fn * | entry_cleanup
| Cache entry destructor.
void * | cleanup_data
| User-supplied data for the destructor.
struct cache_entry | ce []
| Cache entries.

## Detailed Description

Simple cache.

The cache is divided into five partitions:

1. probed: cached entries that have been hit only once
2. precious: cached entries that have been hit more than once
3. ghost probe: evicted entries from the probed list
4. ghost precious: evicted entries from the precious list
5. unused: entries that haven't been used yet

Cached entries have a non-NULL data pointer. Ghost entries do not have any data, so their data pointer is NULL.

The cache is implemented as a circular list. This allows to move around entries without copying much data even if the cache is large. The list is organized as follows:

              <-- ngprobe --> <- nprobe -> <- nprec -> <--- ngprec --->
    +--------+---------------+------------+-----------+----------------+
    | unused | ghost probed  |   probed   | precious  | ghost precious |
    +--------+---------------+------------+-----------+----------------+
            ^               ^            ^             ^                ^
            eprobe          gprobe     split       gprec            eprec

Only the split index and the four sizes are stored in the data structure. The remaining pointers are found as a side effect of searching the cache, and they are stored in cache_search.

Any partition may be empty; some pointers will share the same value in that case.

Note that since the list is circular, the unused partition is between the ghost probed and ghost precious partitions. This part of the cache is usually empty after it has been used for some time.

Entries that have been allocated for I/O but not yet committed back, are removed from the main list and added to an in-flight list. They are returned back to the list later when the user calls cache_insert or cache_discard on the in-flight entry.

The documentation for this struct was generated from the following file:

- src/kdumpfile/cache.c