From 7c0920cd62367ce7e8858fb25b24e2d5f2c144cb Mon Sep 17 00:00:00 2001 From: Wenkai Du <43822138+wenkaidu@users.noreply.github.com> Date: Wed, 15 Nov 2023 18:01:12 -0800 Subject: [PATCH] Fix kernel command line warnings (#961) * Fix kernel command line warnings * Remove while loop [ROCm/rccl commit: bc8661f092853808c9328da876e0c4ce7c7eed80] --- projects/rccl/src/init.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/projects/rccl/src/init.cc b/projects/rccl/src/init.cc index 02fdccdffc..8041c7a5b9 100644 --- a/projects/rccl/src/init.cc +++ b/projects/rccl/src/init.cc @@ -105,7 +105,7 @@ static ncclResult_t ncclInit() { NCCLCHECK(bootstrapNetInit()); NCCLCHECK(ncclNetPluginInit()); - char strValue[MAX_STR_LEN]; + char strValue[1024]; NCCLCHECK(ncclTopoGetStrFromSys("/proc/sys/kernel", "numa_balancing", strValue)); if (strcmp(strValue, "1") == 0) WARN("NUMA auto balancing enabled which can lead to variability in the RCCL performance! Disable by \"sudo sysctl kernel.numa_balancing=0\""); @@ -120,9 +120,14 @@ static ncclResult_t ncclInit() { if (strstr(verStr, "cray") == NULL) { NCCLCHECK(ncclTopoGetStrFromSys("/sys/devices/virtual/dmi/id", "bios_version", strValue)); if (strncmp("Hyper-V UEFI Release", strValue, 20) != 0) { - NCCLCHECK(ncclTopoGetStrFromSys("/proc", "cmdline", strValue)); - if (strstr(strValue, "amd_iommu=on") == NULL) - WARN("Missing \"amd_iommu=on\" from kernel command line which can lead to system instablity or hang!"); + FILE* file; + if ((file = fopen("/proc/cmdline", "r")) != NULL) { + if (feof(file) == 0 && ferror(file) == 0) { + int len = fread(strValue, 1, 1024, file); + strValue[len] = '\0'; + } + fclose(file); + } if (strstr(strValue, "iommu=pt") == NULL) WARN("Missing \"iommu=pt\" from kernel command line which can lead to system instablity or hang!"); }