libkdumpfile-0.5.4
Kernel coredump file access
|
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. | |
Simple cache.
The cache is divided into five partitions:
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.