This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] stap/staprun do not terminate properly


Hi,

I'm using the uprobes-inode with task_finder2.c and had two problems,
when I wanted to terminate my probe runs.

I tested the patches with uprobes-inode and the utrace based version.

Kind Regards,
Torsten

>From ba7faec0af3b06f3a2660e715dbcf039bce710c8 Mon Sep 17 00:00:00 2001
Message-Id: <ba7faec0af3b06f3a2660e715dbcf039bce710c8.1394140974.git.Torsten.Polle@gmx.de>
From: Torsten Polle <Torsten.Polle@gmx.de>
Date: Thu, 6 Mar 2014 21:22:40 +0100
Subject: [PATCH 1/2] Fix: Crash when canceling task work.

As the elements of the list __stp_tf_task_work_list are removed from
the list, a safe iteration has to be used in __stp_tf_cancel_task_work().

Signed-off-by: Torsten Polle <Torsten.Polle@gmx.de>
---
 runtime/linux/task_finder2.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/runtime/linux/task_finder2.c b/runtime/linux/task_finder2.c
index 16fda87..e8f33a3 100644
--- a/runtime/linux/task_finder2.c
+++ b/runtime/linux/task_finder2.c
@@ -169,11 +169,12 @@ static void __stp_tf_free_task_work(struct task_work *work)
 static void __stp_tf_cancel_task_work(void)
 {
 	struct __stp_tf_task_work *node;
+	struct __stp_tf_task_work *tmp;
 	unsigned long flags;
 
 	// Cancel all remaining requests.
 	spin_lock_irqsave(&__stp_tf_task_work_list_lock, flags);
-	list_for_each_entry(node, &__stp_tf_task_work_list, list) {
+	list_for_each_entry_safe(node, tmp, &__stp_tf_task_work_list, list) {
 	    // Remove the item from the list, cancel it, then free it.
 	    list_del(&node->list);
 	    stp_task_work_cancel(node->task, node->work.func);
-- 
1.7.4.1

>From b3dc9c88682a6c02a4cdf8ba73e692e77d593ebb Mon Sep 17 00:00:00 2001
Message-Id: <b3dc9c88682a6c02a4cdf8ba73e692e77d593ebb.1394140974.git.Torsten.Polle@gmx.de>
In-Reply-To: <ba7faec0af3b06f3a2660e715dbcf039bce710c8.1394140974.git.Torsten.Polle@gmx.de>
References: <ba7faec0af3b06f3a2660e715dbcf039bce710c8.1394140974.git.Torsten.Polle@gmx.de>
From: Torsten Polle <Torsten.Polle@gmx.de>
Date: Thu, 6 Mar 2014 21:34:27 +0100
Subject: [PATCH 2/2] Fix: stap/staprun deadlocks when probing ends.

stap_stop_task_finder() exits utrace through utrace_exit(). At that
time, there might be outstanding task workers. Hence, waiting for
exiting the task work waits forever. Therefore exiting the task work
is done after canceling all task workers.

Signed-off-by: Torsten Polle <Torsten.Polle@gmx.de>
---
 runtime/linux/task_finder2.c |    2 ++
 runtime/stp_utrace.c         |    1 -
 2 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/runtime/linux/task_finder2.c b/runtime/linux/task_finder2.c
index e8f33a3..119d04e 100644
--- a/runtime/linux/task_finder2.c
+++ b/runtime/linux/task_finder2.c
@@ -181,6 +181,8 @@ static void __stp_tf_cancel_task_work(void)
 	    _stp_kfree(node);
 	}
 	spin_unlock_irqrestore(&__stp_tf_task_work_list_lock, flags);
+
+	stp_task_work_exit();
 }
 
 static u32
diff --git a/runtime/stp_utrace.c b/runtime/stp_utrace.c
index 89ea0e4..8c948b6 100644
--- a/runtime/stp_utrace.c
+++ b/runtime/stp_utrace.c
@@ -291,7 +291,6 @@ static int utrace_exit(void)
 	if (utrace_engine_cachep)
 		kmem_cache_destroy(utrace_engine_cachep);
 
-	stp_task_work_exit();
 	return 0;
 }
 
-- 
1.7.4.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]