aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2007-12-06 04:12:28 -0500
committerRalf Baechle <ralf@linux-mips.org>2007-12-06 12:15:58 -0500
commit5e2862eb5a263a0339a85545d96fb20995d67b1f (patch)
treea455b6c67268f31662d61276602509b3221cba1f
parent0e8120e0946152720af3d73691550bba108a3826 (diff)
[MIPS] Oprofile: Fix computation of number of counters.
VSMP kernels will split the available performance counters between the two processors / cores. But don't do this when we're not on a VSMP system ... Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r--arch/mips/oprofile/op_model_mipsxx.c44
1 files changed, 38 insertions, 6 deletions
diff --git a/arch/mips/oprofile/op_model_mipsxx.c b/arch/mips/oprofile/op_model_mipsxx.c
index 423bc2c473df..bdfa07aecd97 100644
--- a/arch/mips/oprofile/op_model_mipsxx.c
+++ b/arch/mips/oprofile/op_model_mipsxx.c
@@ -6,6 +6,7 @@
6 * Copyright (C) 2004, 05, 06 by Ralf Baechle 6 * Copyright (C) 2004, 05, 06 by Ralf Baechle
7 * Copyright (C) 2005 by MIPS Technologies, Inc. 7 * Copyright (C) 2005 by MIPS Technologies, Inc.
8 */ 8 */
9#include <linux/cpumask.h>
9#include <linux/oprofile.h> 10#include <linux/oprofile.h>
10#include <linux/interrupt.h> 11#include <linux/interrupt.h>
11#include <linux/smp.h> 12#include <linux/smp.h>
@@ -33,11 +34,45 @@
33#ifdef CONFIG_MIPS_MT_SMP 34#ifdef CONFIG_MIPS_MT_SMP
34#define WHAT (M_TC_EN_VPE | M_PERFCTL_VPEID(smp_processor_id())) 35#define WHAT (M_TC_EN_VPE | M_PERFCTL_VPEID(smp_processor_id()))
35#define vpe_id() smp_processor_id() 36#define vpe_id() smp_processor_id()
37
38/*
39 * The number of bits to shift to convert between counters per core and
40 * counters per VPE. There is no reasonable interface atm to obtain the
41 * number of VPEs used by Linux and in the 34K this number is fixed to two
42 * anyways so we hardcore a few things here for the moment. The way it's
43 * done here will ensure that oprofile VSMP kernel will run right on a lesser
44 * core like a 24K also or with maxcpus=1.
45 */
46static inline unsigned int vpe_shift(void)
47{
48 if (num_possible_cpus() > 1)
49 return 1;
50
51 return 0;
52}
53
36#else 54#else
55
37#define WHAT 0 56#define WHAT 0
38#define vpe_id() 0 57#define vpe_id() 0
58
59static inline unsigned int vpe_shift(void)
60{
61 return 0;
62}
63
39#endif 64#endif
40 65
66static inline unsigned int counters_total_to_per_cpu(unsigned int counters)
67{
68 return counters >> vpe_shift();
69}
70
71static inline unsigned int counters_per_cpu_to_total(unsigned int counters)
72{
73 return counters << vpe_shift();
74}
75
41#define __define_perf_accessors(r, n, np) \ 76#define __define_perf_accessors(r, n, np) \
42 \ 77 \
43static inline unsigned int r_c0_ ## r ## n(void) \ 78static inline unsigned int r_c0_ ## r ## n(void) \
@@ -269,9 +304,7 @@ static int __init mipsxx_init(void)
269 304
270 reset_counters(counters); 305 reset_counters(counters);
271 306
272#ifdef CONFIG_MIPS_MT_SMP 307 counters = counters_total_to_per_cpu(counters);
273 counters >>= 1;
274#endif
275 308
276 op_model_mipsxx_ops.num_counters = counters; 309 op_model_mipsxx_ops.num_counters = counters;
277 switch (current_cpu_type()) { 310 switch (current_cpu_type()) {
@@ -330,9 +363,8 @@ static int __init mipsxx_init(void)
330static void mipsxx_exit(void) 363static void mipsxx_exit(void)
331{ 364{
332 int counters = op_model_mipsxx_ops.num_counters; 365 int counters = op_model_mipsxx_ops.num_counters;
333#ifdef CONFIG_MIPS_MT_SMP 366
334 counters <<= 1; 367 counters = counters_per_cpu_to_total(counters);
335#endif
336 reset_counters(counters); 368 reset_counters(counters);
337 369
338 perf_irq = null_perf_irq; 370 perf_irq = null_perf_irq;