Deleted Added
full compact
prof_machdep.c (219461) prof_machdep.c (220433)
1/*-
2 * Copyright (c) 1996 Bruce D. Evans.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1996 Bruce D. Evans.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/i386/isa/prof_machdep.c 219461 2011-03-10 20:02:58Z jkim $");
28__FBSDID("$FreeBSD: head/sys/i386/isa/prof_machdep.c 220433 2011-04-07 23:28:28Z jkim $");
29
30#ifdef GUPROF
31#include "opt_i586_guprof.h"
32#include "opt_perfmon.h"
33
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/bus.h>

--- 128 unchanged lines hidden (view full) ---

165 * Return the time elapsed since the last call. The units are machine-
166 * dependent.
167 */
168int
169cputime()
170{
171 u_int count;
172 int delta;
29
30#ifdef GUPROF
31#include "opt_i586_guprof.h"
32#include "opt_perfmon.h"
33
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/bus.h>

--- 128 unchanged lines hidden (view full) ---

165 * Return the time elapsed since the last call. The units are machine-
166 * dependent.
167 */
168int
169cputime()
170{
171 u_int count;
172 int delta;
173#if (defined(I586_CPU) || defined(I686_CPU)) && !defined(SMP) && \
174 defined(PERFMON) && defined(I586_PMC_GUPROF)
173#if (defined(I586_CPU) || defined(I686_CPU)) && \
174 defined(PERFMON) && defined(I586_PMC_GUPROF) && !defined(SMP)
175 u_quad_t event_count;
176#endif
177 u_char high, low;
178 static u_int prev_count;
179
180#if defined(I586_CPU) || defined(I686_CPU)
181 if (cputime_clock == CPUTIME_CLOCK_TSC) {
182 /*

--- 98 unchanged lines hidden (view full) ---

281 * The start and stop routines need not be here since we turn off profiling
282 * before calling them. They are here for convenience.
283 */
284
285void
286startguprof(gp)
287 struct gmonparam *gp;
288{
175 u_quad_t event_count;
176#endif
177 u_char high, low;
178 static u_int prev_count;
179
180#if defined(I586_CPU) || defined(I686_CPU)
181 if (cputime_clock == CPUTIME_CLOCK_TSC) {
182 /*

--- 98 unchanged lines hidden (view full) ---

281 * The start and stop routines need not be here since we turn off profiling
282 * before calling them. They are here for convenience.
283 */
284
285void
286startguprof(gp)
287 struct gmonparam *gp;
288{
289 if (cputime_clock == CPUTIME_CLOCK_UNINITIALIZED) {
290 cputime_clock = CPUTIME_CLOCK_I8254;
291#if defined(I586_CPU) || defined(I686_CPU)
289#if defined(I586_CPU) || defined(I686_CPU)
292 if (tsc_freq != 0 && mp_ncpus == 1)
290 uint64_t freq;
291
292 freq = atomic_load_acq_64(&tsc_freq);
293 if (cputime_clock == CPUTIME_CLOCK_UNINITIALIZED) {
294 if (freq != 0 && mp_ncpus == 1)
293 cputime_clock = CPUTIME_CLOCK_TSC;
295 cputime_clock = CPUTIME_CLOCK_TSC;
294#endif
296 else
297 cputime_clock = CPUTIME_CLOCK_I8254;
295 }
298 }
296 gp->profrate = i8254_freq << CPUTIME_CLOCK_I8254_SHIFT;
297#if defined(I586_CPU) || defined(I686_CPU)
298 if (cputime_clock == CPUTIME_CLOCK_TSC) {
299 if (cputime_clock == CPUTIME_CLOCK_TSC) {
299 gp->profrate = tsc_freq >> 1;
300 gp->profrate = freq >> 1;
300 cputime_prof_active = 1;
301 cputime_prof_active = 1;
301 }
302 } else
303 gp->profrate = i8254_freq << CPUTIME_CLOCK_I8254_SHIFT;
302#if defined(PERFMON) && defined(I586_PMC_GUPROF)
304#if defined(PERFMON) && defined(I586_PMC_GUPROF)
303 else if (cputime_clock == CPUTIME_CLOCK_I586_PMC) {
305 if (cputime_clock == CPUTIME_CLOCK_I586_PMC) {
304 if (perfmon_avail() &&
305 perfmon_setup(0, cputime_clock_pmc_conf) == 0) {
306 if (perfmon_start(0) != 0)
307 perfmon_fini(0);
308 else {
309 /* XXX 1 event == 1 us. */
310 gp->profrate = 1000000;
311

--- 8 unchanged lines hidden (view full) ---

320 gp->mexitcount_post_overhead = 0;
321 gp->mexitcount_pre_overhead = 0;
322
323 cputime_clock_pmc_init = TRUE;
324 }
325 }
326 }
327#endif /* PERFMON && I586_PMC_GUPROF */
306 if (perfmon_avail() &&
307 perfmon_setup(0, cputime_clock_pmc_conf) == 0) {
308 if (perfmon_start(0) != 0)
309 perfmon_fini(0);
310 else {
311 /* XXX 1 event == 1 us. */
312 gp->profrate = 1000000;
313

--- 8 unchanged lines hidden (view full) ---

322 gp->mexitcount_post_overhead = 0;
323 gp->mexitcount_pre_overhead = 0;
324
325 cputime_clock_pmc_init = TRUE;
326 }
327 }
328 }
329#endif /* PERFMON && I586_PMC_GUPROF */
330#else /* !(I586_CPU || I686_CPU) */
331 if (cputime_clock == CPUTIME_CLOCK_UNINITIALIZED)
332 cputime_clock = CPUTIME_CLOCK_I8254;
333 gp->profrate = i8254_freq << CPUTIME_CLOCK_I8254_SHIFT;
328#endif /* I586_CPU || I686_CPU */
329 cputime_bias = 0;
330 cputime();
331}
332
333void
334stopguprof(gp)
335 struct gmonparam *gp;

--- 35 unchanged lines hidden ---
334#endif /* I586_CPU || I686_CPU */
335 cputime_bias = 0;
336 cputime();
337}
338
339void
340stopguprof(gp)
341 struct gmonparam *gp;

--- 35 unchanged lines hidden ---