diff options
| author | Petr Mladek <pmladek@suse.com> | 2015-10-01 18:37:11 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-10-01 21:42:35 -0400 |
| commit | 54aea4542980a3ed580426a81c5af799df4d610d (patch) | |
| tree | 6f9ca54438333b0ee829ec57f56712359447d33b /samples | |
| parent | 09a59a9d57a9d6f49510c93304d6e105deb83b93 (diff) | |
kprobes: use _do_fork() in samples to make them work again
Commit 3033f14ab78c ("clone: support passing tls argument via C rather
than pt_regs magic") introduced _do_fork() that allowed to pass @tls
parameter.
The old do_fork() is defined only for architectures that are not ready
to use this way and do not define HAVE_COPY_THREAD_TLS.
Let's use _do_fork() in the kprobe examples to make them work again on
all architectures.
Signed-off-by: Petr Mladek <pmladek@suse.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Thiago Macieira <thiago.macieira@intel.com>
Cc: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'samples')
| -rw-r--r-- | samples/kprobes/jprobe_example.c | 14 | ||||
| -rw-r--r-- | samples/kprobes/kprobe_example.c | 6 | ||||
| -rw-r--r-- | samples/kprobes/kretprobe_example.c | 4 |
3 files changed, 12 insertions, 12 deletions
diff --git a/samples/kprobes/jprobe_example.c b/samples/kprobes/jprobe_example.c index 9119ac6a8270..c285a3b8a9f1 100644 --- a/samples/kprobes/jprobe_example.c +++ b/samples/kprobes/jprobe_example.c | |||
| @@ -1,13 +1,13 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Here's a sample kernel module showing the use of jprobes to dump | 2 | * Here's a sample kernel module showing the use of jprobes to dump |
| 3 | * the arguments of do_fork(). | 3 | * the arguments of _do_fork(). |
| 4 | * | 4 | * |
| 5 | * For more information on theory of operation of jprobes, see | 5 | * For more information on theory of operation of jprobes, see |
| 6 | * Documentation/kprobes.txt | 6 | * Documentation/kprobes.txt |
| 7 | * | 7 | * |
| 8 | * Build and insert the kernel module as done in the kprobe example. | 8 | * Build and insert the kernel module as done in the kprobe example. |
| 9 | * You will see the trace data in /var/log/messages and on the | 9 | * You will see the trace data in /var/log/messages and on the |
| 10 | * console whenever do_fork() is invoked to create a new process. | 10 | * console whenever _do_fork() is invoked to create a new process. |
| 11 | * (Some messages may be suppressed if syslogd is configured to | 11 | * (Some messages may be suppressed if syslogd is configured to |
| 12 | * eliminate duplicate messages.) | 12 | * eliminate duplicate messages.) |
| 13 | */ | 13 | */ |
| @@ -17,13 +17,13 @@ | |||
| 17 | #include <linux/kprobes.h> | 17 | #include <linux/kprobes.h> |
| 18 | 18 | ||
| 19 | /* | 19 | /* |
| 20 | * Jumper probe for do_fork. | 20 | * Jumper probe for _do_fork. |
| 21 | * Mirror principle enables access to arguments of the probed routine | 21 | * Mirror principle enables access to arguments of the probed routine |
| 22 | * from the probe handler. | 22 | * from the probe handler. |
| 23 | */ | 23 | */ |
| 24 | 24 | ||
| 25 | /* Proxy routine having the same arguments as actual do_fork() routine */ | 25 | /* Proxy routine having the same arguments as actual _do_fork() routine */ |
| 26 | static long jdo_fork(unsigned long clone_flags, unsigned long stack_start, | 26 | static long j_do_fork(unsigned long clone_flags, unsigned long stack_start, |
| 27 | unsigned long stack_size, int __user *parent_tidptr, | 27 | unsigned long stack_size, int __user *parent_tidptr, |
| 28 | int __user *child_tidptr) | 28 | int __user *child_tidptr) |
| 29 | { | 29 | { |
| @@ -36,9 +36,9 @@ static long jdo_fork(unsigned long clone_flags, unsigned long stack_start, | |||
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | static struct jprobe my_jprobe = { | 38 | static struct jprobe my_jprobe = { |
| 39 | .entry = jdo_fork, | 39 | .entry = j_do_fork, |
| 40 | .kp = { | 40 | .kp = { |
| 41 | .symbol_name = "do_fork", | 41 | .symbol_name = "_do_fork", |
| 42 | }, | 42 | }, |
| 43 | }; | 43 | }; |
| 44 | 44 | ||
diff --git a/samples/kprobes/kprobe_example.c b/samples/kprobes/kprobe_example.c index 366db1a9fb65..727eb21c9c56 100644 --- a/samples/kprobes/kprobe_example.c +++ b/samples/kprobes/kprobe_example.c | |||
| @@ -1,13 +1,13 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * NOTE: This example is works on x86 and powerpc. | 2 | * NOTE: This example is works on x86 and powerpc. |
| 3 | * Here's a sample kernel module showing the use of kprobes to dump a | 3 | * Here's a sample kernel module showing the use of kprobes to dump a |
| 4 | * stack trace and selected registers when do_fork() is called. | 4 | * stack trace and selected registers when _do_fork() is called. |
| 5 | * | 5 | * |
| 6 | * For more information on theory of operation of kprobes, see | 6 | * For more information on theory of operation of kprobes, see |
| 7 | * Documentation/kprobes.txt | 7 | * Documentation/kprobes.txt |
| 8 | * | 8 | * |
| 9 | * You will see the trace data in /var/log/messages and on the console | 9 | * You will see the trace data in /var/log/messages and on the console |
| 10 | * whenever do_fork() is invoked to create a new process. | 10 | * whenever _do_fork() is invoked to create a new process. |
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
| @@ -16,7 +16,7 @@ | |||
| 16 | 16 | ||
| 17 | /* For each probe you need to allocate a kprobe structure */ | 17 | /* For each probe you need to allocate a kprobe structure */ |
| 18 | static struct kprobe kp = { | 18 | static struct kprobe kp = { |
| 19 | .symbol_name = "do_fork", | 19 | .symbol_name = "_do_fork", |
| 20 | }; | 20 | }; |
| 21 | 21 | ||
| 22 | /* kprobe pre_handler: called just before the probed instruction is executed */ | 22 | /* kprobe pre_handler: called just before the probed instruction is executed */ |
diff --git a/samples/kprobes/kretprobe_example.c b/samples/kprobes/kretprobe_example.c index 1041b6731598..ebb1d1aed547 100644 --- a/samples/kprobes/kretprobe_example.c +++ b/samples/kprobes/kretprobe_example.c | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | * | 7 | * |
| 8 | * usage: insmod kretprobe_example.ko func=<func_name> | 8 | * usage: insmod kretprobe_example.ko func=<func_name> |
| 9 | * | 9 | * |
| 10 | * If no func_name is specified, do_fork is instrumented | 10 | * If no func_name is specified, _do_fork is instrumented |
| 11 | * | 11 | * |
| 12 | * For more information on theory of operation of kretprobes, see | 12 | * For more information on theory of operation of kretprobes, see |
| 13 | * Documentation/kprobes.txt | 13 | * Documentation/kprobes.txt |
| @@ -25,7 +25,7 @@ | |||
| 25 | #include <linux/limits.h> | 25 | #include <linux/limits.h> |
| 26 | #include <linux/sched.h> | 26 | #include <linux/sched.h> |
| 27 | 27 | ||
| 28 | static char func_name[NAME_MAX] = "do_fork"; | 28 | static char func_name[NAME_MAX] = "_do_fork"; |
| 29 | module_param_string(func, func_name, NAME_MAX, S_IRUGO); | 29 | module_param_string(func, func_name, NAME_MAX, S_IRUGO); |
| 30 | MODULE_PARM_DESC(func, "Function to kretprobe; this module will report the" | 30 | MODULE_PARM_DESC(func, "Function to kretprobe; this module will report the" |
| 31 | " function's execution time"); | 31 | " function's execution time"); |
