From 26e6bc390cc9f466448a7470420d9de750e7611e Mon Sep 17 00:00:00 2001 From: Arthur Hanson Rasmusson Date: Tue, 29 Sep 2026 16:32:03 -0400 Subject: sema-svc: bounded diagnostics for GR counter writes; scanner guarantees counter-page delta - rel-apply/publish now log the first 32/48 outcomes (written, skipped with current value, no slot, read failure) so the live counter page can be matched against host writes. - guest pin scanner logs the counter page's pagemap state each loop and adds it to the delta set explicitly, so the page is pinned the moment it is mapped even if the window scan misses it. --- tools/guest-diag/guest_pin_stream.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'tools/guest-diag') diff --git a/tools/guest-diag/guest_pin_stream.py b/tools/guest-diag/guest_pin_stream.py index 8d0b34d..717a05d 100644 --- a/tools/guest-diag/guest_pin_stream.py +++ b/tools/guest-diag/guest_pin_stream.py @@ -141,6 +141,26 @@ def main(): time.sleep(INTERVAL) continue dt = time.time() - t0 + # Diagnostic: the GR completion-counter page is the one page the + # client's context-init wait polls; log its pagemap entry every loop + # so a scan blind spot is visible in the guest log. + cpm = None + try: + fdp = os.open('/proc/%d/pagemap' % pid, os.O_RDONLY) + os.lseek(fdp, (0x20400fec0 // 4096) * 8, 0) + cpm = int.from_bytes(os.read(fdp, 8), 'little') + os.close(fdp) + except OSError: + cpm = None + diag = ('cpm=%s' % ('present' if (cpm or 0) >> 63 & 1 else 'absent') + if cpm is not None else 'cpm=ERR') + # Guaranteed fast path for the GR completion-counter page: if the + # window scan misses it (observed once), add it explicitly so the host + # can register the slots before the client's first wait. + if cpm is not None and (cpm >> 63) & 1: + cpa = (cpm & ((1 << 55) - 1)) << 12 + if cpa and (not PAMAX or cpa < PAMAX): + cur[0x20400f000] = cpa new = [(va, pa) for va, pa in cur.items() if seen.get(va) != pa] seen = cur lines = [] @@ -152,9 +172,9 @@ def main(): last_log = now try: with open('/tmp/guest_pin_stream.log', 'a') as f: - f.write('%s pid=%s present=%d new=%d sem=%d scan=%.3fs\n' + f.write('%s pid=%s present=%d new=%d sem=%d scan=%.3fs %s\n' % (time.strftime('%T'), pid, len(cur), len(new), - len(seen_sems), dt)) + len(seen_sems), dt, diag)) except OSError: pass if not new and not lines: -- cgit v1.2.3