diff options
author | Robert Richter <robert.richter@amd.com> | 2009-05-22 13:47:38 -0400 |
---|---|---|
committer | Robert Richter <robert.richter@amd.com> | 2009-06-11 13:42:11 -0400 |
commit | 74c9a5c341bb1f6cbb5095b07c77230f19682ce8 (patch) | |
tree | 9299c89bb9bd7efabea7b603c86d0b9d13592c0a | |
parent | d2731a4387ad6c6bca07abfe9ed41d450fb6d665 (diff) |
x86/oprofile: remove MSR macros for ppro cpus
The macros CTRL_READ() and CTRL_WRITE() make the code hard to read and
maintain. This patch replaces them by rdmsr()/wrmsr() functions and
simplifies the code.
Signed-off-by: Robert Richter <robert.richter@amd.com>
-rw-r--r-- | arch/x86/oprofile/op_model_ppro.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c index a922a1a815c3..6c5d288c566e 100644 --- a/arch/x86/oprofile/op_model_ppro.c +++ b/arch/x86/oprofile/op_model_ppro.c | |||
@@ -27,9 +27,6 @@ static int num_counters = 2; | |||
27 | static int counter_width = 32; | 27 | static int counter_width = 32; |
28 | 28 | ||
29 | #define CTR_OVERFLOWED(n) (!((n) & (1ULL<<(counter_width-1)))) | 29 | #define CTR_OVERFLOWED(n) (!((n) & (1ULL<<(counter_width-1)))) |
30 | |||
31 | #define CTRL_READ(l, h, msrs, c) do {rdmsr((msrs->controls[(c)].addr), (l), (h)); } while (0) | ||
32 | #define CTRL_WRITE(l, h, msrs, c) do {wrmsr((msrs->controls[(c)].addr), (l), (h)); } while (0) | ||
33 | #define CTRL_CLEAR(x) (x &= (1<<21)) | 30 | #define CTRL_CLEAR(x) (x &= (1<<21)) |
34 | #define CTRL_SET_EVENT(val, e) (val |= e) | 31 | #define CTRL_SET_EVENT(val, e) (val |= e) |
35 | 32 | ||
@@ -88,9 +85,9 @@ static void ppro_setup_ctrs(struct op_msrs const * const msrs) | |||
88 | for (i = 0 ; i < num_counters; ++i) { | 85 | for (i = 0 ; i < num_counters; ++i) { |
89 | if (unlikely(!CTRL_IS_RESERVED(msrs, i))) | 86 | if (unlikely(!CTRL_IS_RESERVED(msrs, i))) |
90 | continue; | 87 | continue; |
91 | CTRL_READ(low, high, msrs, i); | 88 | rdmsr(msrs->controls[i].addr, low, high); |
92 | CTRL_CLEAR(low); | 89 | CTRL_CLEAR(low); |
93 | CTRL_WRITE(low, high, msrs, i); | 90 | wrmsr(msrs->controls[i].addr, low, high); |
94 | } | 91 | } |
95 | 92 | ||
96 | /* avoid a false detection of ctr overflows in NMI handler */ | 93 | /* avoid a false detection of ctr overflows in NMI handler */ |
@@ -107,14 +104,14 @@ static void ppro_setup_ctrs(struct op_msrs const * const msrs) | |||
107 | 104 | ||
108 | wrmsrl(msrs->counters[i].addr, -reset_value[i]); | 105 | wrmsrl(msrs->counters[i].addr, -reset_value[i]); |
109 | 106 | ||
110 | CTRL_READ(low, high, msrs, i); | 107 | rdmsr(msrs->controls[i].addr, low, high); |
111 | CTRL_CLEAR(low); | 108 | CTRL_CLEAR(low); |
112 | CTRL_SET_ENABLE(low); | 109 | CTRL_SET_ENABLE(low); |
113 | CTRL_SET_USR(low, counter_config[i].user); | 110 | CTRL_SET_USR(low, counter_config[i].user); |
114 | CTRL_SET_KERN(low, counter_config[i].kernel); | 111 | CTRL_SET_KERN(low, counter_config[i].kernel); |
115 | CTRL_SET_UM(low, counter_config[i].unit_mask); | 112 | CTRL_SET_UM(low, counter_config[i].unit_mask); |
116 | CTRL_SET_EVENT(low, counter_config[i].event); | 113 | CTRL_SET_EVENT(low, counter_config[i].event); |
117 | CTRL_WRITE(low, high, msrs, i); | 114 | wrmsr(msrs->controls[i].addr, low, high); |
118 | } else { | 115 | } else { |
119 | reset_value[i] = 0; | 116 | reset_value[i] = 0; |
120 | } | 117 | } |
@@ -162,9 +159,9 @@ static void ppro_start(struct op_msrs const * const msrs) | |||
162 | return; | 159 | return; |
163 | for (i = 0; i < num_counters; ++i) { | 160 | for (i = 0; i < num_counters; ++i) { |
164 | if (reset_value[i]) { | 161 | if (reset_value[i]) { |
165 | CTRL_READ(low, high, msrs, i); | 162 | rdmsr(msrs->controls[i].addr, low, high); |
166 | CTRL_SET_ACTIVE(low); | 163 | CTRL_SET_ACTIVE(low); |
167 | CTRL_WRITE(low, high, msrs, i); | 164 | wrmsr(msrs->controls[i].addr, low, high); |
168 | } | 165 | } |
169 | } | 166 | } |
170 | } | 167 | } |
@@ -180,9 +177,9 @@ static void ppro_stop(struct op_msrs const * const msrs) | |||
180 | for (i = 0; i < num_counters; ++i) { | 177 | for (i = 0; i < num_counters; ++i) { |
181 | if (!reset_value[i]) | 178 | if (!reset_value[i]) |
182 | continue; | 179 | continue; |
183 | CTRL_READ(low, high, msrs, i); | 180 | rdmsr(msrs->controls[i].addr, low, high); |
184 | CTRL_SET_INACTIVE(low); | 181 | CTRL_SET_INACTIVE(low); |
185 | CTRL_WRITE(low, high, msrs, i); | 182 | wrmsr(msrs->controls[i].addr, low, high); |
186 | } | 183 | } |
187 | } | 184 | } |
188 | 185 | ||