Commit 88f7a890 authored by Li Zefan's avatar Li Zefan Committed by Ingo Molnar

ksym_tracer: Fix to make the tracer work

ksym tracer doesn't work:

 # echo tasklist_lock:rw- > ksym_trace_filter
 -bash: echo: write error: No such device

It's because we pass to perf_event_create_kernel_counter()
a cpu number which is not present.
Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: K.Prasad <prasad@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <4B3AF19E.1010201@cn.fujitsu.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 40892367
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <linux/percpu.h> #include <linux/percpu.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/cpu.h>
#include <linux/smp.h> #include <linux/smp.h>
#include <linux/hw_breakpoint.h> #include <linux/hw_breakpoint.h>
...@@ -388,7 +389,8 @@ register_wide_hw_breakpoint(struct perf_event_attr *attr, ...@@ -388,7 +389,8 @@ register_wide_hw_breakpoint(struct perf_event_attr *attr,
if (!cpu_events) if (!cpu_events)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
for_each_possible_cpu(cpu) { get_online_cpus();
for_each_online_cpu(cpu) {
pevent = per_cpu_ptr(cpu_events, cpu); pevent = per_cpu_ptr(cpu_events, cpu);
bp = perf_event_create_kernel_counter(attr, cpu, -1, triggered); bp = perf_event_create_kernel_counter(attr, cpu, -1, triggered);
...@@ -399,18 +401,20 @@ register_wide_hw_breakpoint(struct perf_event_attr *attr, ...@@ -399,18 +401,20 @@ register_wide_hw_breakpoint(struct perf_event_attr *attr,
goto fail; goto fail;
} }
} }
put_online_cpus();
return cpu_events; return cpu_events;
fail: fail:
for_each_possible_cpu(cpu) { for_each_online_cpu(cpu) {
pevent = per_cpu_ptr(cpu_events, cpu); pevent = per_cpu_ptr(cpu_events, cpu);
if (IS_ERR(*pevent)) if (IS_ERR(*pevent))
break; break;
unregister_hw_breakpoint(*pevent); unregister_hw_breakpoint(*pevent);
} }
put_online_cpus();
free_percpu(cpu_events); free_percpu(cpu_events);
/* return the error if any */
return ERR_PTR(err); return ERR_PTR(err);
} }
EXPORT_SYMBOL_GPL(register_wide_hw_breakpoint); EXPORT_SYMBOL_GPL(register_wide_hw_breakpoint);
......
...@@ -197,7 +197,6 @@ int process_new_ksym_entry(char *ksymname, int op, unsigned long addr) ...@@ -197,7 +197,6 @@ int process_new_ksym_entry(char *ksymname, int op, unsigned long addr)
entry->attr.bp_addr = addr; entry->attr.bp_addr = addr;
entry->attr.bp_len = HW_BREAKPOINT_LEN_4; entry->attr.bp_len = HW_BREAKPOINT_LEN_4;
ret = -EAGAIN;
entry->ksym_hbp = register_wide_hw_breakpoint(&entry->attr, entry->ksym_hbp = register_wide_hw_breakpoint(&entry->attr,
ksym_hbp_handler); ksym_hbp_handler);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment