From 03d8df9ece5bd2d81703b3eeac07e4d889639674 Mon Sep 17 00:00:00 2001 From: Arthur Hanson Rasmusson Date: Mon, 28 Sep 2026 13:14:16 -0400 Subject: guest-diag: adaptive miss-driven pinner; cdt holds on failure for inspection pin_miss_pages.sh watches the host journal for release-miss VAs, resolves each page for the live cdt pid through the guest pagemap and injects it (the injection rewinds the pump so releases consumed under a stale pin are re-read); it re-pins when a new cdt pid appears. cuda_drv_test prints cuGetErrorName/String on failure and, with CDT_HOLD=, stays alive so the RM error record and tracker state can be inspected after cuCtxCreate has given up. --- tools/test/cuda_drv_test.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'tools/test') diff --git a/tools/test/cuda_drv_test.c b/tools/test/cuda_drv_test.c index 20ad88a..8995a55 100644 --- a/tools/test/cuda_drv_test.c +++ b/tools/test/cuda_drv_test.c @@ -15,7 +15,9 @@ * gcc -O1 -o /tmp/cdt cuda_drv_test.c -ldl */ #include +#include #include +#include #include #include @@ -24,9 +26,30 @@ typedef int CUdevice; typedef void *CUcontext; typedef uint64_t CUdeviceptr; +/* On failure: print cuGetErrorName/String and, when CDT_HOLD= is + * set, keep the process alive so the live state (trackers, RM error record) + * can be inspected with gdb after cuCtxCreate has given up. */ +static void fail_info(CUresult r) +{ + const char *(*errname)(CUresult, const char **) = dlsym(RTLD_DEFAULT, "cuGetErrorName"); + const char *(*errstr)(CUresult, const char **) = dlsym(RTLD_DEFAULT, "cuGetErrorString"); + const char *s = NULL; + const char *hold = getenv("CDT_HOLD"); + + if (errname && errname(r, &s) == 0 && s) + printf("cuGetErrorName: %s\n", s); + if (errstr && errstr(r, &s) == 0 && s) + printf("cuGetErrorString: %s\n", s); + if (hold && atoi(hold) > 0) { + printf("CDT_HOLD: sleeping %d s for inspection\n", atoi(hold)); + fflush(stdout); + sleep((unsigned)atoi(hold)); + } +} + #define CHECK(expr) do { \ CUresult r = (expr); \ - if (r) { printf("%-24s FAILED rc=%d\n", #expr, r); return 1; } \ + if (r) { printf("%-24s FAILED rc=%d\n", #expr, r); fail_info(r); return 1; } \ printf("%-24s OK\n", #expr); \ } while (0) -- cgit v1.2.3