[ltt-dev] [PATCH] LTTng trace destroy wait for readers to complete

Mathieu Desnoyers compudj at krystal.dyndns.org
Mon Sep 15 15:08:07 EDT 2008


Hi John,

Please try the following patch instead. It should make lttctl wait until
all lttd instances release the trace kref.

Mathieu


LTTng trace destroy wait for readers to complete

Make lttctl sleep until all the lttd readers complete.

Hopefully this will brighten Martin's day.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at polymtl.ca>
CC: Martin J. Bligh <mbligh at google.com>
CC: Jiaying Zhang <jiayingz at google.com>
CC: John Admanski <jadmanski at google.com>
---
 ltt/ltt-tracer.c |    9 +++++++++
 1 file changed, 9 insertions(+)

Index: linux-2.6-lttng/ltt/ltt-tracer.c
===================================================================
--- linux-2.6-lttng.orig/ltt/ltt-tracer.c	2008-09-15 14:43:00.000000000 -0400
+++ linux-2.6-lttng/ltt/ltt-tracer.c	2008-09-15 14:58:03.000000000 -0400
@@ -40,6 +40,7 @@
 #include <linux/fs.h>
 #include <linux/cpu.h>
 #include <linux/kref.h>
+#include <linux/delay.h>
 #include <asm/atomic.h>
 
 static void async_wakeup(unsigned long data);
@@ -635,6 +636,14 @@ static void __ltt_trace_destroy(struct l
 
 	module_put(trace->transport->owner);
 
+	/*
+	 * Wait for lttd readers to release the files, therefore making sure
+	 * the last subbuffers have been read. Currently use a sleep, should
+	 * probably use a waitqueue.
+	 */
+	while (atomic_read(&trace->kref.refcount) > 1)
+		ssleep(1);
+
 	kref_put(&trace->kref, ltt_release_trace);
 }
 

-- 
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68




More information about the lttng-dev mailing list