diff --git a/0006-add-cpu-online-fault-isolation.patch b/0006-add-cpu-online-fault-isolation.patch index 448405212613fe2fead97aa6d62dae481d5e2b5d..81707cdc788d54c941de87d6b53dc360ede0962e 100644 --- a/0006-add-cpu-online-fault-isolation.patch +++ b/0006-add-cpu-online-fault-isolation.patch @@ -15,11 +15,11 @@ Signed-off-by: Luo Shengwei queue.c | 126 +++++++++++ queue.h | 43 ++++ ras-arm-handler.c | 72 +++++++ - ras-cpu-isolation.c | 497 ++++++++++++++++++++++++++++++++++++++++++++ + ras-cpu-isolation.c | 495 ++++++++++++++++++++++++++++++++++++++++++++ ras-cpu-isolation.h | 76 +++++++ ras-events.c | 8 + ras-record.h | 5 + - 11 files changed, 861 insertions(+), 2 deletions(-) + 11 files changed, 859 insertions(+), 2 deletions(-) create mode 100644 queue.c create mode 100644 queue.h create mode 100644 ras-cpu-isolation.c @@ -386,10 +386,10 @@ index 2f170e2..f9baa51 100644 ras_store_arm_record(ras, &ev); diff --git a/ras-cpu-isolation.c b/ras-cpu-isolation.c new file mode 100644 -index 0000000..153c9b4 +index 0000000..7f1c287 --- /dev/null +++ b/ras-cpu-isolation.c -@@ -0,0 +1,497 @@ +@@ -0,0 +1,495 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. + * @@ -543,25 +543,23 @@ index 0000000..153c9b4 +static int get_cpu_status(unsigned cpu) +{ + int fd, num; ++ char buf[2] = ""; + fd = open_sys_file(cpu, O_RDONLY, cpu_path_format); + + if (fd == -1) { + return CPU_UNKNOWN; + } + -+ if (read(fd, &num, 1) <= 0) { ++ if (read(fd, buf, 1) <= 0 || sscanf(buf, "%d", &num) != 1) { + num = CPU_UNKNOWN; + } -+ else { -+ num = num - '0'; -+ } + + close(fd); + -+ return num; ++ return (num < 0 || num > CPU_UNKNOWN) ? CPU_UNKNOWN : num; +} + -+static int init_cpu_info(unsigned int cpus) ++static int init_cpu_info(unsigned cpus) +{ + ncores = cpus; + cpu_infos = (struct cpu_info *) malloc(sizeof(*cpu_infos) * cpus); @@ -669,7 +667,7 @@ index 0000000..153c9b4 + char *env = getenv("CPU_ISOLATION_ENABLE"); + + if (env == NULL || strcasecmp(env, "yes")) { -+ log(TERM, LOG_ERR, "Config of cpu fault isolation is not on\n"); ++ log(TERM, LOG_WARNING, "Cpu fault isolation is disabled\n"); + return -1; + } + @@ -700,7 +698,7 @@ index 0000000..153c9b4 +static int do_cpu_offline(unsigned cpu) +{ + int fd, rc; -+ char buf[2]; ++ char buf[2] = ""; + cpu_infos[cpu].state = CPU_OFFLINE_FAILED; + fd = open_sys_file(cpu, O_RDWR, cpu_path_format); + @@ -876,12 +874,12 @@ index 0000000..153c9b4 + log(TERM, LOG_WARNING, "Doing nothing in the cpu%d\n", cpu); + } + else if (ret == HANDLE_SUCCEED) { -+ log(TERM, LOG_INFO, "Offline cpu %d succeed, the state is %s\n", ++ log(TERM, LOG_INFO, "Offline cpu%d succeed, the state is %s\n", + cpu, cpu_state[cpu_infos[cpu].state]); + clear_queue(cpu_infos[cpu].ce_queue); + } + else { -+ log(TERM, LOG_INFO, "Offline cpu %d fail, the state is %s\n", ++ log(TERM, LOG_INFO, "Offline cpu%d fail, the state is %s\n", + cpu, cpu_state[cpu_infos[cpu].state]); + } + diff --git a/rasdaemon.spec b/rasdaemon.spec index 0e10558a4210bbe401f4a3d296118c3df1eafbba..a25b8813f80fc28714d9a5af63751d8cb9ebd5bf 100644 --- a/rasdaemon.spec +++ b/rasdaemon.spec @@ -1,6 +1,6 @@ Name: rasdaemon Version: 0.6.6 -Release: 4 +Release: 5 License: GPLv2 Summary: Utility to get Platform Reliability, Availability and Serviceability (RAS) reports via the Kernel tracing events URL: https://github.com/mchehab/rasdaemon.git @@ -72,6 +72,10 @@ rm INSTALL %{buildroot}/usr/include/*.h /usr/bin/systemctl enable rasdaemon.service >/dev/null 2>&1 || : %changelog +* Thu Jun 3 2021 luoshengwei - 0.6.6-5 +- modify the way to get cpu status and modify some description of +- the log print + * Fri May 21 2021 luoshengwei - 0.6.6-4 - add cpu online fault isolation, user can enable this function - by configure --enable-cpu-fault-isolation