code wiki / _hdl_build / nx_resmon_lib.nx

nx_resmon_lib.nx

buildroot/runtime/_hdl_build/nx_resmon_lib.nx

5071 B123 linesdepth 2pulls 2 transitivereach 16 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_resmon_lib.nx -- the PURE, GATEABLE core of nx_resmon (debt seq1005). Split out per rule 9 (single responsibility) and rule 15 (DRY): the organ owns the /proc walk and the printing, this lib owns the two predicates that actually encode the policy -- rm_is_leaker : what counts as a leaking process rm_verdict : how measurements become GREEN / AMBER / RED Keeping them here means the gate exercises the SAME code the organ runs, not a reimplementation. Everything here is a pure function of its arguments (rm_field/rm_conf parse a caller-owned buffer), so the gate needs no /proc, no files and no fixtures on disk. license_tier: ORIGINAL

dependencies 1 imports · 5 importers

nx_syscalls.nx nx_resmon_lib.nx nx_adopt.nx nx_cpuid.nx nx_procchurn_lib.nx nx_resmon.nx nx_resmon_gate.nx

imports: nx_syscalls.nx

imported by: nx_adopt.nxnx_cpuid.nxnx_procchurn_lib.nxnx_resmon.nxnx_resmon_gate.nx

structs

none

consts

none

functions

13func rm_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
14func rm_puts(s: *u8) -> i64 { sys_write(1, s, rm_slen(s)); return 0 }
15func rm_num(v: i64) -> i64
30func rm_read(path: *u8, buf: *u8, cap: i64) -> i64
48func rm_field(buf: *u8, n: i64, key: *u8) -> i64
84func rm_conf(cbuf: *u8, cn: i64, key: *u8, dflt: i64) -> i64
called by 4: mainmainmainmain calls 1: rm_field
97func rm_is_leaker(vsz: i64, vpk: i64, rss: i64, swap: i64, min_kb: i64) -> i64
called by 2: mainmain
112func rm_verdict(swused_pm: i64, avail_pm: i64, leakers: i64,
called by 2: mainmain