diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2009-12-30 01:23:40 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-12-30 01:50:49 -0500 |
commit | e6d9491bf8ba6728cc86aeabbc688d20ec0563b5 (patch) | |
tree | 1ca34f9f0608f688069da43688b2a9b8fa163644 /kernel | |
parent | 3d13ec2efdb5843ad91e57b60d50b44d922cf063 (diff) |
ksym_tracer: Fix race when incrementing count
We are under rcu read section but not holding the write lock, so
count++ is not atomic. Use atomic64_t instead.
Signed-off-by: Li 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: <4B3AF1EC.9010608@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/trace/trace_ksym.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/kernel/trace/trace_ksym.c b/kernel/trace/trace_ksym.c index 160a8d8b37a2..67d79f709fc5 100644 --- a/kernel/trace/trace_ksym.c +++ b/kernel/trace/trace_ksym.c | |||
@@ -32,6 +32,8 @@ | |||
32 | #include <linux/hw_breakpoint.h> | 32 | #include <linux/hw_breakpoint.h> |
33 | #include <asm/hw_breakpoint.h> | 33 | #include <asm/hw_breakpoint.h> |
34 | 34 | ||
35 | #include <asm/atomic.h> | ||
36 | |||
35 | /* | 37 | /* |
36 | * For now, let us restrict the no. of symbols traced simultaneously to number | 38 | * For now, let us restrict the no. of symbols traced simultaneously to number |
37 | * of available hardware breakpoint registers. | 39 | * of available hardware breakpoint registers. |
@@ -44,7 +46,7 @@ struct trace_ksym { | |||
44 | struct perf_event **ksym_hbp; | 46 | struct perf_event **ksym_hbp; |
45 | struct perf_event_attr attr; | 47 | struct perf_event_attr attr; |
46 | #ifdef CONFIG_PROFILE_KSYM_TRACER | 48 | #ifdef CONFIG_PROFILE_KSYM_TRACER |
47 | unsigned long counter; | 49 | atomic64_t counter; |
48 | #endif | 50 | #endif |
49 | struct hlist_node ksym_hlist; | 51 | struct hlist_node ksym_hlist; |
50 | }; | 52 | }; |
@@ -69,9 +71,8 @@ void ksym_collect_stats(unsigned long hbp_hit_addr) | |||
69 | 71 | ||
70 | rcu_read_lock(); | 72 | rcu_read_lock(); |
71 | hlist_for_each_entry_rcu(entry, node, &ksym_filter_head, ksym_hlist) { | 73 | hlist_for_each_entry_rcu(entry, node, &ksym_filter_head, ksym_hlist) { |
72 | if ((entry->attr.bp_addr == hbp_hit_addr) && | 74 | if (entry->attr.bp_addr == hbp_hit_addr) { |
73 | (entry->counter <= MAX_UL_INT)) { | 75 | atomic64_inc(&entry->counter); |
74 | entry->counter++; | ||
75 | break; | 76 | break; |
76 | } | 77 | } |
77 | } | 78 | } |
@@ -501,7 +502,8 @@ static int ksym_tracer_stat_show(struct seq_file *m, void *v) | |||
501 | seq_printf(m, " %-36s", fn_name); | 502 | seq_printf(m, " %-36s", fn_name); |
502 | else | 503 | else |
503 | seq_printf(m, " %-36s", "<NA>"); | 504 | seq_printf(m, " %-36s", "<NA>"); |
504 | seq_printf(m, " %15lu\n", entry->counter); | 505 | seq_printf(m, " %15llu\n", |
506 | (unsigned long long)atomic64_read(&entry->counter)); | ||
505 | 507 | ||
506 | return 0; | 508 | return 0; |
507 | } | 509 | } |