This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: [RFC] [PATCH 2.6.37-rc5-tip 8/20] 8: uprobes: mmap and fork hooks.
- From: Peter Zijlstra <peterz at infradead dot org>
- To: Srikar Dronamraju <srikar at linux dot vnet dot ibm dot com>
- Cc: Ingo Molnar <mingo at elte dot hu>, Steven Rostedt <rostedt at goodmis dot org>, Linux-mm <linux-mm at vger dot kernel dot org>, Arnaldo Carvalho de Melo <acme at infradead dot org>, Linus Torvalds <torvalds at linux-foundation dot org>, Ananth N Mavinakayanahalli <ananth at in dot ibm dot com>, Christoph Hellwig <hch at infradead dot org>, 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>, SystemTap <systemtap at sources dot redhat dot com>, Jim Keniston <jkenisto at linux dot vnet dot ibm dot com>, Frederic Weisbecker <fweisbec at gmail dot com>, Andi Kleen <andi at firstfloor dot org>, Andrew Morton <akpm at linux-foundation dot org>, "Paul E. McKenney" <paulmck at linux dot vnet dot ibm dot com>
- Date: Tue, 25 Jan 2011 13:15:41 +0100
- Subject: Re: [RFC] [PATCH 2.6.37-rc5-tip 8/20] 8: uprobes: mmap and fork hooks.
- References: <20101216095714.23751.52601.sendpatchset@localhost6.localdomain6> <20101216095848.23751.73144.sendpatchset@localhost6.localdomain6>
On Thu, 2010-12-16 at 15:28 +0530, Srikar Dronamraju wrote:
> +static void search_within_subtree(struct rb_node *n, struct inode *inode,
> + struct list_head *tmp_list);
> +
> +static void add_to_temp_list(struct vm_area_struct *vma, struct inode *inode,
> + struct list_head *tmp_list)
> +{
> + struct uprobe *uprobe;
> + struct rb_node *n;
> + unsigned long flags;
> +
> + n = uprobes_tree.rb_node;
> + spin_lock_irqsave(&treelock, flags);
> + while (n) {
> + uprobe = rb_entry(n, struct uprobe, rb_node);
> + if (match_inode(uprobe, inode, &n)) {
> + list_add(&uprobe->pending_list, tmp_list);
> + search_within_subtree(n, inode, tmp_list);
> + break;
> + }
> + }
> + spin_unlock_irqrestore(&treelock, flags);
> +}
> +
> +static void __search_within_subtree(struct rb_node *p, struct inode *inode,
> + struct list_head *tmp_list)
> +{
> + struct uprobe *uprobe;
> +
> + uprobe = rb_entry(p, struct uprobe, rb_node);
> + if (match_inode(uprobe, inode, &p)) {
> + list_add(&uprobe->pending_list, tmp_list);
> + search_within_subtree(p, inode, tmp_list);
> + }
> +
> +
> +}
> +
> +static void search_within_subtree(struct rb_node *n, struct inode *inode,
> + struct list_head *tmp_list)
> +{
> + struct rb_node *p;
> +
> + if (p)
> + __search_within_subtree(p, inode, tmp_list);
> +
> + p = n->rb_right;
> + if (p)
> + __search_within_subtree(p, inode, tmp_list);
> +}
Whee recursion FTW!, you just blew your kernel stack :-)
Since you sort inode first, offset second, I think you can simply look
for the first matching inode entry and simply rb_next() until you don't
match.