Skip to contentSkip to conversation

uprobes: Add exports for module use

PATCH In review Josh Stone 3 participants 4 messages Jan 10, 2013 – Jan 12, 2013

Subsystems (3)
lore
Share & tools
lore

Josh Stone

author
#0 lore raw

PATCH 1/1 uprobes: Add exports for module use

The original pull message for uprobes (commit 654443e2) noted:

This tree includes uprobes support in 'perf probe' - but SystemTap (and other tools) can take advantage of user probe points as well.

In order to actually be usable in module-based tools like SystemTap, the interface needs to be exported. This patch first adds the obvious exports for uprobe_register and uprobe_unregister. Then it also adds one for task_user_regset_view, which is necessary to get the correct state of userspace registers.

---
 kernel/events/uprobes.c | 3 +++
 kernel/ptrace.c         | 7 +++++++
 2 files changed, 10 insertions(+)
kernel/events/uprobes.c +3 -0
index dea7acf..1db8cb6 100644
@@ -27,6 +27,7 @@
 #include <linux/pagemap.h>	/* read_mapping_page */
 #include <linux/slab.h>
 #include <linux/sched.h>
+#include <linux/export.h>
 #include <linux/rmap.h>		/* anon_vma_prepare */
 #include <linux/mmu_notifier.h>	/* set_pte_at_notify */
 #include <linux/swap.h>		/* try_to_free_swap */
@@ -873,6 +874,7 @@ int uprobe_register(struct inode *inode, loff_t offset, struct uprobe_consumer *
 
 	return ret;
 }
+EXPORT_SYMBOL_GPL(uprobe_register);
 
 /*
  * uprobe_unregister - unregister a already registered probe.
@@ -904,6 +906,7 @@ void uprobe_unregister(struct inode *inode, loff_t offset, struct uprobe_consume
 	if (uprobe)
 		put_uprobe(uprobe);
 }
+EXPORT_SYMBOL_GPL(uprobe_unregister);
 
 static struct rb_node *
 find_node_in_range(struct inode *inode, loff_t min, loff_t max)
kernel/ptrace.c +7 -0
index 1599157..24eee5d 100644
@@ -673,6 +673,13 @@ static int ptrace_regset(struct task_struct *task, int req, unsigned int type,
 					     kiov->iov_len, kiov->iov_base);
 }
 
+/*
+ * This is declared in linux/regset.h and defined in machine-dependent
+ * code.  We put the export here, near the primary machine-neutral use,
+ * to ensure no machine forgets it.
+ */
+EXPORT_SYMBOL_GPL(task_user_regset_view);
+
 #endif
 
 int ptrace_request(struct task_struct *child, long request,
Signature · 1 line
1.7.11.7
#1 lore raw
Quoted 10 lines · Josh Stone

The original pull message for uprobes (commit 654443e2) noted:

This tree includes uprobes support in 'perf probe' - but SystemTap (and other tools) can take advantage of user probe points as well.

In order to actually be usable in module-based tools like SystemTap, the interface needs to be exported. This patch first adds the obvious exports for uprobe_register and uprobe_unregister. Then it also adds one for task_user_regset_view, which is necessary to get the correct state of userspace registers.

Get systemtap into the mainline kernel tree and we can talk.

author
#2 lore raw

Hi Christoph,

Quoted 5 lines · Christoph Hellwig
Quoted 4 lines · Josh Stone

The original pull message for uprobes (commit 654443e2) noted:

This tree includes uprobes support in 'perf probe' - but SystemTap (and other tools) can take advantage of user probe points as well.

I believe this quoted line already signaled the intent that SystemTap use should be allowed.

Quoted 1 line

Get systemtap into the mainline kernel tree and we can talk.

This is unlikely to ever happen, nor do I think it's necessarily appropriate. For instance, we are also developing an alternate mode of operation that uses Dyninst instead of kernel modules. We're keeping both modes for their different trade-offs, but in general the tool's relationship with the kernel is somewhat weaker now.

Thanks,
Josh

maintainer
#3 lore raw
In reply to Christoph Hellwig
Quoted 7 lines · Christoph Hellwig
Quoted 5 lines · Josh Stone

The original pull message for uprobes (commit 654443e2) noted:

This tree includes uprobes support in 'perf probe' - but SystemTap (and other tools) can take advantage of user probe points as well.

Quoted 7 lines
Quoted 5 lines

In order to actually be usable in module-based tools like SystemTap, the interface needs to be exported. This patch first adds the obvious exports for uprobe_register and uprobe_unregister. Then it also adds one for task_user_regset_view, which is necessary to get the correct state of userspace registers.

Get systemtap into the mainline kernel tree and we can talk.

I can't understand your reply.

Looks like, you do not like the fact that uprobes can be used by the out of tree modules. Why?

And why, say, kprobe_register() is exported then? Afaics, it does not have any modular in-kernel user.

As for systemtap in particular. I never used it, and probably you didn't. But it has a lot of users, and I know many people who find it very useful.

Oleg.