Deleted Added
full compact
subr_prof.c (85733) subr_prof.c (88088)
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 85733 2001-10-30 15:04:57Z green $
34 * $FreeBSD: head/sys/kern/subr_prof.c 88088 2001-12-18 00:27:18Z jhb $
35 */
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/sysproto.h>
40#include <sys/kernel.h>
41#include <sys/lock.h>
42#include <sys/mutex.h>

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

85 * of KLDs.
86 */
87void
88kmupetext(uintfptr_t nhighpc)
89{
90 struct gmonparam np; /* slightly large */
91 struct gmonparam *p = &_gmonparam;
92 char *cp;
35 */
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/sysproto.h>
40#include <sys/kernel.h>
41#include <sys/lock.h>
42#include <sys/mutex.h>

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

85 * of KLDs.
86 */
87void
88kmupetext(uintfptr_t nhighpc)
89{
90 struct gmonparam np; /* slightly large */
91 struct gmonparam *p = &_gmonparam;
92 char *cp;
93 critical_t savecrit;
94
95 GIANT_REQUIRED;
96 bcopy(p, &np, sizeof(*p));
97 np.highpc = ROUNDUP(nhighpc, HISTFRACTION * sizeof(HISTCOUNTER));
98 if (np.highpc <= p->highpc)
99 return;
100 np.textsize = np.highpc - p->lowpc;
101 np.kcountsize = np.textsize / HISTFRACTION;

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

122 cp += np.kcountsize;
123 np.froms = (u_short *)cp;
124#ifdef GUPROF
125 /* Reinitialize pointers to overhead counters. */
126 np.cputime_count = &KCOUNT(&np, PC_TO_I(&np, cputime));
127 np.mcount_count = &KCOUNT(&np, PC_TO_I(&np, mcount));
128 np.mexitcount_count = &KCOUNT(&np, PC_TO_I(&np, mexitcount));
129#endif
93
94 GIANT_REQUIRED;
95 bcopy(p, &np, sizeof(*p));
96 np.highpc = ROUNDUP(nhighpc, HISTFRACTION * sizeof(HISTCOUNTER));
97 if (np.highpc <= p->highpc)
98 return;
99 np.textsize = np.highpc - p->lowpc;
100 np.kcountsize = np.textsize / HISTFRACTION;

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

121 cp += np.kcountsize;
122 np.froms = (u_short *)cp;
123#ifdef GUPROF
124 /* Reinitialize pointers to overhead counters. */
125 np.cputime_count = &KCOUNT(&np, PC_TO_I(&np, cputime));
126 np.mcount_count = &KCOUNT(&np, PC_TO_I(&np, mcount));
127 np.mexitcount_count = &KCOUNT(&np, PC_TO_I(&np, mexitcount));
128#endif
130 savecrit = critical_enter();
129 critical_enter();
131 bcopy(p->tos, np.tos, p->tossize);
132 bzero((char *)np.tos + p->tossize, np.tossize - p->tossize);
133 bcopy(p->kcount, np.kcount, p->kcountsize);
134 bzero((char *)np.kcount + p->kcountsize, np.kcountsize -
135 p->kcountsize);
136 bcopy(p->froms, np.froms, p->fromssize);
137 bzero((char *)np.froms + p->fromssize, np.fromssize - p->fromssize);
138 cp = (char *)p->tos;
139 bcopy(&np, p, sizeof(*p));
130 bcopy(p->tos, np.tos, p->tossize);
131 bzero((char *)np.tos + p->tossize, np.tossize - p->tossize);
132 bcopy(p->kcount, np.kcount, p->kcountsize);
133 bzero((char *)np.kcount + p->kcountsize, np.kcountsize -
134 p->kcountsize);
135 bcopy(p->froms, np.froms, p->fromssize);
136 bzero((char *)np.froms + p->fromssize, np.fromssize - p->fromssize);
137 cp = (char *)p->tos;
138 bcopy(&np, p, sizeof(*p));
140 critical_exit(savecrit);
139 critical_exit();
141 free(cp, M_GPROF);
142}
143
144static void
145kmstartup(dummy)
146 void *dummy;
147{
148 char *cp;
149 struct gmonparam *p = &_gmonparam;
150#ifdef GUPROF
151 int cputime_overhead;
152 int empty_loop_time;
153 int i;
154 int mcount_overhead;
155 int mexitcount_overhead;
156 int nullfunc_loop_overhead;
157 int nullfunc_loop_profiled_time;
158 uintfptr_t tmp_addr;
140 free(cp, M_GPROF);
141}
142
143static void
144kmstartup(dummy)
145 void *dummy;
146{
147 char *cp;
148 struct gmonparam *p = &_gmonparam;
149#ifdef GUPROF
150 int cputime_overhead;
151 int empty_loop_time;
152 int i;
153 int mcount_overhead;
154 int mexitcount_overhead;
155 int nullfunc_loop_overhead;
156 int nullfunc_loop_profiled_time;
157 uintfptr_t tmp_addr;
159 critical_t savecrit;
160#endif
161
162 /*
163 * Round lowpc and highpc to multiples of the density we're using
164 * so the rest of the scaling (here and in gprof) stays in ints.
165 */
166 p->lowpc = ROUNDDOWN((u_long)btext, HISTFRACTION * sizeof(HISTCOUNTER));
167 p->highpc = ROUNDUP((u_long)etext, HISTFRACTION * sizeof(HISTCOUNTER));

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

190 p->cputime_count = &KCOUNT(p, PC_TO_I(p, cputime));
191 p->mcount_count = &KCOUNT(p, PC_TO_I(p, mcount));
192 p->mexitcount_count = &KCOUNT(p, PC_TO_I(p, mexitcount));
193
194 /*
195 * Disable interrupts to avoid interference while we calibrate
196 * things.
197 */
158#endif
159
160 /*
161 * Round lowpc and highpc to multiples of the density we're using
162 * so the rest of the scaling (here and in gprof) stays in ints.
163 */
164 p->lowpc = ROUNDDOWN((u_long)btext, HISTFRACTION * sizeof(HISTCOUNTER));
165 p->highpc = ROUNDUP((u_long)etext, HISTFRACTION * sizeof(HISTCOUNTER));

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

188 p->cputime_count = &KCOUNT(p, PC_TO_I(p, cputime));
189 p->mcount_count = &KCOUNT(p, PC_TO_I(p, mcount));
190 p->mexitcount_count = &KCOUNT(p, PC_TO_I(p, mexitcount));
191
192 /*
193 * Disable interrupts to avoid interference while we calibrate
194 * things.
195 */
198 savecrit = critical_enter();
196 critical_enter();
199
200 /*
201 * Determine overheads.
202 * XXX this needs to be repeated for each useful timer/counter.
203 */
204 cputime_overhead = 0;
205 startguprof(p);
206 for (i = 0; i < CALIB_SCALE; i++)

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

244#else
245#error
246#endif
247 mexitcount_overhead = KCOUNT(p, PC_TO_I(p, tmp_addr));
248
249 p->state = GMON_PROF_OFF;
250 stopguprof(p);
251
197
198 /*
199 * Determine overheads.
200 * XXX this needs to be repeated for each useful timer/counter.
201 */
202 cputime_overhead = 0;
203 startguprof(p);
204 for (i = 0; i < CALIB_SCALE; i++)

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

242#else
243#error
244#endif
245 mexitcount_overhead = KCOUNT(p, PC_TO_I(p, tmp_addr));
246
247 p->state = GMON_PROF_OFF;
248 stopguprof(p);
249
252 critical_exit(savecrit);
250 critical_exit();
253
254 nullfunc_loop_profiled_time = 0;
255 for (tmp_addr = (uintfptr_t)nullfunc_loop_profiled;
256 tmp_addr < (uintfptr_t)nullfunc_loop_profiled_end;
257 tmp_addr += HISTFRACTION * sizeof(HISTCOUNTER))
258 nullfunc_loop_profiled_time += KCOUNT(p, PC_TO_I(p, tmp_addr));
259#define CALIB_DOSCALE(count) (((count) + CALIB_SCALE / 3) / CALIB_SCALE)
260#define c2n(count, freq) ((int)((count) * 1000000000LL / freq))

--- 274 unchanged lines hidden ---
251
252 nullfunc_loop_profiled_time = 0;
253 for (tmp_addr = (uintfptr_t)nullfunc_loop_profiled;
254 tmp_addr < (uintfptr_t)nullfunc_loop_profiled_end;
255 tmp_addr += HISTFRACTION * sizeof(HISTCOUNTER))
256 nullfunc_loop_profiled_time += KCOUNT(p, PC_TO_I(p, tmp_addr));
257#define CALIB_DOSCALE(count) (((count) + CALIB_SCALE / 3) / CALIB_SCALE)
258#define c2n(count, freq) ((int)((count) * 1000000000LL / freq))

--- 274 unchanged lines hidden ---