nx_resgov.nx
buildroot/runtime/nx_resgov.nx
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
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
structs
| none |
consts
| 18 | const RG_MAGIC_4096: i64 = 4096 |
| 19 | const RG_MAGIC_4095: i64 = 4095 |
| 20 | const RG_MAGIC_3600: i64 = 3600 |
| 21 | const RG_MAGIC_1024: i64 = 1024 |
| 22 | const RG_MAGIC_1048576: i64 = 1048576 |
| 24 | const RG_CONF_CAP: i64 = 16384 |
| 25 | const RG_STATE_CAP: i64 = 262144 |
| 26 | const RG_DIR_CAP: i64 = 65536 |
| 27 | const RG_CMD_CAP: i64 = 8192 |
| 28 | const RG_MAXROWS: i64 = 64 |
| 29 | const RG_MAXPROC: i64 = 2048 |
| 30 | const RG_STATE_PATH: *u8 = "knowledge/status/resgov.state" |
functions
| 32 | func 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 } |
| 33 | func g_putn(v: i64) -> i64 |
| 43 | func g_streq(a: *u8, b: *u8) -> i64 called by 1: main |
| 49 | func g_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } called by 1: main |
| 54 | func g_find_sp(buf: *u8, from: i64, to: i64) -> i64 called by 1: main |
| 61 | func g_skip_sp(buf: *u8, from: i64, to: i64) -> i64 called by 1: main |
| 67 | func 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 } |
| 68 | func g_appn(buf: *u8, p: i64, v: i64) -> i64 |
| 82 | func g_starttime(dirname: *u8) -> i64 |
| 117 | func main(argc: i64, argv: *i64) -> i64 |