code wiki / _hdl_build / nx_resmon_lib.nx

nx_resmon_lib.nx

buildroot/runtime/_hdl_build/nx_resmon_lib.nx

19011 B306 linesdepth 3pulls 4 transitivereach 83 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 3 imports · 13 importers

nx_syscalls.nx nx_itoa_lib.nx nx_logtail.nx nx_resmon_lib.nx nx_adopt.nx nx_cpuid.nx nx_dstate.nx nx_ioadmit_lib.nx nx_ioae_lib_test_20260907.nx nx_memvel_gate.nx nx_procchurn_lib.nx nx_read_file_gate.nx nx_resmon.nx nx_resmon_gate.nx

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

240const RM_BLIND_ALARM_WINDOWS: i64 = 2

functions

27func rm_trend_read_tail(logpath: *u8, lbuf: *u8, cap: i64, env: *i64) -> i64
called by 2: rm_trendmain calls 1: lt_read_tail
31func rm_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
32func rm_puts(s: *u8) -> i64 { sys_write(1, s, rm_slen(s)); return 0 }
35func rm_num(v: i64) -> i64
52func rm_read(path: *u8, buf: *u8, cap: i64) -> i64
70func rm_field(buf: *u8, n: i64, key: *u8) -> i64
106func rm_conf(cbuf: *u8, cn: i64, key: *u8, dflt: i64) -> i64
129func rm_is_leaker(vsz: i64, vpk: i64, rss: i64, swap: i64, min_kb: i64) -> i64
called by 3: mainmainmain
151func rm_verdict(swused_pm: i64, avail_pm: i64, leakers: i64, leak_observed: i64,
168func 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 }
169func rm_lnum(b: *u8, off: i64, v: i64) -> i64
191func rm_sustained_count(acnt: *i64, n: i64, rounds: i64) -> i64
called by 2: mainmain
221func rm_blind_class(leak_observed: i64, refused_age: i64, max_age: i64) -> i64
called by 2: mainmain
245func rm_blind_sev(leak_observed: i64, leak_age: i64, max_age: i64) -> i64
called by 1: rm_verdict_blind
271func rm_disk_sev(avail_bytes: i64, amber_bytes: i64, red_bytes: i64) -> i64
called by 2: mainrm_verdict_disk
282func rm_verdict_disk(swused_pm: i64, avail_pm: i64, leakers: i64, leak_observed: i64,
called by 1: main calls 2: rm_verdict_blindrm_disk_sev
297func rm_verdict_blind(swused_pm: i64, avail_pm: i64, leakers: i64, leak_observed: i64,