From 793f7ae18e56fd118c9dc5c6ed3a3d08b726c847 Mon Sep 17 00:00:00 2001 From: Lostwayzxc Date: Thu, 3 Jun 2021 19:36:51 +0800 Subject: [PATCH 1/5] 1.modify the way to get cpu status: first read to buf, and then read to int field by sscanf 2.modify some description of the log print --- 0006-add-cpu-online-fault-isolation.patch | 24 +++++++++++------------ 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/0006-add-cpu-online-fault-isolation.patch b/0006-add-cpu-online-fault-isolation.patch index 4484052..00c17d2 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,22 +543,20 @@ 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 > 3 ? CPU_UNKNOWN : num); +} + +static int init_cpu_info(unsigned int 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]); + } + -- Gitee From 24937623d39f9473492a1aefc80faa483f0936aa Mon Sep 17 00:00:00 2001 From: Lostwayzxc Date: Fri, 4 Jun 2021 09:20:19 +0800 Subject: [PATCH 2/5] add changelog to spec --- rasdaemon.spec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rasdaemon.spec b/rasdaemon.spec index 0e10558..a25b881 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 -- Gitee From 90413c908ed1d82e38cdfc80fd76e6bf17b818db Mon Sep 17 00:00:00 2001 From: Lostwayzxc Date: Fri, 4 Jun 2021 09:34:11 +0800 Subject: [PATCH 3/5] use enum --- 0006-add-cpu-online-fault-isolation.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/0006-add-cpu-online-fault-isolation.patch b/0006-add-cpu-online-fault-isolation.patch index 00c17d2..9d31286 100644 --- a/0006-add-cpu-online-fault-isolation.patch +++ b/0006-add-cpu-online-fault-isolation.patch @@ -556,7 +556,7 @@ index 0000000..7f1c287 + + close(fd); + -+ return (num > 3 ? CPU_UNKNOWN : num); ++ return (num > CPU_UNKNOWN ? CPU_UNKNOWN : num); +} + +static int init_cpu_info(unsigned int cpus) -- Gitee From 82a22de0f5577899c2f2ae21050039f4d0092d9d Mon Sep 17 00:00:00 2001 From: Lostwayzxc Date: Fri, 4 Jun 2021 11:04:36 +0800 Subject: [PATCH 4/5] judge whether the cpu status read from cpu file will be lower than 0 --- 0006-add-cpu-online-fault-isolation.patch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/0006-add-cpu-online-fault-isolation.patch b/0006-add-cpu-online-fault-isolation.patch index 9d31286..5b8e761 100644 --- a/0006-add-cpu-online-fault-isolation.patch +++ b/0006-add-cpu-online-fault-isolation.patch @@ -556,10 +556,10 @@ index 0000000..7f1c287 + + close(fd); + -+ return (num > CPU_UNKNOWN ? CPU_UNKNOWN : 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); -- Gitee From 4546c11c2a1e9c48d9e9c1f2f165e68bed14c27d Mon Sep 17 00:00:00 2001 From: Lostwayzxc Date: Fri, 4 Jun 2021 11:30:11 +0800 Subject: [PATCH 5/5] push again for gitee bug... --- 0006-add-cpu-online-fault-isolation.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/0006-add-cpu-online-fault-isolation.patch b/0006-add-cpu-online-fault-isolation.patch index 5b8e761..81707cd 100644 --- a/0006-add-cpu-online-fault-isolation.patch +++ b/0006-add-cpu-online-fault-isolation.patch @@ -556,7 +556,7 @@ index 0000000..7f1c287 + + close(fd); + -+ return ((num < 0 || num > CPU_UNKNOWN) ? CPU_UNKNOWN : num); ++ return (num < 0 || num > CPU_UNKNOWN) ? CPU_UNKNOWN : num; +} + +static int init_cpu_info(unsigned cpus) -- Gitee