From ccd91bcd19557692f2f696bb1c0e524942e4f040 Mon Sep 17 00:00:00 2001 From: Yifan Zhang Date: Mon, 26 May 2025 13:29:39 +0800 Subject: [PATCH] coredump: call KFD_IOC_DBG_TRAP_DISABLE in error path. KFD assumes kfd_dbg_trap_enable/disable be called in pair, or there will be kfd_process ref leak in KFD. --- runtime/hsa-runtime/libamdhsacode/amd_core_dump.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/runtime/hsa-runtime/libamdhsacode/amd_core_dump.cpp b/runtime/hsa-runtime/libamdhsacode/amd_core_dump.cpp index 079da9438f..8f3700bf70 100644 --- a/runtime/hsa-runtime/libamdhsacode/amd_core_dump.cpp +++ b/runtime/hsa-runtime/libamdhsacode/amd_core_dump.cpp @@ -127,6 +127,7 @@ struct NoteSegmentBuilder : public SegmentBuilder { std::unique_ptr runtime_info(runtime_ptr, std::free); if (HSAKMT_CALL(hsaKmtGetVersion(&versionInfo))) { + HSAKMT_CALL(hsaKmtDbgDisable()); fprintf(stderr, "Failed to fetch driver ABI version.\n"); return HSA_STATUS_ERROR; } @@ -140,6 +141,7 @@ struct NoteSegmentBuilder : public SegmentBuilder { note_package_builder_.Write(runtime_size); if (HSAKMT_CALL(hsaKmtDbgGetDeviceData(&agents_ptr, &n_entries, &entry_size))) { + HSAKMT_CALL(hsaKmtDbgDisable()); fprintf(stderr, "Failed to fetch agents snapshot.\n"); return HSA_STATUS_ERROR; } @@ -151,6 +153,7 @@ struct NoteSegmentBuilder : public SegmentBuilder { note_package_builder_.Write(entry_size); if (HSAKMT_CALL(hsaKmtDbgGetQueueData(&queues_ptr, &n_entries, &entry_size, true))) { + HSAKMT_CALL(hsaKmtDbgDisable()); fprintf(stderr, "Failed to fetch queues snapshot.\n"); return HSA_STATUS_ERROR; }