8 Star 1 Fork 8

src-anolis-os/rasdaemon

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
1068-The-rasdaemon-service-may-fail-to-be-started-for-the.patch 1.84 KB
一键复制 编辑 原始数据 按行查看 历史
From 3c97362d2bb26861c04c738b1499451f428c96dc Mon Sep 17 00:00:00 2001
From: zhuofeng <zhuofeng2@huawei.com>
Date: Sat, 29 Jun 2024 17:27:56 +0800
Subject: [PATCH 68/85] The rasdaemon service may fail to be started for the
first time.
The rasdaemon creates a separate instance virtual directory on first startup, like `/sys/kernel/debug/tracing/instances/rasdaemon`.
After the directory is created, the kernel generates virtual files such as `trace_clock` and `set_event` in `/sys/kernel/debug/tracing/instances/rasdaemon`.
The kernel generates virtual files and the rasdaemon accesses the virtual files at the same time. Therefore, the kernel may not generate the virtual files when the rasdaemon accesses the virtual files.
So add up to 30 seconds to give the kernel enough time to generate the files.
Signed-off-by: zhuofeng <zhuofeng2@huawei.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
---
ras-events.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/ras-events.c b/ras-events.c
index 0bba53f..9dbbcd0 100644
--- a/ras-events.c
+++ b/ras-events.c
@@ -109,6 +109,19 @@ static int get_debugfs_dir(char *tracing_dir, size_t len)
return -ENOENT;
}
+static int wait_access(char *path, int ms)
+{
+ int i;
+ for (i = 0; i < ms; i++) {
+ if (access(path, F_OK) == 0)
+ return 0;
+ usleep(1000);
+ }
+
+ log(ALL, LOG_WARNING, "wait_access() failed, %s not created in %d ms\n", path, ms);
+ return -1;
+}
+
static int open_trace(struct ras_events *ras, char *name, int flags)
{
char fname[MAX_PATH + 1];
@@ -124,6 +137,12 @@ static int open_trace(struct ras_events *ras, char *name, int flags)
if (rc < 0)
return rc;
+ rc = wait_access(fname, 30000);
+ if (rc != 0) {
+ /* use -1 to keep same error value with open() */
+ return -1;
+ }
+
rc = open(fname, flags);
if (rc < 0) {
rc = -errno;
--
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