diff options
-rw-r--r-- | sys/amd64/amd64/prof_machdep.c | 15 | ||||
-rw-r--r-- | sys/i386/isa/prof_machdep.c | 19 |
2 files changed, 15 insertions, 19 deletions
diff --git a/sys/amd64/amd64/prof_machdep.c b/sys/amd64/amd64/prof_machdep.c index 41c04d7..48ea613 100644 --- a/sys/amd64/amd64/prof_machdep.c +++ b/sys/amd64/amd64/prof_machdep.c @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include <sys/systm.h> #include <sys/gmon.h> #include <sys/kernel.h> +#include <sys/smp.h> #include <sys/sysctl.h> #include <machine/clock.h> @@ -54,7 +55,7 @@ __FBSDID("$FreeBSD$"); int cputime_bias = 1; /* initialize for locality of reference */ static int cputime_clock = CPUTIME_CLOCK_UNINITIALIZED; -#ifdef I586_PMC_GUPROF +#if defined(PERFMON) && defined(I586_PMC_GUPROF) static u_int cputime_clock_pmc_conf = I586_PMC_GUPROF; static int cputime_clock_pmc_init; static struct gmonparam saved_gmp; @@ -204,7 +205,6 @@ cputime() u_char high, low; static u_int prev_count; -#ifndef SMP if (cputime_clock == CPUTIME_CLOCK_TSC) { /* * Scale the TSC a little to make cputime()'s frequency @@ -218,7 +218,7 @@ cputime() prev_count = count; return (delta); } -#if defined(PERFMON) && defined(I586_PMC_GUPROF) +#if defined(PERFMON) && defined(I586_PMC_GUPROF) && !defined(SMP) if (cputime_clock == CPUTIME_CLOCK_I586_PMC) { /* * XXX permon_read() should be inlined so that the @@ -232,8 +232,7 @@ cputime() prev_count = count; return (delta); } -#endif /* PERFMON && I586_PMC_GUPROF */ -#endif /* !SMP */ +#endif /* PERFMON && I586_PMC_GUPROF && !SMP */ /* * Read the current value of the 8254 timer counter 0. @@ -315,13 +314,10 @@ startguprof(gp) { if (cputime_clock == CPUTIME_CLOCK_UNINITIALIZED) { cputime_clock = CPUTIME_CLOCK_I8254; -#ifndef SMP - if (tsc_freq != 0) + if (tsc_freq != 0 && !tsc_is_broken && mp_ncpus < 2) cputime_clock = CPUTIME_CLOCK_TSC; -#endif } gp->profrate = timer_freq << CPUTIME_CLOCK_I8254_SHIFT; -#ifndef SMP if (cputime_clock == CPUTIME_CLOCK_TSC) gp->profrate = tsc_freq >> 1; #if defined(PERFMON) && defined(I586_PMC_GUPROF) @@ -350,7 +346,6 @@ startguprof(gp) } } #endif /* PERFMON && I586_PMC_GUPROF */ -#endif /* !SMP */ cputime_bias = 0; cputime(); } diff --git a/sys/i386/isa/prof_machdep.c b/sys/i386/isa/prof_machdep.c index 8b19340..2ad00bd 100644 --- a/sys/i386/isa/prof_machdep.c +++ b/sys/i386/isa/prof_machdep.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include <sys/systm.h> #include <sys/gmon.h> #include <sys/kernel.h> +#include <sys/smp.h> #include <sys/sysctl.h> #include <machine/clock.h> @@ -50,7 +51,7 @@ __FBSDID("$FreeBSD$"); int cputime_bias = 1; /* initialize for locality of reference */ static int cputime_clock = CPUTIME_CLOCK_UNINITIALIZED; -#ifdef I586_PMC_GUPROF +#if defined(PERFMON) && defined(I586_PMC_GUPROF) static u_int cputime_clock_pmc_conf = I586_PMC_GUPROF; static int cputime_clock_pmc_init; static struct gmonparam saved_gmp; @@ -174,7 +175,7 @@ cputime() u_char high, low; static u_int prev_count; -#if (defined(I586_CPU) || defined(I686_CPU)) && !defined(SMP) +#if defined(I586_CPU) || defined(I686_CPU) if (cputime_clock == CPUTIME_CLOCK_TSC) { /* * Scale the TSC a little to make cputime()'s frequency @@ -188,7 +189,7 @@ cputime() prev_count = count; return (delta); } -#if defined(PERFMON) && defined(I586_PMC_GUPROF) +#if defined(PERFMON) && defined(I586_PMC_GUPROF) && !defined(SMP) if (cputime_clock == CPUTIME_CLOCK_I586_PMC) { /* * XXX permon_read() should be inlined so that the @@ -202,8 +203,8 @@ cputime() prev_count = count; return (delta); } -#endif /* PERFMON && I586_PMC_GUPROF */ -#endif /* (I586_CPU || I686_CPU) && !SMP */ +#endif /* PERFMON && I586_PMC_GUPROF && !SMP */ +#endif /* I586_CPU || I686_CPU */ /* * Read the current value of the 8254 timer counter 0. @@ -285,13 +286,13 @@ startguprof(gp) { if (cputime_clock == CPUTIME_CLOCK_UNINITIALIZED) { cputime_clock = CPUTIME_CLOCK_I8254; -#if (defined(I586_CPU) || defined(I686_CPU)) && !defined(SMP) - if (tsc_freq != 0) +#if defined(I586_CPU) || defined(I686_CPU) + if (tsc_freq != 0 && !tsc_is_broken && mp_ncpus < 2) cputime_clock = CPUTIME_CLOCK_TSC; #endif } gp->profrate = timer_freq << CPUTIME_CLOCK_I8254_SHIFT; -#if (defined(I586_CPU) || defined(I686_CPU)) && !defined(SMP) +#if defined(I586_CPU) || defined(I686_CPU) if (cputime_clock == CPUTIME_CLOCK_TSC) gp->profrate = tsc_freq >> 1; #if defined(PERFMON) && defined(I586_PMC_GUPROF) @@ -320,7 +321,7 @@ startguprof(gp) } } #endif /* PERFMON && I586_PMC_GUPROF */ -#endif /* (I586_CPU || I686_CPU) && !SMP */ +#endif /* I586_CPU || I686_CPU */ cputime_bias = 0; cputime(); } |