8 Star 1 Fork 8

src-anolis-os/rasdaemon

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
1027-anolis-Add-dynamic-switch-of-ras-events-support.patch 4.85 KB
一键复制 编辑 原始数据 按行查看 历史
winterddd 提交于 2024-12-25 17:32 +08:00 . [Feature]anolis: rasdaemon: rasdaemon 0.6.7-16
From 80e534e597163ef2fd4fc3bff3d441420914e0d2 Mon Sep 17 00:00:00 2001
From: caixiaomeng 00662745 <caixiaomeng2@huawei.com>
Date: Wed, 29 Nov 2023 14:31:46 +0800
Subject: [PATCH 27/85] anolis: Add dynamic switch of ras events support.
Rasdaemon does not support a way to disable some events by config.
If user want to disable specified event(eg:block_rq_complete), he
should recompile rasdaemon, which is not so convenient.
This patch add dynamic switch of ras event support.You can add
events you want to disabled in /etc/sysconfig/rasdaemon.For example,
`DISABLE="ras:mc_event,block:block_rq_complete"`.Then restart
rasdaemon, these two events will be disabled without recompilation.
[mchehab: make is_disabled_event() static]
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
[Ruidong: delete cxl code]
---
ras-events.c | 35 ++++++++++++++++++++++++++++-------
rasdaemon.c | 3 +++
2 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/ras-events.c b/ras-events.c
index 9ad34f8..31a4e0b 100644
--- a/ras-events.c
+++ b/ras-events.c
@@ -57,6 +57,8 @@
#define ENDIAN KBUFFER_ENDIAN_BIG
#endif
+extern char* choices_disable;
+
static int get_debugfs_dir(char *tracing_dir, size_t len)
{
FILE *fp;
@@ -147,6 +149,18 @@ static int get_tracing_dir(struct ras_events *ras)
return 0;
}
+static int is_disabled_event(char *group, char *event) {
+ char ras_event_name[MAX_PATH + 1];
+
+ snprintf(ras_event_name, sizeof(ras_event_name), "%s:%s",
+ group, event);
+
+ if (choices_disable != NULL && strlen(choices_disable) != 0 && strstr(choices_disable, ras_event_name)) {
+ return 1;
+ }
+ return 0;
+}
+
/*
* Tracing enable/disable code
*/
@@ -155,6 +169,7 @@ static int __toggle_ras_mc_event(struct ras_events *ras,
{
int fd, rc;
char fname[MAX_PATH + 1];
+ enable = is_disabled_event(group, event) ? 0 : 1;
snprintf(fname, sizeof(fname), "%s%s:%s\n",
enable ? "" : "!",
@@ -775,6 +790,12 @@ static int add_event_handler(struct ras_events *ras, struct pevent *pevent,
ras->filters[id] = filter;
+ if (is_disabled_event(group, event)) {
+ log(ALL, LOG_INFO, "Disabled %s:%s tracing from config\n",
+ group, event);
+ return -EINVAL;
+ }
+
/* Enable RAS events */
rc = __toggle_ras_mc_event(ras, group, event, 1);
free(page);
@@ -842,7 +863,7 @@ int handle_ras_events(int record_events)
ras_mc_event_handler, NULL, MC_EVENT);
if (!rc)
num_events++;
- else
+ else if (rc != -EINVAL)
log(ALL, LOG_ERR, "Can't get traces from %s:%s\n",
"ras", "mc_event");
@@ -851,7 +872,7 @@ int handle_ras_events(int record_events)
ras_aer_event_handler, NULL, AER_EVENT);
if (!rc)
num_events++;
- else
+ else if (rc != -EINVAL)
log(ALL, LOG_ERR, "Can't get traces from %s:%s\n",
"ras", "aer_event");
#endif
@@ -861,7 +882,7 @@ int handle_ras_events(int record_events)
ras_non_standard_event_handler, NULL, NON_STANDARD_EVENT);
if (!rc)
num_events++;
- else
+ else if (rc != -EINVAL)
log(ALL, LOG_ERR, "Can't get traces from %s:%s\n",
"ras", "non_standard_event");
#endif
@@ -871,7 +892,7 @@ int handle_ras_events(int record_events)
ras_arm_event_handler, NULL, ARM_EVENT);
if (!rc)
num_events++;
- else
+ else if (rc != -EINVAL)
log(ALL, LOG_ERR, "Can't get traces from %s:%s\n",
"ras", "arm_event");
#endif
@@ -905,7 +926,7 @@ int handle_ras_events(int record_events)
/* tell kernel we are listening, so don't printk to console */
(void)open("/sys/kernel/debug/ras/daemon_active", 0);
num_events++;
- } else
+ } else if (rc != -EINVAL)
log(ALL, LOG_ERR, "Can't get traces from %s:%s\n",
"ras", "extlog_mem_event");
#endif
@@ -922,7 +943,7 @@ int handle_ras_events(int record_events)
ras_devlink_event_handler, filter_str, DEVLINK_EVENT);
if (!rc)
num_events++;
- else
+ else if (rc != -EINVAL)
log(ALL, LOG_ERR, "Can't get traces from %s:%s\n",
"devlink", "devlink_health_report");
#endif
@@ -946,7 +967,7 @@ int handle_ras_events(int record_events)
ras_memory_failure_event_handler, NULL, MF_EVENT);
if (!rc)
num_events++;
- else
+ else if (rc != -EINVAL)
log(ALL, LOG_ERR, "Can't get traces from %s:%s\n",
"ras", "memory_failure_event");
#endif
diff --git a/rasdaemon.c b/rasdaemon.c
index e9a3a4d..0db51c9 100644
--- a/rasdaemon.c
+++ b/rasdaemon.c
@@ -33,6 +33,8 @@
#define TOOL_NAME "rasdaemon"
#define TOOL_DESCRIPTION "RAS daemon to log the RAS events."
#define ARGS_DOC "<options>"
+#define DISABLE "DISABLE"
+char *choices_disable = NULL;
const char *argp_program_version = TOOL_NAME " " VERSION;
const char *argp_program_bug_address = "Mauro Carvalho Chehab <mchehab@kernel.org>";
@@ -127,6 +129,7 @@ int main(int argc, char *argv[])
{
struct arguments args;
int idx = -1;
+ choices_disable = getenv(DISABLE);
#ifdef HAVE_MCE
const struct argp_option offline_options[] = {
--
2.33.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-anolis-os/rasdaemon.git
git@gitee.com:src-anolis-os/rasdaemon.git
src-anolis-os
rasdaemon
rasdaemon
a8

搜索帮助

371d5123 14472233 46e8bd33 14472233