From 5bd21014caba0815fafd4b713b26198c569aba93 Mon Sep 17 00:00:00 2001 From: bde Date: Sun, 29 Oct 2006 09:48:44 +0000 Subject: Removed some SMP ifdefs so that using the TSC as a cputime clock is not completely decided at config time. Just don't default to using the TSC if there are multiple active CPUs. Also, don't default to using the TSC if it is broken. SMP ifdefs are still used to disallow using perfmon since perfmon is always broken if SMP is just configured. This only helps much for SMP kernels running on 1 CPU. The overheads for using the i8254 cputime clock were a bit too high on 486/33's, and now on multi-GHz CPUs they are usually in the 99-99.9% range. Switching from the old default of an i8254 clock to the TSC works poorly because the overheads are not recalibrated. Use the same condition for declaring perfmon stuff as for using it. --- sys/amd64/amd64/prof_machdep.c | 15 +++++---------- 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 #include #include +#include #include #include @@ -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 #include #include +#include #include #include @@ -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(); } -- cgit v1.1