@@ -383,6 +383,8 @@ static int read_ras_event_all_cpus(struct pthread_data *pdata,
int warnonce[n_cpus];
char pipe_raw[PATH_MAX];
int legacy_kernel = 0;
+ int fd;
+ char buf[2];
#if 0
int need_sleep = 0;
#endif
@@ -402,6 +404,33 @@ static int read_ras_event_all_cpus(struct pthread_data *pdata,
return -ENOMEM;
}
+ /* Fix for poll() do not return on per_cpu trace_pipe and
+ * trace_pipe_raw with the default buffer_percent in the kernel trace,
+ * introduced by the following change in the kernel
+ * https://lore.kernel.org/all/20221020231427.41be3f26@gandalf.local.home/T/#u.
+ * Set buffer_percent to 0 so that poll() returned immediately
+ * when the trace data is available in the ras per_cpu trace pipe_raw */
+ fd = open_trace(pdata[0].ras, "buffer_percent", O_RDWR);
+ if (fd < 0) {
+ log(TERM, LOG_ERR, "Can't open trace buffer_percent\n");
+ return -1;
+ }
+ size = write(fd, "0", 1);
+ if (size <= 0) {
+ log(TERM, LOG_ERR, "Can't set rasdaemon trace buffer_percent\n");
+ return -1;
+ }
+ size = read(fd, buf, 1);
+ if (size <= 0) {
+ log(TERM, LOG_ERR, "Can't read rasdaemon trace buffer_percent\n");
+ return -1;
+ }
+ if (atoi(buf) != 0) {
+ log(TERM, LOG_ERR, "Can't verify rasdaemon trace buffer_percent\n");
+ return -1;
+ }
+ close(fd);
+
for (i = 0; i < (n_cpus + 1); i++)
fds[i].fd = -1;