This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[RFC] [PATCH 2.6.37-rc5-tip 18/20] 18: uprobes: commonly used filters.
- From: Srikar Dronamraju <srikar at linux dot vnet dot ibm dot com>
- To: Peter Zijlstra <peterz at infradead dot org>, Ingo Molnar <mingo at elte dot hu>
- Cc: Steven Rostedt <rostedt at goodmis dot org>, Srikar Dronamraju <srikar at linux dot vnet dot ibm dot com>, Arnaldo Carvalho de Melo <acme at infradead dot org>, Linus Torvalds <torvalds at linux-foundation dot org>, Andi Kleen <andi at firstfloor dot org>, Christoph Hellwig <hch at infradead dot org>, Ananth N Mavinakayanahalli <ananth at in dot ibm dot com>, Masami Hiramatsu <masami dot hiramatsu dot pt at hitachi dot com>, Oleg Nesterov <oleg at redhat dot com>, LKML <linux-kernel at vger dot kernel dot org>, Linux-mm <linux-mm at vger dot kernel dot org>, Jim Keniston <jkenisto at linux dot vnet dot ibm dot com>, Frederic Weisbecker <fweisbec at gmail dot com>, SystemTap <systemtap at sources dot redhat dot com>, Andrew Morton <akpm at linux-foundation dot org>, "Paul E. McKenney" <paulmck at linux dot vnet dot ibm dot com>
- Date: Thu, 16 Dec 2010 15:30:49 +0530
- Subject: [RFC] [PATCH 2.6.37-rc5-tip 18/20] 18: uprobes: commonly used filters.
- References: <20101216095714.23751.52601.sendpatchset@localhost6.localdomain6>
Provides most commonly used filters. Prevents users from having to define
their own filters. However this would be useful once we can
dynamically associate a filter with a uprobe-event tracer.
Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
---
kernel/uprobes.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/kernel/uprobes.c b/kernel/uprobes.c
index b0d323c..44a7ff6 100644
--- a/kernel/uprobes.c
+++ b/kernel/uprobes.c
@@ -1190,6 +1190,46 @@ int uprobe_post_notifier(struct pt_regs *regs)
return 0;
}
+bool uprobes_pid_filter(struct uprobe_consumer *self, struct task_struct *t)
+{
+ if (t->tgid == (long)self->fvalue)
+ return true;
+ return false;
+}
+
+bool uprobes_tid_filter(struct uprobe_consumer *self, struct task_struct *t)
+{
+ if (t->pid == (long)self->fvalue)
+ return true;
+ return false;
+}
+
+bool uprobes_ppid_filter(struct uprobe_consumer *self, struct task_struct *t)
+{
+ pid_t pid;
+
+ rcu_read_lock();
+ pid = task_tgid_vnr(t->real_parent);
+ rcu_read_unlock();
+
+ if (pid == (long)self->fvalue)
+ return true;
+ return false;
+}
+
+bool uprobes_sid_filter(struct uprobe_consumer *self, struct task_struct *t)
+{
+ pid_t pid;
+
+ rcu_read_lock();
+ pid = pid_vnr(task_session(t));
+ rcu_read_unlock();
+
+ if (pid == (long)self->fvalue)
+ return true;
+ return false;
+}
+
struct notifier_block uprobes_exception_nb = {
.notifier_call = uprobes_exception_notify,
.priority = 0x7ffffff0,
@@ -1207,3 +1247,4 @@ static void __exit exit_uprobes(void)
module_init(init_uprobes);
module_exit(exit_uprobes);
+