[ltt-dev] [PATCH] LTTNG: hold markers_mutex during marker section iteration

Gui Jianfeng guijianfeng at cn.fujitsu.com
Wed Mar 18 05:35:11 EDT 2009


Hold the markers_mutex during marker section iteration.

Signed-off-by: Gui Jianfeng <guijianfeng at cn.fujitsu.com>
---
 kernel/marker.c         |    2 ++
 ltt/ltt-trace-control.c |   12 ++++++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/kernel/marker.c b/kernel/marker.c
index 7d11393..93ffa8e 100644
--- a/kernel/marker.c
+++ b/kernel/marker.c
@@ -44,11 +44,13 @@ void lock_markers(void)
 {
 	mutex_lock(&markers_mutex);
 }
+EXPORT_SYMBOL_GPL(lock_markers);
 
 void unlock_markers(void)
 {
 	mutex_unlock(&markers_mutex);
 }
+EXPORT_SYMBOL_GPL(unlock_markers);
 
 /*
  * Marker hash table, containing the active markers.
diff --git a/ltt/ltt-trace-control.c b/ltt/ltt-trace-control.c
index c1c44c6..63cbb29 100644
--- a/ltt/ltt-trace-control.c
+++ b/ltt/ltt-trace-control.c
@@ -846,6 +846,8 @@ static ssize_t marker_info_read(struct file *filp, char __user *ubuf,
 	len = 0;
 	buf = (char *)__get_free_page(GFP_KERNEL);
 
+	lock_markers();
+
 	marker_iter_reset(&iter);
 	marker_iter_start(&iter);
 	for (; iter.marker != NULL; marker_iter_next(&iter)) {
@@ -872,6 +874,8 @@ static ssize_t marker_info_read(struct file *filp, char __user *ubuf,
 	}
 	marker_iter_stop(&iter);
 
+	unlock_markers();
+
 	if (len >= PAGE_SIZE) {
 		len = PAGE_SIZE;
 		buf[PAGE_SIZE] = '\0';
@@ -958,6 +962,8 @@ static int build_marker_control_files(void)
 	if (!markers_control_dir)
 		return -EEXIST;
 
+	lock_markers();
+
 	marker_iter_reset(&iter);
 	marker_iter_start(&iter);
 	for (; iter.marker != NULL; marker_iter_next(&iter)) {
@@ -966,6 +972,9 @@ static int build_marker_control_files(void)
 			goto err_build_fail;
 	}
 	marker_iter_stop(&iter);
+
+	unlock_markers();
+
 	return 0;
 
 err_build_fail:
@@ -991,6 +1000,8 @@ static int remove_marker_control_dir(struct module *mod, struct marker *marker)
 		return -ENOENT;
 	name = marker_d->d_name.name;
 
+	lock_markers();
+
 	marker_iter_reset(&iter);
 	marker_iter_start(&iter);
 	for (; iter.marker != NULL; marker_iter_next(&iter)) {
@@ -1008,6 +1019,7 @@ static int remove_marker_control_dir(struct module *mod, struct marker *marker)
 
 end:
 	marker_iter_stop(&iter);
+	unlock_markers();
 	return 0;
 }
 
-- 
1.5.4.rc3







More information about the lttng-dev mailing list