Deleted Added
full compact
subr_prof.c (72912) subr_prof.c (74903)
1/*-
2 * Copyright (c) 1982, 1986, 1993
3 * The Regents of the University of California. 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

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

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)subr_prof.c 8.3 (Berkeley) 9/23/93
1/*-
2 * Copyright (c) 1982, 1986, 1993
3 * The Regents of the University of California. 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

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

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)subr_prof.c 8.3 (Berkeley) 9/23/93
34 * $FreeBSD: head/sys/kern/subr_prof.c 72912 2001-02-22 18:07:31Z jhb $
34 * $FreeBSD: head/sys/kern/subr_prof.c 74903 2001-03-28 03:06:10Z jhb $
35 */
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/sysproto.h>
40#include <sys/ipl.h>
41#include <sys/kernel.h>
42#include <sys/proc.h>

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

87 int cputime_overhead;
88 int empty_loop_time;
89 int i;
90 int mcount_overhead;
91 int mexitcount_overhead;
92 int nullfunc_loop_overhead;
93 int nullfunc_loop_profiled_time;
94 uintfptr_t tmp_addr;
35 */
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/sysproto.h>
40#include <sys/ipl.h>
41#include <sys/kernel.h>
42#include <sys/proc.h>

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

87 int cputime_overhead;
88 int empty_loop_time;
89 int i;
90 int mcount_overhead;
91 int mexitcount_overhead;
92 int nullfunc_loop_overhead;
93 int nullfunc_loop_profiled_time;
94 uintfptr_t tmp_addr;
95 int intrstate;
95 critical_t savecrit;
96#endif
97
98 /*
99 * Round lowpc and highpc to multiples of the density we're using
100 * so the rest of the scaling (here and in gprof) stays in ints.
101 */
102 p->lowpc = ROUNDDOWN((u_long)btext, HISTFRACTION * sizeof(HISTCOUNTER));
103 p->highpc = ROUNDUP((u_long)etext, HISTFRACTION * sizeof(HISTCOUNTER));

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

130 p->cputime_count = &KCOUNT(p, PC_TO_I(p, cputime));
131 p->mcount_count = &KCOUNT(p, PC_TO_I(p, mcount));
132 p->mexitcount_count = &KCOUNT(p, PC_TO_I(p, mexitcount));
133
134 /*
135 * Disable interrupts to avoid interference while we calibrate
136 * things.
137 */
96#endif
97
98 /*
99 * Round lowpc and highpc to multiples of the density we're using
100 * so the rest of the scaling (here and in gprof) stays in ints.
101 */
102 p->lowpc = ROUNDDOWN((u_long)btext, HISTFRACTION * sizeof(HISTCOUNTER));
103 p->highpc = ROUNDUP((u_long)etext, HISTFRACTION * sizeof(HISTCOUNTER));

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

130 p->cputime_count = &KCOUNT(p, PC_TO_I(p, cputime));
131 p->mcount_count = &KCOUNT(p, PC_TO_I(p, mcount));
132 p->mexitcount_count = &KCOUNT(p, PC_TO_I(p, mexitcount));
133
134 /*
135 * Disable interrupts to avoid interference while we calibrate
136 * things.
137 */
138 intrstate = save_intr();
139 disable_intr();
138 savecrit = critical_enter();
140
141 /*
142 * Determine overheads.
143 * XXX this needs to be repeated for each useful timer/counter.
144 */
145 cputime_overhead = 0;
146 startguprof(p);
147 for (i = 0; i < CALIB_SCALE; i++)

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

185#else
186#error
187#endif
188 mexitcount_overhead = KCOUNT(p, PC_TO_I(p, tmp_addr));
189
190 p->state = GMON_PROF_OFF;
191 stopguprof(p);
192
139
140 /*
141 * Determine overheads.
142 * XXX this needs to be repeated for each useful timer/counter.
143 */
144 cputime_overhead = 0;
145 startguprof(p);
146 for (i = 0; i < CALIB_SCALE; i++)

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

184#else
185#error
186#endif
187 mexitcount_overhead = KCOUNT(p, PC_TO_I(p, tmp_addr));
188
189 p->state = GMON_PROF_OFF;
190 stopguprof(p);
191
193 restore_intr(intrstate);
192 critical_exit(savecrit);
194
195 nullfunc_loop_profiled_time = 0;
196 for (tmp_addr = (uintfptr_t)nullfunc_loop_profiled;
197 tmp_addr < (uintfptr_t)nullfunc_loop_profiled_end;
198 tmp_addr += HISTFRACTION * sizeof(HISTCOUNTER))
199 nullfunc_loop_profiled_time += KCOUNT(p, PC_TO_I(p, tmp_addr));
200#define CALIB_DOSCALE(count) (((count) + CALIB_SCALE / 3) / CALIB_SCALE)
201#define c2n(count, freq) ((int)((count) * 1000000000LL / freq))

--- 265 unchanged lines hidden ---
193
194 nullfunc_loop_profiled_time = 0;
195 for (tmp_addr = (uintfptr_t)nullfunc_loop_profiled;
196 tmp_addr < (uintfptr_t)nullfunc_loop_profiled_end;
197 tmp_addr += HISTFRACTION * sizeof(HISTCOUNTER))
198 nullfunc_loop_profiled_time += KCOUNT(p, PC_TO_I(p, tmp_addr));
199#define CALIB_DOSCALE(count) (((count) + CALIB_SCALE / 3) / CALIB_SCALE)
200#define c2n(count, freq) ((int)((count) * 1000000000LL / freq))

--- 265 unchanged lines hidden ---