39 lines
1.5 KiB
C
39 lines
1.5 KiB
C
|
|
// tiny_mem_stats_box.h - Lightweight memory accounting for Tiny front boxes
|
||
|
|
//
|
||
|
|
// Purpose:
|
||
|
|
// - Provide coarse-grained byte counters for major Tiny front allocations
|
||
|
|
// (Unified Cache buffers, Warm Pool TLS state, Page Box TLS state,
|
||
|
|
// TLS magazine/front caches, and policy/stats tables).
|
||
|
|
// - Keep overhead near-zero: helpers are simple fetch-adds, typically called
|
||
|
|
// at init time when the structures are allocated.
|
||
|
|
//
|
||
|
|
// Usage:
|
||
|
|
// - Call tiny_mem_stats_add_*() at allocation/free sites (positive/negative).
|
||
|
|
// - Call tiny_mem_stats_dump() when HAKMEM_TINY_MEM_DUMP is set to emit one
|
||
|
|
// summary line to stderr (values reported in KB).
|
||
|
|
|
||
|
|
#ifndef TINY_MEM_STATS_BOX_H
|
||
|
|
#define TINY_MEM_STATS_BOX_H
|
||
|
|
|
||
|
|
#include <stddef.h>
|
||
|
|
#include <stdint.h>
|
||
|
|
#include <sys/types.h>
|
||
|
|
|
||
|
|
// Byte counters (signed to allow subtracting on free paths)
|
||
|
|
extern _Atomic long long g_tiny_mem_unified_cache_bytes;
|
||
|
|
extern _Atomic long long g_tiny_mem_warm_pool_bytes;
|
||
|
|
extern _Atomic long long g_tiny_mem_page_box_bytes;
|
||
|
|
extern _Atomic long long g_tiny_mem_tls_magazine_bytes;
|
||
|
|
extern _Atomic long long g_tiny_mem_policy_stats_bytes;
|
||
|
|
|
||
|
|
void tiny_mem_stats_add_unified(ssize_t bytes);
|
||
|
|
void tiny_mem_stats_add_warm(ssize_t bytes);
|
||
|
|
void tiny_mem_stats_add_pagebox(ssize_t bytes);
|
||
|
|
void tiny_mem_stats_add_tls_magazine(ssize_t bytes);
|
||
|
|
void tiny_mem_stats_add_policy_stats(ssize_t bytes);
|
||
|
|
|
||
|
|
// Dump one line summary (values in KB) if hooked by caller.
|
||
|
|
void tiny_mem_stats_dump(void);
|
||
|
|
|
||
|
|
#endif // TINY_MEM_STATS_BOX_H
|