diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-02-28 13:20:25 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-02-28 13:20:25 -0500 |
commit | 6556a6743549defc32e5f90ee2cb1ecd833a44c3 (patch) | |
tree | 622306583d4a3c13235a8bfc012854c125c597f1 /kernel/kprobes.c | |
parent | e0d272429a34ff143bfa04ee8e29dd4eed2964c7 (diff) | |
parent | 1dd2980d990068e20045b90c424518cc7f3657ff (diff) |
Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (172 commits)
perf_event, amd: Fix spinlock initialization
perf_event: Fix preempt warning in perf_clock()
perf tools: Flush maps on COMM events
perf_events, x86: Split PMU definitions into separate files
perf annotate: Handle samples not at objdump output addr boundaries
perf_events, x86: Remove superflous MSR writes
perf_events: Simplify code by removing cpu argument to hw_perf_group_sched_in()
perf_events, x86: AMD event scheduling
perf_events: Add new start/stop PMU callbacks
perf_events: Report the MMAP pgoff value in bytes
perf annotate: Defer allocating sym_priv->hist array
perf symbols: Improve debugging information about symtab origins
perf top: Use a macro instead of a constant variable
perf symbols: Check the right return variable
perf/scripts: Tag syscall_name helper as not yet available
perf/scripts: Add perf-trace-python Documentation
perf/scripts: Remove unnecessary PyTuple resizes
perf/scripts: Add syscall tracing scripts
perf/scripts: Add Python scripting engine
perf/scripts: Remove check-perf-trace from listed scripts
...
Fix trivial conflict in tools/perf/util/probe-event.c
Diffstat (limited to 'kernel/kprobes.c')
-rw-r--r-- | kernel/kprobes.c | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/kernel/kprobes.c b/kernel/kprobes.c index c4b43430d393..ccec774c716d 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #include <linux/debugfs.h> | 44 | #include <linux/debugfs.h> |
45 | #include <linux/kdebug.h> | 45 | #include <linux/kdebug.h> |
46 | #include <linux/memory.h> | 46 | #include <linux/memory.h> |
47 | #include <linux/ftrace.h> | ||
47 | 48 | ||
48 | #include <asm-generic/sections.h> | 49 | #include <asm-generic/sections.h> |
49 | #include <asm/cacheflush.h> | 50 | #include <asm/cacheflush.h> |
@@ -125,30 +126,6 @@ static LIST_HEAD(kprobe_insn_pages); | |||
125 | static int kprobe_garbage_slots; | 126 | static int kprobe_garbage_slots; |
126 | static int collect_garbage_slots(void); | 127 | static int collect_garbage_slots(void); |
127 | 128 | ||
128 | static int __kprobes check_safety(void) | ||
129 | { | ||
130 | int ret = 0; | ||
131 | #if defined(CONFIG_PREEMPT) && defined(CONFIG_FREEZER) | ||
132 | ret = freeze_processes(); | ||
133 | if (ret == 0) { | ||
134 | struct task_struct *p, *q; | ||
135 | do_each_thread(p, q) { | ||
136 | if (p != current && p->state == TASK_RUNNING && | ||
137 | p->pid != 0) { | ||
138 | printk("Check failed: %s is running\n",p->comm); | ||
139 | ret = -1; | ||
140 | goto loop_end; | ||
141 | } | ||
142 | } while_each_thread(p, q); | ||
143 | } | ||
144 | loop_end: | ||
145 | thaw_processes(); | ||
146 | #else | ||
147 | synchronize_sched(); | ||
148 | #endif | ||
149 | return ret; | ||
150 | } | ||
151 | |||
152 | /** | 129 | /** |
153 | * __get_insn_slot() - Find a slot on an executable page for an instruction. | 130 | * __get_insn_slot() - Find a slot on an executable page for an instruction. |
154 | * We allocate an executable page if there's no room on existing ones. | 131 | * We allocate an executable page if there's no room on existing ones. |
@@ -236,9 +213,8 @@ static int __kprobes collect_garbage_slots(void) | |||
236 | { | 213 | { |
237 | struct kprobe_insn_page *kip, *next; | 214 | struct kprobe_insn_page *kip, *next; |
238 | 215 | ||
239 | /* Ensure no-one is preepmted on the garbages */ | 216 | /* Ensure no-one is interrupted on the garbages */ |
240 | if (check_safety()) | 217 | synchronize_sched(); |
241 | return -EAGAIN; | ||
242 | 218 | ||
243 | list_for_each_entry_safe(kip, next, &kprobe_insn_pages, list) { | 219 | list_for_each_entry_safe(kip, next, &kprobe_insn_pages, list) { |
244 | int i; | 220 | int i; |
@@ -729,7 +705,8 @@ int __kprobes register_kprobe(struct kprobe *p) | |||
729 | 705 | ||
730 | preempt_disable(); | 706 | preempt_disable(); |
731 | if (!kernel_text_address((unsigned long) p->addr) || | 707 | if (!kernel_text_address((unsigned long) p->addr) || |
732 | in_kprobes_functions((unsigned long) p->addr)) { | 708 | in_kprobes_functions((unsigned long) p->addr) || |
709 | ftrace_text_reserved(p->addr, p->addr)) { | ||
733 | preempt_enable(); | 710 | preempt_enable(); |
734 | return -EINVAL; | 711 | return -EINVAL; |
735 | } | 712 | } |