[PATCH 2/6] use tracehook_finish_jctl() to clear ->stopped

Oleg Nesterov oleg at redhat.com
Fri Jul 31 01:06:49 UTC 2009


(depends on signals-introduce-tracehook_finish_jctl-helper.patch)

Use tracehook_finish_jctl() to clear utrace->stopped. From now
we shouldn't worry about ->stopped "leaking" after jctl stop.

Signed-off-by: Oleg Nesterov <oleg at redhat.com>
---

 include/linux/utrace.h    |    2 ++
 include/linux/tracehook.h |    2 ++
 kernel/utrace.c           |   18 ++++++++++++++++++
 3 files changed, 22 insertions(+)

--- __UTRACE/include/linux/utrace.h~2_FINISH_JCTL	2009-07-29 03:10:09.000000000 +0200
+++ __UTRACE/include/linux/utrace.h	2009-07-31 02:15:34.000000000 +0200
@@ -109,6 +109,8 @@ void utrace_report_death(struct task_str
 	__attribute__((weak));
 void utrace_report_jctl(int notify, int type)
 	__attribute__((weak));
+void utrace_finish_jctl(void)
+	__attribute__((weak));
 void utrace_report_exec(struct linux_binfmt *, struct linux_binprm *,
 			struct pt_regs *regs)
 	__attribute__((weak));
--- __UTRACE/include/linux/tracehook.h~2_FINISH_JCTL	2009-07-31 02:13:57.000000000 +0200
+++ __UTRACE/include/linux/tracehook.h	2009-07-31 02:15:34.000000000 +0200
@@ -528,6 +528,8 @@ static inline int tracehook_notify_jctl(
  */
 static inline void tracehook_finish_jctl(void)
 {
+	if (task_utrace_flags(current))
+		utrace_finish_jctl();
 }
 
 #define DEATH_REAP			-1
--- __UTRACE/kernel/utrace.c~2_FINISH_JCTL	2009-07-31 01:54:29.000000000 +0200
+++ __UTRACE/kernel/utrace.c	2009-07-31 02:15:34.000000000 +0200
@@ -1640,6 +1640,24 @@ void utrace_report_jctl(int notify, int 
 }
 
 /*
+ * Called without locks.
+ */
+void utrace_finish_jctl(void)
+{
+	struct utrace *utrace = task_utrace_struct(current);
+	/*
+	 * While in TASK_STOPPED, we can be considered safely
+	 * stopped by utrace_do_stop(). Clear ->stopped if we
+	 * were woken by signal.
+	 */
+	if (utrace->stopped) {
+		spin_lock(&utrace->lock);
+		utrace->stopped = false;
+		spin_unlock(&utrace->lock);
+	}
+}
+
+/*
  * Called iff UTRACE_EVENT(EXIT) flag is set.
  */
 void utrace_report_exit(long *exit_code)




More information about the utrace-devel mailing list