aboutsummaryrefslogtreecommitdiffstats
path: root/samples
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-11-13 16:05:08 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-11-13 16:05:08 -0500
commit31486372a1e9a66ec2e9e2903b8792bba7e503e1 (patch)
tree84f61e0758695e6fbee8d2b7d7b9bc4a5ce6e03b /samples
parent8e9a2dba8686187d8c8179e5b86640e653963889 (diff)
parentfcdfafcb73be8fa45909327bbddca46fb362a675 (diff)
Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf updates from Ingo Molnar: "The main changes in this cycle were: Kernel: - kprobes updates: use better W^X patterns for code modifications, improve optprobes, remove jprobes. (Masami Hiramatsu, Kees Cook) - core fixes: event timekeeping (enabled/running times statistics) fixes, perf_event_read() locking fixes and cleanups, etc. (Peter Zijlstra) - Extend x86 Intel free-running PEBS support and support x86 user-register sampling in perf record and perf script. (Andi Kleen) Tooling: - Completely rework the way inline frames are handled. Instead of querying for the inline nodes on-demand in the individual tools, we now create proper callchain nodes for inlined frames. (Milian Wolff) - 'perf trace' updates (Arnaldo Carvalho de Melo) - Implement a way to print formatted output to per-event files in 'perf script' to facilitate generate flamegraphs, elliminating the need to write scripts to do that separation (yuzhoujian, Arnaldo Carvalho de Melo) - Update vendor events JSON metrics for Intel's Broadwell, Broadwell Server, Haswell, Haswell Server, IvyBridge, IvyTown, JakeTown, Sandy Bridge, Skylake, SkyLake Server - and Goldmont Plus V1 (Andi Kleen, Kan Liang) - Multithread the synthesizing of PERF_RECORD_ events for pre-existing threads in 'perf top', speeding up that phase, greatly improving the user experience in systems such as Intel's Knights Mill (Kan Liang) - Introduce the concept of weak groups in 'perf stat': try to set up a group, but if it's not schedulable fallback to not using a group. That gives us the best of both worlds: groups if they work, but still a usable fallback if they don't. E.g: (Andi Kleen) - perf sched timehist enhancements (David Ahern) - ... various other enhancements, updates, cleanups and fixes" * 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (139 commits) kprobes: Don't spam the build log with deprecation warnings arm/kprobes: Remove jprobe test case arm/kprobes: Fix kretprobe test to check correct counter perf srcline: Show correct function name for srcline of callchains perf srcline: Fix memory leak in addr2inlines() perf trace beauty kcmp: Beautify arguments perf trace beauty: Implement pid_fd beautifier tools include uapi: Grab a copy of linux/kcmp.h perf callchain: Fix double mapping al->addr for children without self period perf stat: Make --per-thread update shadow stats to show metrics perf stat: Move the shadow stats scale computation in perf_stat__update_shadow_stats perf tools: Add perf_data_file__write function perf tools: Add struct perf_data_file perf tools: Rename struct perf_data_file to perf_data perf script: Print information about per-event-dump files perf trace beauty prctl: Generate 'option' string table from kernel headers tools include uapi: Grab a copy of linux/prctl.h perf script: Allow creating per-event dump files perf evsel: Restore evsel->priv as a tool private area perf script: Use event_format__fprintf() ...
Diffstat (limited to 'samples')
-rw-r--r--samples/kprobes/Makefile2
-rw-r--r--samples/kprobes/jprobe_example.c67
2 files changed, 1 insertions, 68 deletions
diff --git a/samples/kprobes/Makefile b/samples/kprobes/Makefile
index 68739bc4fc6a..880e54d2c082 100644
--- a/samples/kprobes/Makefile
+++ b/samples/kprobes/Makefile
@@ -1,5 +1,5 @@
1# builds the kprobes example kernel modules; 1# builds the kprobes example kernel modules;
2# then to use one (as root): insmod <module_name.ko> 2# then to use one (as root): insmod <module_name.ko>
3 3
4obj-$(CONFIG_SAMPLE_KPROBES) += kprobe_example.o jprobe_example.o 4obj-$(CONFIG_SAMPLE_KPROBES) += kprobe_example.o
5obj-$(CONFIG_SAMPLE_KRETPROBES) += kretprobe_example.o 5obj-$(CONFIG_SAMPLE_KRETPROBES) += kretprobe_example.o
diff --git a/samples/kprobes/jprobe_example.c b/samples/kprobes/jprobe_example.c
deleted file mode 100644
index e3c0a40909f7..000000000000
--- a/samples/kprobes/jprobe_example.c
+++ /dev/null
@@ -1,67 +0,0 @@
1/*
2 * Here's a sample kernel module showing the use of jprobes to dump
3 * the arguments of _do_fork().
4 *
5 * For more information on theory of operation of jprobes, see
6 * Documentation/kprobes.txt
7 *
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
10 * console whenever _do_fork() is invoked to create a new process.
11 * (Some messages may be suppressed if syslogd is configured to
12 * eliminate duplicate messages.)
13 */
14
15#include <linux/kernel.h>
16#include <linux/module.h>
17#include <linux/kprobes.h>
18
19/*
20 * Jumper probe for _do_fork.
21 * Mirror principle enables access to arguments of the probed routine
22 * from the probe handler.
23 */
24
25/* Proxy routine having the same arguments as actual _do_fork() routine */
26static long j_do_fork(unsigned long clone_flags, unsigned long stack_start,
27 unsigned long stack_size, int __user *parent_tidptr,
28 int __user *child_tidptr, unsigned long tls)
29{
30 pr_info("jprobe: clone_flags = 0x%lx, stack_start = 0x%lx "
31 "stack_size = 0x%lx\n", clone_flags, stack_start, stack_size);
32
33 /* Always end with a call to jprobe_return(). */
34 jprobe_return();
35 return 0;
36}
37
38static struct jprobe my_jprobe = {
39 .entry = j_do_fork,
40 .kp = {
41 .symbol_name = "_do_fork",
42 },
43};
44
45static int __init jprobe_init(void)
46{
47 int ret;
48
49 ret = register_jprobe(&my_jprobe);
50 if (ret < 0) {
51 pr_err("register_jprobe failed, returned %d\n", ret);
52 return -1;
53 }
54 pr_info("Planted jprobe at %p, handler addr %p\n",
55 my_jprobe.kp.addr, my_jprobe.entry);
56 return 0;
57}
58
59static void __exit jprobe_exit(void)
60{
61 unregister_jprobe(&my_jprobe);
62 pr_info("jprobe at %p unregistered\n", my_jprobe.kp.addr);
63}
64
65module_init(jprobe_init)
66module_exit(jprobe_exit)
67MODULE_LICENSE("GPL");