42 lines
1.5 KiB
C
42 lines
1.5 KiB
C
// tiny_class_policy_box.h - Class-scoped policy box for Tiny front-end
|
||
//
|
||
// Purpose:
|
||
// - Centralize per-class feature toggles (Page Box / Warm Pool / caps).
|
||
// - Keep hot paths free from direct ENV parsing or scattered conditionals.
|
||
// - Defaults:
|
||
// legacy (デフォルト): Page Box は C5–C7、Warm は C0–C7 で cap は小さめ
|
||
// c5_7_only: Page/Warm とも C5–C7 のみ
|
||
// tinyplus_all: 予備プロファイル(当面 legacy と同等)
|
||
// - ENV: HAKMEM_TINY_POLICY_PROFILE=legacy|c5_7_only|tinyplus_all
|
||
// - Learner が入るまでは固定ポリシーで運用し、Hot path は tiny_policy_get() を見るだけに保つ。
|
||
|
||
#ifndef TINY_CLASS_POLICY_BOX_H
|
||
#define TINY_CLASS_POLICY_BOX_H
|
||
|
||
#include <stdatomic.h>
|
||
#include <stdint.h>
|
||
#include "../hakmem_tiny_config.h"
|
||
|
||
typedef struct TinyClassPolicy {
|
||
uint8_t page_box_enabled; // Enable Tiny Page Box for this class
|
||
uint8_t warm_enabled; // Enable Warm Pool for this class
|
||
uint8_t warm_cap; // Max warm SuperSlabs to keep (per-thread)
|
||
uint8_t reserved;
|
||
} TinyClassPolicy;
|
||
|
||
extern TinyClassPolicy g_tiny_class_policy[TINY_NUM_CLASSES];
|
||
|
||
// Initialize policy table once (idempotent).
|
||
void tiny_class_policy_init_once(void);
|
||
|
||
// Lightweight accessor for hot paths.
|
||
static inline const TinyClassPolicy* tiny_policy_get(int class_idx) {
|
||
if (class_idx < 0 || class_idx >= TINY_NUM_CLASSES) {
|
||
return NULL;
|
||
}
|
||
tiny_class_policy_init_once();
|
||
return &g_tiny_class_policy[class_idx];
|
||
}
|
||
|
||
#endif // TINY_CLASS_POLICY_BOX_H
|