summaryrefslogtreecommitdiffstats
path: root/runtime/task_finder.c
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2009-02-20 14:56:38 +0100
committerMark Wielaard <mjw@redhat.com>2009-02-20 14:56:38 +0100
commit02615365a92ca2570c1f96abc8a97674aa2ccae1 (patch)
treeebedfd91a0f6d299b39e84295e091e12c0767dc8 /runtime/task_finder.c
parentc3bad3042df505a3470f1e20b09822a9df1d4761 (diff)
parentadc67597f327cd43d58b1d0cb740dab14a75a058 (diff)
downloadsystemtap-steved-02615365a92ca2570c1f96abc8a97674aa2ccae1.tar.gz
systemtap-steved-02615365a92ca2570c1f96abc8a97674aa2ccae1.tar.xz
systemtap-steved-02615365a92ca2570c1f96abc8a97674aa2ccae1.zip
Merge branch 'master' into pr6866
Conflicts: ChangeLog: Removed runtime/ChangeLog: Removed runtime/sym.c: Merged runtime/task_finder.c: Merged tapset/ChangeLog: Removed testsuite/ChangeLog: Removed
Diffstat (limited to 'runtime/task_finder.c')
-rw-r--r--runtime/task_finder.c37
1 files changed, 30 insertions, 7 deletions
diff --git a/runtime/task_finder.c b/runtime/task_finder.c
index 31bccad8..ae381a41 100644
--- a/runtime/task_finder.c
+++ b/runtime/task_finder.c
@@ -22,14 +22,14 @@ struct stap_task_finder_target;
#define __STP_TF_RUNNING 1
#define __STP_TF_STOPPING 2
#define __STP_TF_STOPPED 3
-atomic_t __stp_task_finder_state = ATOMIC_INIT(__STP_TF_STARTING);
-atomic_t __stp_inuse_count = ATOMIC_INIT (0);
+static atomic_t __stp_task_finder_state = ATOMIC_INIT(__STP_TF_STARTING);
+static atomic_t __stp_inuse_count = ATOMIC_INIT (0);
#define __stp_tf_handler_start() (atomic_inc(&__stp_inuse_count))
#define __stp_tf_handler_end() (atomic_dec(&__stp_inuse_count))
#ifdef DEBUG_TASK_FINDER
-atomic_t __stp_attach_count = ATOMIC_INIT (0);
+static atomic_t __stp_attach_count = ATOMIC_INIT (0);
#define debug_task_finder_attach() (atomic_inc(&__stp_attach_count))
#define debug_task_finder_detach() (atomic_dec(&__stp_attach_count))
@@ -55,7 +55,7 @@ typedef int (*stap_task_finder_vm_callback)(struct stap_task_finder_target *tgt,
unsigned long vm_end,
unsigned long vm_pgoff);
-int __stp_tf_vm_cb(struct stap_task_finder_target *tgt,
+static int __stp_tf_vm_cb(struct stap_task_finder_target *tgt,
struct task_struct *tsk,
int map_p, char *vm_path,
unsigned long vm_start,
@@ -230,6 +230,14 @@ stap_utrace_detach(struct task_struct *tsk,
if (tsk == NULL || tsk->pid <= 1)
return 0;
+#ifdef PF_KTHREAD
+ // Ignore kernel threads. On systems without PF_KTHREAD,
+ // we're ok, since kernel threads won't be matched by the
+ // utrace_attach_task() call below.
+ if (tsk->flags & PF_KTHREAD)
+ return 0;
+#endif
+
// Notice we're not calling get_task_mm() here. Normally we
// avoid tasks with no mm, because those are kernel threads.
// So, why is this function different? When a thread is in
@@ -302,6 +310,14 @@ stap_utrace_detach_ops(struct utrace_engine_ops *ops)
rcu_read_lock();
do_each_thread(grp, tsk) {
+#ifdef PF_KTHREAD
+ // Ignore kernel threads. On systems without
+ // PF_KTHREAD, we're ok, since kernel threads won't be
+ // matched by the stap_utrace_detach() call.
+ if (tsk->flags & PF_KTHREAD)
+ continue;
+#endif
+
rc = stap_utrace_detach(tsk, ops);
if (rc != 0)
goto udo_err;
@@ -414,7 +430,14 @@ __stp_utrace_attach(struct task_struct *tsk,
if (tsk == NULL || tsk->pid <= 1)
return EPERM;
- // Ignore threads with no mm (which are kernel threads).
+#ifdef PF_KTHREAD
+ // Ignore kernel threads
+ if (tsk->flags & PF_KTHREAD)
+ return EPERM;
+#endif
+
+ // Ignore threads with no mm (which are either kernel threads
+ // or "mortally wounded" threads).
mm = get_task_mm(tsk);
if (! mm)
return EPERM;
@@ -917,7 +940,7 @@ utftq_out:
}
-struct vm_area_struct *
+static struct vm_area_struct *
__stp_find_file_based_vma(struct mm_struct *mm, unsigned long addr)
{
struct vm_area_struct *vma = find_vma(mm, addr);
@@ -1218,7 +1241,7 @@ struct utrace_engine_ops __stp_utrace_task_finder_ops = {
.report_death = stap_utrace_task_finder_report_death,
};
-int
+static int
stap_start_task_finder(void)
{
int rc = 0;