Add kernel work-around for boot_id
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 30 Jan 2012 13:30:53 +0000 (08:30 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 30 Jan 2012 13:30:53 +0000 (08:30 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Link: https://lkml.org/lkml/2012/1/29/180
src/bin/lttng-sessiond/kernel.c
src/bin/lttng-sessiond/kernel.h
src/bin/lttng-sessiond/main.c

index d9e047fc3f5cdcc50a72ea68d0a7f29fa49b159b..43c6285773847739afc437de35bbb09cb0f6b0e3 100644 (file)
@@ -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;
+}
index a916f68411244fb5b6fdb9773e5f04ae700107f0..d663dbb1cebd6e6d2da57e9cf904445cd8884335 100644 (file)
@@ -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 */
index 631aa6b2d92e5e0d13aaa5a2d59072327b31eb69..9b2d1fe0079c91753877dec1ca724466187ac9f3 100644 (file)
@@ -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 */
This page took 0.028984 seconds and 4 git commands to generate.