<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/kernel/trace/trace_uprobe.c, branch v3.9</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v3.9</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v3.9'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2013-02-08T17:28:08Z</updated>
<entry>
<title>uprobes/perf: Avoid uprobe_apply() whenever possible</title>
<updated>2013-02-08T17:28:08Z</updated>
<author>
<name>Oleg Nesterov</name>
<email>oleg@redhat.com</email>
</author>
<published>2013-02-04T18:05:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b2fe8ba674e8acbb9e8e63510b802c6d054d88a3'/>
<id>urn:sha1:b2fe8ba674e8acbb9e8e63510b802c6d054d88a3</id>
<content type='text'>
uprobe_perf_open/close call the costly uprobe_apply() every time,
we can avoid it if:

	- "nr_systemwide != 0" is not changed.

	- There is another process/thread with the same -&gt;mm.

	- copy_proccess() does inherit_event(). dup_mmap() preserves the
	  inserted breakpoints.

	- event-&gt;attr.enable_on_exec == T, we can rely on uprobe_mmap()
	  called by exec/mmap paths.

	- tp_target is exiting. Only _close() checks PF_EXITING, I don't
	  think TRACE_REG_PERF_OPEN can hit the dying task too often.

Signed-off-by: Oleg Nesterov &lt;oleg@redhat.com&gt;
</content>
</entry>
<entry>
<title>uprobes/perf: Teach trace_uprobe/perf code to use UPROBE_HANDLER_REMOVE</title>
<updated>2013-02-08T17:28:07Z</updated>
<author>
<name>Oleg Nesterov</name>
<email>oleg@redhat.com</email>
</author>
<published>2013-02-04T16:48:34Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=f42d24a1d20d2e72d1e5d48930f18b138dfad117'/>
<id>urn:sha1:f42d24a1d20d2e72d1e5d48930f18b138dfad117</id>
<content type='text'>
Change uprobe_trace_func() and uprobe_perf_func() to return "int". Change
uprobe_dispatcher() to return "trace_ret | perf_ret" although this is not
needed, currently TP_FLAG_TRACE/TP_FLAG_PROFILE are mutually exclusive.

The only functional change is that uprobe_perf_func() checks the filtering
too and returns UPROBE_HANDLER_REMOVE if nobody wants to trace current.

Testing:

	# perf probe -x /lib/libc.so.6 syscall

	# perf record -e probe_libc:syscall -i perl -e 'fork; syscall -1 for 1..10; wait'

	# perf report --show-total-period
		100.00%            10     perl  libc-2.8.so    [.] syscall

Before this patch:

	# cat /sys/kernel/debug/tracing/uprobe_profile
		/lib/libc.so.6 syscall				20

A child process doesn't have a counter, but still it hits this breakoint
"copied" by dup_mmap().

After the patch:

	# cat /sys/kernel/debug/tracing/uprobe_profile
		/lib/libc.so.6 syscall				11

The child process hits this int3 only once and does unapply_uprobe().

Signed-off-by: Oleg Nesterov &lt;oleg@redhat.com&gt;
</content>
</entry>
<entry>
<title>uprobes/perf: Teach trace_uprobe/perf code to pre-filter</title>
<updated>2013-02-08T17:28:07Z</updated>
<author>
<name>Oleg Nesterov</name>
<email>oleg@redhat.com</email>
</author>
<published>2013-02-04T16:11:58Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=31ba334836c0ac0039084859f14a5b96858493dc'/>
<id>urn:sha1:31ba334836c0ac0039084859f14a5b96858493dc</id>
<content type='text'>
Finally implement uprobe_perf_filter() which checks -&gt;nr_systemwide or
-&gt;perf_events to figure out whether we need to insert the breakpoint.

uprobe_perf_open/close are changed to do uprobe_apply(true/false) when
the new perf event comes or goes away.

Note that currently this is very suboptimal:

	- uprobe_register() called by TRACE_REG_PERF_REGISTER becomes a
	  heavy nop, consumer-&gt;filter() always returns F at this stage.

	  As it was already discussed we need uprobe_register_only() to
	  avoid the costly register_for_each_vma() when possible.

	- uprobe_apply() is oftenly overkill. Unless "nr_systemwide != 0"
	  changes we need uprobe_apply_mm(), unapply_uprobe() is almost
	  what we need.

	- uprobe_apply() can be simply avoided sometimes, see the next
	  changes.

Testing:

	# perf probe -x /lib/libc.so.6 syscall

	# perl -e 'syscall -1 while 1' &amp;
	[1] 530

	# perf record -e probe_libc:syscall perl -e 'syscall -1 for 1..10; sleep 1'

	# perf report --show-total-period
		100.00%            10     perl  libc-2.8.so    [.] syscall

Before this patch:

	# cat /sys/kernel/debug/tracing/uprobe_profile
		/lib/libc.so.6 syscall				79291

A huge -&gt;nrhit == 79291 reflects the fact that the background process
530 constantly hits this breakpoint too, even if doesn't contribute to
the output.

After the patch:

	# cat /sys/kernel/debug/tracing/uprobe_profile
		/lib/libc.so.6 syscall				10

This shows that only the target process was punished by int3.

Signed-off-by: Oleg Nesterov &lt;oleg@redhat.com&gt;
</content>
</entry>
<entry>
<title>uprobes/perf: Teach trace_uprobe/perf code to track the active perf_event's</title>
<updated>2013-02-08T17:28:06Z</updated>
<author>
<name>Oleg Nesterov</name>
<email>oleg@redhat.com</email>
</author>
<published>2013-02-03T19:58:35Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=736288ba5016e255869c26296014eeff649971c2'/>
<id>urn:sha1:736288ba5016e255869c26296014eeff649971c2</id>
<content type='text'>
Introduce "struct trace_uprobe_filter" which records the "active"
perf_event's attached to ftrace_event_call. For the start we simply
use list_head, we can optimize this later if needed. For example, we
do not really need to record an event with -&gt;parent != NULL, we can
rely on parent-&gt;child_list. And we can certainly do some optimizations
for the case when 2 events have the same -&gt;tp_target or tp_target-&gt;mm.

Change trace_uprobe_register() to process TRACE_REG_PERF_OPEN/CLOSE
and add/del this perf_event to the list.

We can probably avoid any locking, but lets start with the "obvioulsy
correct" trace_uprobe_filter-&gt;rwlock which protects everything.

Signed-off-by: Oleg Nesterov &lt;oleg@redhat.com&gt;
</content>
</entry>
<entry>
<title>uprobes/perf: Always increment trace_uprobe-&gt;nhit</title>
<updated>2013-02-08T17:24:34Z</updated>
<author>
<name>Oleg Nesterov</name>
<email>oleg@redhat.com</email>
</author>
<published>2013-01-31T18:55:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=1b47aefd9b6bd439a4be43c47acd22987ac22db8'/>
<id>urn:sha1:1b47aefd9b6bd439a4be43c47acd22987ac22db8</id>
<content type='text'>
Move tu-&gt;nhit++ from uprobe_trace_func() to uprobe_dispatcher().

-&gt;nhit counts how many time we hit the breakpoint inserted by this
uprobe, we do not want to loose this info if uprobe was enabled by
sys_perf_event_open().

Signed-off-by: Oleg Nesterov &lt;oleg@redhat.com&gt;
Acked-by: Srikar Dronamraju &lt;srikar@linux.vnet.ibm.com&gt;
</content>
</entry>
<entry>
<title>uprobes/tracing: Kill uprobe_trace_consumer, embed uprobe_consumer into trace_uprobe</title>
<updated>2013-02-08T17:24:33Z</updated>
<author>
<name>Oleg Nesterov</name>
<email>oleg@redhat.com</email>
</author>
<published>2013-01-31T18:47:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=a932b7381f81235530c3d0acbd3ba2c7537d78e5'/>
<id>urn:sha1:a932b7381f81235530c3d0acbd3ba2c7537d78e5</id>
<content type='text'>
trace_uprobe-&gt;consumer and "struct uprobe_trace_consumer" add the
unnecessary indirection and complicate the code for no reason.

This patch simply embeds uprobe_consumer into "struct trace_uprobe",
all other changes only fix the compilation errors.

Signed-off-by: Oleg Nesterov &lt;oleg@redhat.com&gt;
</content>
</entry>
<entry>
<title>uprobes/tracing: Introduce is_trace_uprobe_enabled()</title>
<updated>2013-02-08T17:24:30Z</updated>
<author>
<name>Oleg Nesterov</name>
<email>oleg@redhat.com</email>
</author>
<published>2013-01-31T18:15:30Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b64b007797c1e6d6b745c93c296ba1d5f4d72d86'/>
<id>urn:sha1:b64b007797c1e6d6b745c93c296ba1d5f4d72d86</id>
<content type='text'>
probe_event_enable/disable() check tu-&gt;consumer != NULL to avoid the
wrong uprobe_register/unregister().

We are going to kill this pointer and "struct uprobe_trace_consumer",
so we add the new helper, is_trace_uprobe_enabled(), which can rely
on TP_FLAG_TRACE/TP_FLAG_PROFILE instead.

Note: the current logic doesn't look optimal, it is not clear why
TP_FLAG_TRACE/TP_FLAG_PROFILE are mutually exclusive, we will probably
change this later.

Also kill the unused TP_FLAG_UPROBE.

Signed-off-by: Oleg Nesterov &lt;oleg@redhat.com&gt;
Acked-by: Srikar Dronamraju &lt;srikar@linux.vnet.ibm.com&gt;
</content>
</entry>
<entry>
<title>uprobes/tracing: Ensure inode != NULL in create_trace_uprobe()</title>
<updated>2013-02-08T17:24:14Z</updated>
<author>
<name>Oleg Nesterov</name>
<email>oleg@redhat.com</email>
</author>
<published>2013-01-28T16:08:47Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7e4e28c53963e6cfa94d8109bb8f5233c5659048'/>
<id>urn:sha1:7e4e28c53963e6cfa94d8109bb8f5233c5659048</id>
<content type='text'>
probe_event_enable/disable() check tu-&gt;inode != NULL at the start.
This is ugly, if igrab() can fail create_trace_uprobe() should not
succeed and "postpone" the failure.

And S_ISREG(inode-&gt;i_mode) check added by d24d7dbf is not safe.

Note: alloc_uprobe() should probably check igrab() != NULL as well.

Signed-off-by: Oleg Nesterov &lt;oleg@redhat.com&gt;
Acked-by: Srikar Dronamraju &lt;srikar@linux.vnet.ibm.com&gt;
</content>
</entry>
<entry>
<title>uprobes/tracing: Fully initialize uprobe_trace_consumer before uprobe_register()</title>
<updated>2013-02-08T17:10:19Z</updated>
<author>
<name>Oleg Nesterov</name>
<email>oleg@redhat.com</email>
</author>
<published>2013-01-27T17:36:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=4161824f18ff4f56f46595a4016c7315dd0d24f1'/>
<id>urn:sha1:4161824f18ff4f56f46595a4016c7315dd0d24f1</id>
<content type='text'>
probe_event_enable() does uprobe_register() and only after that sets
utc-&gt;tu and tu-&gt;consumer/flags. This can race with uprobe_dispatcher()
which can miss these assignments or see them out of order. Nothing
really bad can happen, but this doesn't look clean/safe.

And this does not allow to use uprobe_consumer-&gt;filter() we are going
to add, it is called by uprobe_register() and it needs utc-&gt;tu.

Change this code to initialize everything before uprobe_register(), and
reset tu-&gt;consumer/flags if it fails. We can't race with event_disable(),
the caller holds event_mutex, and if we could the code would be wrong
anyway.

In fact I think uprobe_trace_consumer should die, it buys nothing but
complicates the code. We can simply add uprobe_consumer into trace_uprobe.

Signed-off-by: Oleg Nesterov &lt;oleg@redhat.com&gt;
Acked-by: Srikar Dronamraju &lt;srikar@linux.vnet.ibm.com&gt;
</content>
</entry>
<entry>
<title>uprobes/tracing: Fix dentry/mount leak in create_trace_uprobe()</title>
<updated>2013-02-08T17:10:17Z</updated>
<author>
<name>Oleg Nesterov</name>
<email>oleg@redhat.com</email>
</author>
<published>2013-01-27T17:20:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=84d7ed799fd6c1366547d88ddb8188c65de3b94f'/>
<id>urn:sha1:84d7ed799fd6c1366547d88ddb8188c65de3b94f</id>
<content type='text'>
create_trace_uprobe() does kern_path() to find -&gt;d_inode, but forgets
to do path_put(). We can do this right after igrab().

Signed-off-by: Oleg Nesterov &lt;oleg@redhat.com&gt;
Acked-by: Srikar Dronamraju &lt;srikar@linux.vnet.ibm.com&gt;
</content>
</entry>
</feed>
