code wiki / _hdl_build / nx_ctxtop.nx

nx_ctxtop.nx

buildroot/runtime/_hdl_build/nx_ctxtop.nx

11792 B229 linesdepth 5pulls 6 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_ctxtop.nx -- WHO is producing the context switches. The producer-finder for seq1340. nx_procchurn measured the box at 81k-93k ctxsw/sec in every sample (the one CONSTANT in the perf lane) and DISPROVED forks as the driver -- forks swing 15->179->10 while ctxsw stays flat. A box-level rate names no culprit, so this walks /proc/<pid>/status twice and attributes the switches per process. LAW (rising-debt-means-find-the-producer): a rate with no owner is a symptom, not a diagnosis. ★Reports voluntary and nonvoluntary SEPARATELY because they demand OPPOSITE fixes: voluntary = the process blocked itself (poll/read/sleep) -> batch, lengthen polls, go event-driven; nonvoluntary = the scheduler preempted it -> reduce concurrency. A tool printing only the sum sends the fix the wrong way. Exit code = 0 when the sample completed, 3 UNMEASURED (fail-closed, never a confident empty answer). license_tier: ORIGINAL Read-only. No hw writes (Rule 26). expect_exit: 0

dependencies 2 imports · 0 importers

nx_ctxtop_lib.nx nx_proc_ctl.nx nx_ctxtop.nx

imports: nx_ctxtop_lib.nxnx_proc_ctl.nx

imported by: nobody (leaf or entry point)

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

main rm_conf rm_field rm_slen ct_load_centi ct_admit sys_now_us sys_mmap sys_clock_gettime_mono ct_scan sys_getdents64 dirent_reclen dirent_name rm_field ↻ sys_sleep_ms sys_mmap ↻ sys_munmap ct_find pc_rate ct_topk_insert ct_share_permil ct_putname pc_catn sys_munmap ↻ sys_munmap ↻

structs

none

consts

16const CT_MAXP: i64 = 2048
17const CT_TABLE_BYTES: i64 = 16384
18const CT_DIRBUF: i64 = 65536
19const CT_STATBUF: i64 = 4096
20const CT_TOPK: i64 = 8
21const CT_TOPK_BYTES: i64 = 128
22const CT_WINDOW_MS: i64 = 3000
23const CT_US_PER_MS: i64 = 1000
24const CT_NAMEOFF: i64 = 6
25const CT_EXIT_UNMEASURED: i64 = 3
26const CT_SLASH: i64 = 47
27const CT_EXIT_REFUSED: i64 = 4
28const CT_ADMIT_DEFAULT: i64 = 800
29const CT_CONFBUF: i64 = 4096
30const CT_LOADBUF: i64 = 128

functions

34func ct_scan(pids: *i64, vols: *i64, nvs: *i64, dbuf: *u8, path: *u8, sbuf: *u8) -> i64
128func ct_putname(pid: i64, path: *u8, sbuf: *u8) -> i64
called by 1: main calls 2: pc_catnsys_munmap
150func main() -> i64