mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-18 11:09:56 -04:00
Say which guest region holds the memory when the process grows.
The commit census of NX2NAVI_TRACE=perf with NX2NAVI_MEM_CENSUS=1 reported the process's committed memory by kind, which lumps every guest region together. memory.c mem_guest_census now walks each reserved region (aslr, stack, heap, alias, kernel, host functions) beside it and reports the bytes committed in each, so a process that has grown to thirty gigabytes (issues #203, #215, #240) says which region to look at. Like the census, it runs only when mem_census asks for it, since the walk holds the address-space lock the game's threads take at every page fault. On the Kokiri route the answer was the aslr region at 28 to 31 GB, the heap at 7.5 GB and the alias window at 2.7 GB while the physical-memory pool itself stayed near its limit, which is what the device-loss crash follows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -708,3 +708,30 @@ void mem_kernel_free(void *p, uint64_t size) {
|
||||
kfree_list[k] = f;
|
||||
plat_mutex_unlock(&klock);
|
||||
}
|
||||
|
||||
// NX2NAVI_TRACE=perf: how many bytes of each guest region are committed, so a process that has grown says which region
|
||||
// holds the memory. A region is reserved whole at start-up and committed page by page, so the walk reads each run of
|
||||
// pages of the same state; the alias window is the largest and costs the most steps when it is full.
|
||||
void mem_guest_census(uint64_t frame) {
|
||||
const RtGuestLayout *g = mem_layout();
|
||||
const struct { const char *name; RtRange r; } reg[] = {
|
||||
{"aslr", g->aslr}, {"stack", g->stack}, {"heap", g->heap},
|
||||
{"alias", g->alias}, {"kernel", g->kernel}, {"hostfn", g->hostfn},
|
||||
};
|
||||
char line[400];
|
||||
int o = snprintf(line, sizeof line, "mem: guest regions at frame %llu (MiB committed):",
|
||||
(unsigned long long)frame);
|
||||
uint64_t all = 0;
|
||||
for (unsigned i = 0; i < sizeof reg / sizeof *reg && o < (int)sizeof line - 40; i++) {
|
||||
uint64_t x = reg[i].r.base, end = reg[i].r.base + reg[i].r.size, committed = 0, b = 0;
|
||||
while (x < end) {
|
||||
int st = plat_mem_state(x, end, &b);
|
||||
if (b <= x) break;
|
||||
if (st >= 0) committed += b - x; // a PLAT_PROT_* state: these pages are committed
|
||||
x = b;
|
||||
}
|
||||
all += committed;
|
||||
o += snprintf(line + o, sizeof line - o, " %s %.0f", reg[i].name, committed / 1048576.0);
|
||||
}
|
||||
rt_log("%s; all %.0f", line, all / 1048576.0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user