code wiki / _hdl_build / nx_resmon_lib.nx
nx_resmon_lib.nx
buildroot/runtime/_hdl_build/nx_resmon_lib.nx
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 3 imports · 13 importers
diagram shows first 10 each side; +0 more imports, +3 more importers in the complete lists below.
imports: nx_syscalls.nxnx_itoa_lib.nxnx_logtail.nx
imported by: nx_adopt.nxnx_cpuid.nxnx_dstate.nxnx_ioadmit_lib.nxnx_ioae_lib_test_20260907.nxnx_memvel_gate.nxnx_procchurn_lib.nxnx_read_file_gate.nxnx_resmon.nxnx_resmon_gate.nxnx_sota_why.nxnx_ts_drain_lib.nxnx_ts_slot_lib.nx
structs
| none |
consts
| 240 | const RM_BLIND_ALARM_WINDOWS: i64 = 2 |
functions
| 27 | func rm_trend_read_tail(logpath: *u8, lbuf: *u8, cap: i64, env: *i64) -> i64 |
| 31 | func rm_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 32 | func rm_puts(s: *u8) -> i64 { sys_write(1, s, rm_slen(s)); return 0 } |
| 35 | func rm_num(v: i64) -> i64 |
| 52 | func rm_read(path: *u8, buf: *u8, cap: i64) -> i64 called by 10: mainioa_measureioa_dirtyioa_diskstatsioa_measureioa_dirty+4 calls 3: sys_openat_rdsys_readsys_close |
| 70 | func rm_field(buf: *u8, n: i64, key: *u8) -> i64 |
| 106 | func rm_conf(cbuf: *u8, cn: i64, key: *u8, dflt: i64) -> i64 |
| 129 | func rm_is_leaker(vsz: i64, vpk: i64, rss: i64, swap: i64, min_kb: i64) -> i64 |
| 151 | func rm_verdict(swused_pm: i64, avail_pm: i64, leakers: i64, leak_observed: i64, |
| 168 | func rm_lcat(b: *u8, off: i64, s: *u8) -> i64 { var o: i64 = off; var j: i64 = 0; while s[j] != (0 as u8) { b[o] = s[j]; o = o + 1; j = j + 1 } return o } |
| 169 | func rm_lnum(b: *u8, off: i64, v: i64) -> i64 |
| 191 | func rm_sustained_count(acnt: *i64, n: i64, rounds: i64) -> i64 |
| 221 | func rm_blind_class(leak_observed: i64, refused_age: i64, max_age: i64) -> i64 |
| 245 | func rm_blind_sev(leak_observed: i64, leak_age: i64, max_age: i64) -> i64 called by 1: rm_verdict_blind |
| 271 | func rm_disk_sev(avail_bytes: i64, amber_bytes: i64, red_bytes: i64) -> i64 |
| 282 | func rm_verdict_disk(swused_pm: i64, avail_pm: i64, leakers: i64, leak_observed: i64, |
| 297 | func rm_verdict_blind(swused_pm: i64, avail_pm: i64, leakers: i64, leak_observed: i64, |