From 853d3b0cc5e56686850accd364df8c8b3ce777b0 Mon Sep 17 00:00:00 2001
From: limeng12
Date: Wed, 23 Oct 2024 16:42:24 +0800
Subject: [PATCH] Backgroud health check
Add the RdcSmiHealth module, which will call rocm_smi_lib.
It will support following health:
- XGMI error detected
- PCIE replay count detected
- Memory check
- InfoROM check
- Power/Thermal check
The grpc client and server side health function is added.
The health module is added to the rdci.
At present, XGMI/PCIE and a part of Memory have been implemented.
Others will be added as soon as possible.
Change-Id: I1bd99290bdc7dea733f21a41a8c4bcefb2138112
---
common/rdc_field.data | 9 +
example/CMakeLists.txt | 6 +
example/health_example.cc | 359 +++++++++++
include/rdc/rdc.h | 153 +++++
include/rdc_lib/RdcCacheManager.h | 15 +
include/rdc_lib/RdcHandler.h | 6 +
include/rdc_lib/RdcWatchTable.h | 8 +
include/rdc_lib/impl/RdcCacheManagerImpl.h | 21 +
include/rdc_lib/impl/RdcEmbeddedHandler.h | 6 +
include/rdc_lib/impl/RdcStandaloneHandler.h | 6 +
include/rdc_lib/impl/RdcWatchTableImpl.h | 43 +-
protos/rdc.proto | 64 ++
python_binding/rdc_bootstrap.py | 8 +
rdc_libs/bootstrap/src/RdcBootStrap.cc | 39 ++
rdc_libs/rdc/src/RdcCacheManagerImpl.cc | 137 +++++
rdc_libs/rdc/src/RdcEmbeddedHandler.cc | 35 +-
rdc_libs/rdc/src/RdcMetricFetcherImpl.cc | 60 ++
rdc_libs/rdc/src/RdcSmiLib.cc | 3 +
rdc_libs/rdc/src/RdcWatchTableImpl.cc | 459 +++++++++++++++
.../rdc_client/src/RdcStandaloneHandler.cc | 82 +++
rdci/CMakeLists.txt | 1 +
rdci/include/RdciHealthSubSystem.h | 77 +++
rdci/src/RdciHealthSubSystem.cc | 557 ++++++++++++++++++
rdci/src/rdci.cc | 5 +-
server/include/rdc/rdc_api_service.h | 16 +
server/src/rdc_api_service.cc | 88 +++
26 files changed, 2260 insertions(+), 3 deletions(-)
create mode 100644 example/health_example.cc
create mode 100644 rdci/include/RdciHealthSubSystem.h
create mode 100644 rdci/src/RdciHealthSubSystem.cc
diff --git a/common/rdc_field.data b/common/rdc_field.data
index 7b2dc61e96..c01e44a4f4 100644
--- a/common/rdc_field.data
+++ b/common/rdc_field.data
@@ -161,3 +161,12 @@ FLD_DESC_ENT(RDC_EVNT_NOTIF_THERMAL_THROTTLE, "Clk freq decrease due to temp",
FLD_DESC_ENT(RDC_EVNT_NOTIF_PRE_RESET, "GPU reset is about to occur", "GPU_PRE_RESET", false)
FLD_DESC_ENT(RDC_EVNT_NOTIF_POST_RESET, "GPU reset just occurred", "GPU_POST_RESET", false)
FLD_DESC_ENT(RDC_EVNT_NOTIF_RING_HANG, "GPU ring hang just occured", "RING_HANG", false)
+
+// RDC health related fields
+FLD_DESC_ENT(RDC_HEALTH_XGMI_ERROR, "XGMI one or more errors detected", "XGMI_ERROR", true)
+FLD_DESC_ENT(RDC_HEALTH_PCIE_REPLAY_COUNT, "Total PCIE replay count", "PCIE_REPLAY_COUNT", true)
+FLD_DESC_ENT(RDC_HEALTH_PENDING_PAGE_NUM, "Pending page number", "PENDING_PAGE_NUM", true)
+FLD_DESC_ENT(RDC_HEALTH_RETIRED_PAGE_LIMIT, "Retired page limit", "RETIRED_PAGE_LIMIT", false)
+FLD_DESC_ENT(RDC_HEALTH_UNCORRECTABLE_PAGE_LIMIT, "Uncorrectable page limit", "UNCORRECTABLE_PAGE_LIMIT", false)
+FLD_DESC_ENT(RDC_HEALTH_POWER_THROTTLE_TIME, "Power throttle status counter", "POWER_THROTTLE_TIME", false)
+FLD_DESC_ENT(RDC_HEALTH_THERMAL_THROTTLE_TIME, "Total time(ms) in thermal throttle status", "THERMAL_THROTTLE_TIME", false)
diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt
index ac6019b2fe..6bbf746eb8 100755
--- a/example/CMakeLists.txt
+++ b/example/CMakeLists.txt
@@ -120,6 +120,12 @@ set(POLICY_EXAMPLE_EXE "policy")
add_executable(${POLICY_EXAMPLE_EXE} "${POLICY_EXAMPLE_SRC_LIST}")
target_link_libraries(${POLICY_EXAMPLE_EXE} pthread dl rdc_bootstrap)
+set(HEALTH_EXAMPLE_SRC_LIST "health_example.cc")
+cmake_print_variables(HEALTH_EXAMPLE_SRC_LIST)
+set(HEALTH_EXAMPLE_EXE "health")
+add_executable(${HEALTH_EXAMPLE_EXE} "${HEALTH_EXAMPLE_SRC_LIST}")
+target_link_libraries(${HEALTH_EXAMPLE_EXE} pthread dl rdc_bootstrap)
+
message("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&")
message(" Finished Cmake Example ")
message("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&")
diff --git a/example/health_example.cc b/example/health_example.cc
new file mode 100644
index 0000000000..d15dfa35a5
--- /dev/null
+++ b/example/health_example.cc
@@ -0,0 +1,359 @@
+/*
+Copyright (c) 2024 - present Advanced Micro Devices, Inc. All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+#include
+
+#include
+#include
+#include
+#include