From 335a95b7e3fab0d66908594ac7039651c7aaf6f4 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Mon, 30 Jan 2012 08:30:53 -0500 Subject: [PATCH] Add kernel work-around for boot_id Signed-off-by: Mathieu Desnoyers Link: https://lkml.org/lkml/2012/1/29/180 --- src/bin/lttng-sessiond/kernel.c | 27 +++++++++++++++++++++++++++ src/bin/lttng-sessiond/kernel.h | 2 ++ src/bin/lttng-sessiond/main.c | 2 ++ 3 files changed, 31 insertions(+) diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index d9e047fc3..43c628577 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -638,3 +638,30 @@ error_version: error: return ret; } + +/* + * Kernel work-arounds called at the start of sessiond main(). + */ +int init_kernel_workarounds(void) +{ + FILE *fp; + + /* + * boot_id needs to be read once before being used concurrently + * to deal with a Linux kernel race. A fix is proposed for + * upstream, but the work-around is needed for older kernels. + */ + fp = fopen("/proc/sys/kernel/random/boot_id", "r"); + if (!fp) { + goto end_boot_id; + } + while (!feof(fp)) { + char buf[37] = ""; + + (void) fread(buf, 1, sizeof(buf), fp); + } + fclose(fp); +end_boot_id: + + return 0; +} diff --git a/src/bin/lttng-sessiond/kernel.h b/src/bin/lttng-sessiond/kernel.h index a916f6841..d663dbb1c 100644 --- a/src/bin/lttng-sessiond/kernel.h +++ b/src/bin/lttng-sessiond/kernel.h @@ -55,4 +55,6 @@ void kernel_wait_quiescent(int fd); int kernel_calibrate(int fd, struct lttng_kernel_calibrate *calibrate); int kernel_validate_version(int tracer_fd); +int init_kernel_workarounds(void); + #endif /* _LTT_KERNEL_CTL_H */ diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 631aa6b2d..9b2d1fe00 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -4158,6 +4158,8 @@ int main(int argc, char **argv) void *status; const char *home_path; + init_kernel_workarounds(); + rcu_register_thread(); /* Create thread quit pipe */ -- 2.34.1