code wiki / (root) / nx_resgov.nx

nx_resgov.nx

buildroot/runtime/nx_resgov.nx

21027 B396 linesdepth 3pulls 4 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_resgov.nx -- THE UNIFIED RESOURCE GOVERNOR (one-shot, cron-invoked every minute). nx_resgov [conf] [dry] conf default knowledge/resgov.conf ; `dry` = decide + log, never signal Walks EVERY process, meters VmRSS + VmSwap (the resource that actually hurts), remembers each process's footprint between runs to compute GROWTH VELOCITY, and escalates gracefully long before a ceiling is reached. Default-covered: an unlisted process is governed by the default cap, not ignored. Death is decided here; RESPAWN stays the guard's job (single responsibility -- no dueling supervisors). STATE (velocity memory): knowledge/status/resgov.state, rows `pid:starttime footprint_kb epoch level_ts`. ★IDENTITY IS pid+starttime, NEVER pid ALONE -- Linux reuses pids, and a reused pid would make the velocity of a brand-new process look like the growth of the dead one it replaced, which is how a predictive breaker kills innocents. license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_vsz_watchdog_core.nx nx_resgov_core.nx nx_resgov.nx

imports: nx_syscalls.nxnx_vsz_watchdog_core.nxnx_resgov_core.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main g_streq sys_mmap vw_read sys_openat_rd sys_read sys_close g_puts sys_write g_find_sp g_skip_sp vw_num_at rg_meminfo_kb rg_headroom_permil rg_swap_permil rg_system_pressured sys_now_realtime_sec sys_mmap ↻ sys_clock_gettime_real vw_selfpid sys_mmap ↻ vw_read ↻ sys_munmap vw_num_at ↻ sys_openat_rd ↻ sys_getdents64 dirent_reclen dirent_name g_slen vw_rss_kb_of vw_status_kb_of sys_mmap ↻ vw_read ↻ sys_munmap ↻ vw_status_kb vw_slen sys_mmap ↻ vw_num_at ↻ sys_munmap ↻ vw_status_kb_of ↻

structs

none

consts

18const RG_MAGIC_4096: i64 = 4096
19const RG_MAGIC_4095: i64 = 4095
20const RG_MAGIC_3600: i64 = 3600
21const RG_MAGIC_1024: i64 = 1024
22const RG_MAGIC_1048576: i64 = 1048576
24const RG_CONF_CAP: i64 = 16384
25const RG_STATE_CAP: i64 = 262144
26const RG_DIR_CAP: i64 = 65536
27const RG_CMD_CAP: i64 = 8192
28const RG_MAXROWS: i64 = 64
29const RG_MAXPROC: i64 = 2048
30const RG_STATE_PATH: *u8 = "knowledge/status/resgov.state"

functions

32func g_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 1: main calls 1: sys_write
33func g_putn(v: i64) -> i64
called by 1: main calls 2: sys_writesys_mmap
43func g_streq(a: *u8, b: *u8) -> i64
called by 1: main
49func g_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 1: main
54func g_find_sp(buf: *u8, from: i64, to: i64) -> i64
called by 1: main
61func g_skip_sp(buf: *u8, from: i64, to: i64) -> i64
called by 1: main
67func g_app(buf: *u8, p: i64, s: *u8) -> i64 { var i: i64 = 0; var q: i64 = p; while s[i] != (0 as u8) { buf[q] = s[i]; q = q + 1; i = i + 1 } return q }
called by 2: g_starttimemain
68func g_appn(buf: *u8, p: i64, v: i64) -> i64
called by 1: main calls 1: sys_mmap
82func g_starttime(dirname: *u8) -> i64
called by 1: main calls 4: sys_mmapg_appvw_readvw_num_at
117func main(argc: i64, argv: *i64) -> i64