diff options
author | Peter Zijlstra <peterz@infradead.org> | 2013-10-17 09:36:19 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2013-10-29 07:02:49 -0400 |
commit | d9494cb4299da66541a3f3ab82c552889bee0606 (patch) | |
tree | 5ffbb922c8eab879a582abd2b17335bde359634c | |
parent | aac898548d04c7bff179b79f805874b0d6f87571 (diff) |
perf: Remove useless atomic_t
There's nothing atomic about atomic_set vs atomic_read; so remove the
atomic_t usage.
Also, make running_sample_length static as it really is (and should
be) local to this translation unit.
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Cc: eranian@google.com
Cc: Don Zickus <dzickus@redhat.com>
Cc: jmario@redhat.com
Cc: acme@infradead.org
Cc: dave.hansen@linux.intel.com
Link: http://lkml.kernel.org/n/tip-vw9lg588x1ic248whybjon0c@git.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | kernel/events/core.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c index 5bd7fe43a7a2..028dad97760d 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
@@ -175,8 +175,8 @@ int sysctl_perf_event_sample_rate __read_mostly = DEFAULT_MAX_SAMPLE_RATE; | |||
175 | static int max_samples_per_tick __read_mostly = DIV_ROUND_UP(DEFAULT_MAX_SAMPLE_RATE, HZ); | 175 | static int max_samples_per_tick __read_mostly = DIV_ROUND_UP(DEFAULT_MAX_SAMPLE_RATE, HZ); |
176 | static int perf_sample_period_ns __read_mostly = DEFAULT_SAMPLE_PERIOD_NS; | 176 | static int perf_sample_period_ns __read_mostly = DEFAULT_SAMPLE_PERIOD_NS; |
177 | 177 | ||
178 | static atomic_t perf_sample_allowed_ns __read_mostly = | 178 | static int perf_sample_allowed_ns __read_mostly = |
179 | ATOMIC_INIT( DEFAULT_SAMPLE_PERIOD_NS * DEFAULT_CPU_TIME_MAX_PERCENT / 100); | 179 | DEFAULT_SAMPLE_PERIOD_NS * DEFAULT_CPU_TIME_MAX_PERCENT / 100; |
180 | 180 | ||
181 | void update_perf_cpu_limits(void) | 181 | void update_perf_cpu_limits(void) |
182 | { | 182 | { |
@@ -184,7 +184,7 @@ void update_perf_cpu_limits(void) | |||
184 | 184 | ||
185 | tmp *= sysctl_perf_cpu_time_max_percent; | 185 | tmp *= sysctl_perf_cpu_time_max_percent; |
186 | do_div(tmp, 100); | 186 | do_div(tmp, 100); |
187 | atomic_set(&perf_sample_allowed_ns, tmp); | 187 | ACCESS_ONCE(perf_sample_allowed_ns) = tmp; |
188 | } | 188 | } |
189 | 189 | ||
190 | static int perf_rotate_context(struct perf_cpu_context *cpuctx); | 190 | static int perf_rotate_context(struct perf_cpu_context *cpuctx); |
@@ -228,14 +228,15 @@ int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write, | |||
228 | * we detect that events are taking too long. | 228 | * we detect that events are taking too long. |
229 | */ | 229 | */ |
230 | #define NR_ACCUMULATED_SAMPLES 128 | 230 | #define NR_ACCUMULATED_SAMPLES 128 |
231 | DEFINE_PER_CPU(u64, running_sample_length); | 231 | static DEFINE_PER_CPU(u64, running_sample_length); |
232 | 232 | ||
233 | void perf_sample_event_took(u64 sample_len_ns) | 233 | void perf_sample_event_took(u64 sample_len_ns) |
234 | { | 234 | { |
235 | u64 avg_local_sample_len; | 235 | u64 avg_local_sample_len; |
236 | u64 local_samples_len; | 236 | u64 local_samples_len; |
237 | u64 allowed_ns = ACCESS_ONCE(perf_sample_allowed_ns); | ||
237 | 238 | ||
238 | if (atomic_read(&perf_sample_allowed_ns) == 0) | 239 | if (allowed_ns == 0) |
239 | return; | 240 | return; |
240 | 241 | ||
241 | /* decay the counter by 1 average sample */ | 242 | /* decay the counter by 1 average sample */ |
@@ -251,7 +252,7 @@ void perf_sample_event_took(u64 sample_len_ns) | |||
251 | */ | 252 | */ |
252 | avg_local_sample_len = local_samples_len/NR_ACCUMULATED_SAMPLES; | 253 | avg_local_sample_len = local_samples_len/NR_ACCUMULATED_SAMPLES; |
253 | 254 | ||
254 | if (avg_local_sample_len <= atomic_read(&perf_sample_allowed_ns)) | 255 | if (avg_local_sample_len <= allowed_ns) |
255 | return; | 256 | return; |
256 | 257 | ||
257 | if (max_samples_per_tick <= 1) | 258 | if (max_samples_per_tick <= 1) |
@@ -262,10 +263,9 @@ void perf_sample_event_took(u64 sample_len_ns) | |||
262 | perf_sample_period_ns = NSEC_PER_SEC / sysctl_perf_event_sample_rate; | 263 | perf_sample_period_ns = NSEC_PER_SEC / sysctl_perf_event_sample_rate; |
263 | 264 | ||
264 | printk_ratelimited(KERN_WARNING | 265 | printk_ratelimited(KERN_WARNING |
265 | "perf samples too long (%lld > %d), lowering " | 266 | "perf samples too long (%lld > %lld), lowering " |
266 | "kernel.perf_event_max_sample_rate to %d\n", | 267 | "kernel.perf_event_max_sample_rate to %d\n", |
267 | avg_local_sample_len, | 268 | avg_local_sample_len, allowed_ns, |
268 | atomic_read(&perf_sample_allowed_ns), | ||
269 | sysctl_perf_event_sample_rate); | 269 | sysctl_perf_event_sample_rate); |
270 | 270 | ||
271 | update_perf_cpu_limits(); | 271 | update_perf_cpu_limits(); |