33typedef enum : uint8_t {
52typedef enum : uint32_t {
94 if (l->
prev[f] != -1) {
96 }
else if (*head == f) {
99 if (l->
next[f] != -1) {
101 }
else if (*tail == f) {
166 const size_t required =
sizeof(
slru_t) + ((
size_t)c->
capacity * 2U *
sizeof(int32_t));
171 l->
prev = (int32_t*)&l[1];
254 const int32_t f = (int32_t)frame;
315 .state_base_bytes =
sizeof(
slru_t),
316 .state_frame_bytes = 2U *
sizeof(int32_t),
327typedef enum : uint8_t {
360 return (hand ==
nullptr) ? 1 : 0;
456 const uint32_t f = *hand;
473 .state_base_bytes =
sizeof(uint32_t),
474 .state_frame_bytes = 0U,
Eviction-policy comparison harness for the #147 memory-hierarchy decision record: the DIP seam every ...
const cache_policy_t g_cb_policy_srrip
SRRIP: the 2-bit re-reference-interval candidate (src/policy_scanresist.c).
const cache_policy_t g_cb_policy_slru
Segmented-LRU: the scan-resistant candidate (src/policy_scanresist.c).
static void internal_slru_access(cb_cache_t *c, uint32_t frame)
SLRU hit hook: promote or refresh frame on re-reference.
static int internal_slru_init(cb_cache_t *c)
Bind SLRU state: two LRU segments over shared frame arrays.
slru_dim_t
Protected-segment share of the cache, in percent, plus associated scaling and metadata constants.
@ k_slru_protected_pct
Protected-segment target, percent of capacity.
@ k_slru_pct_full_scale
Divisor for percent-to-frame-count conversion.
@ k_slru_meta_bytes
Per-frame metadata: 1 B tag + 8 B list indices.
static void internal_slru_unlink(slru_t *l, int32_t f, int32_t *head, int32_t *tail)
Detach f from the list whose head/tail pointers are given.
static uint32_t internal_srrip_victim(cb_cache_t *c, uint32_t *scanned)
Choose the SRRIP victim by aging RRPVs to the maximum.
slru_seg_t
Per-frame segment tag stored in frame meta[0].
@ k_slru_protected
Frame is in the protected segment.
@ k_slru_probation
Frame is in the probationary segment.
static uint32_t internal_slru_victim(cb_cache_t *c, uint32_t *scanned)
Choose the SLRU victim: probationary LRU first, else protected LRU.
rrip_rrpv_t
RRIP re-reference prediction values (2-bit).
@ k_rrip_max
Furthest – the eviction candidate.
@ k_rrip_long
Distant re-reference (fresh insert).
@ k_rrip_near
Immediate re-reference (just hit).
static void internal_slru_push_head(slru_t *l, int32_t f, int32_t *head, int32_t *tail)
Push f to the MRU head of the segment.
static void internal_srrip_deinit(cb_cache_t *c)
Release SRRIP state (the sweep hand).
static int internal_srrip_init(cb_cache_t *c)
Bind SRRIP state: a sweep hand over the frame ring.
static void internal_srrip_access(cb_cache_t *c, uint32_t frame)
SRRIP hit hook: predict an immediate re-reference for frame.
static void internal_slru_insert(cb_cache_t *c, uint32_t frame)
SLRU insert hook: admit a fresh frame to the probationary segment.
static void internal_srrip_insert(cb_cache_t *c, uint32_t frame)
SRRIP insert hook: predict a distant re-reference for frame.
static void internal_slru_deinit(cb_cache_t *c)
Release SLRU state (control block + shared index arrays).
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
static void internal_slru_access(ra8_keycache_t *kc, int32_t f)
SLRU re-reference: promote / refresh cell f on a hit.
The replacement-policy DIP seam (the eventual firmware Layer-2 seam).
The fixed-capacity frame cache a policy manages.
cb_frame_t * frames
capacity frame slots.
size_t policy_workspace_bytes
Bytes available at the storage.
void * policy_data
Policy-private state (rings, stacks, sketch).
uint32_t capacity
Number of frame slots (the RAM budget knob).
void * policy_workspace
Caller-provided policy-state storage.
uint8_t meta[16]
Per-policy scratch (ref bits, RRPV, list links).
Two LRU segments threaded through shared prev/next frame arrays.
int32_t * next
next[f] toward LRU within the frame's segment.
int32_t pb_head
Probationary MRU, or -1.
uint32_t pt_cap
Protected-segment capacity.
int32_t * prev
prev[f] toward MRU within the frame's segment.
int32_t pb_tail
Probationary LRU (first evicted), or -1.
int32_t pt_head
Protected MRU, or -1.
int32_t pt_tail
Protected LRU, or -1.
uint32_t pt_count
Frames currently in the protected segment.