| 139 | } |
| 140 | |
| 141 | static void |
| 142 | kmstartup(void *dummy) |
| 143 | { |
| 144 | char *cp; |
| 145 | struct gmonparam *p = &_gmonparam; |
| 146 | #ifdef GUPROF |
| 147 | int cputime_overhead; |
| 148 | int empty_loop_time; |
| 149 | int i; |
| 150 | int mcount_overhead; |
| 151 | int mexitcount_overhead; |
| 152 | int nullfunc_loop_overhead; |
| 153 | int nullfunc_loop_profiled_time; |
| 154 | uintfptr_t tmp_addr; |
| 155 | #endif |
| 156 | |
| 157 | /* |
| 158 | * Round lowpc and highpc to multiples of the density we're using |
| 159 | * so the rest of the scaling (here and in gprof) stays in ints. |
| 160 | */ |
| 161 | p->lowpc = ROUNDDOWN((u_long)btext, HISTFRACTION * sizeof(HISTCOUNTER)); |
| 162 | p->highpc = ROUNDUP((u_long)etext, HISTFRACTION * sizeof(HISTCOUNTER)); |
| 163 | p->textsize = p->highpc - p->lowpc; |
| 164 | printf("Profiling kernel, textsize=%lu [%jx..%jx]\n", |
| 165 | p->textsize, (uintmax_t)p->lowpc, (uintmax_t)p->highpc); |
| 166 | p->kcountsize = p->textsize / HISTFRACTION; |
| 167 | p->hashfraction = HASHFRACTION; |
| 168 | p->fromssize = p->textsize / HASHFRACTION; |
| 169 | p->tolimit = p->textsize * ARCDENSITY / 100; |
| 170 | if (p->tolimit < MINARCS) |
| 171 | p->tolimit = MINARCS; |
| 172 | else if (p->tolimit > MAXARCS) |
| 173 | p->tolimit = MAXARCS; |
| 174 | p->tossize = p->tolimit * sizeof(struct tostruct); |
| 175 | cp = (char *)malloc(p->kcountsize + p->fromssize + p->tossize, |
| 176 | M_GPROF, M_WAITOK | M_ZERO); |
| 177 | p->tos = (struct tostruct *)cp; |
| 178 | cp += p->tossize; |
| 179 | p->kcount = (HISTCOUNTER *)cp; |
| 180 | cp += p->kcountsize; |
| 181 | p->froms = (u_short *)cp; |
| 182 | p->histcounter_type = FUNCTION_ALIGNMENT / HISTFRACTION * NBBY; |
| 183 | |
| 184 | #ifdef GUPROF |
| 185 | /* Signed counters. */ |
| 186 | p->histcounter_type = -p->histcounter_type; |
| 187 | |
| 188 | /* Initialize pointers to overhead counters. */ |
| 189 | p->cputime_count = &KCOUNT(p, PC_TO_I(p, cputime)); |
| 190 | p->mcount_count = &KCOUNT(p, PC_TO_I(p, mcount)); |
| 191 | p->mexitcount_count = &KCOUNT(p, PC_TO_I(p, mexitcount)); |
| 192 | |
| 193 | /* |
| 194 | * Disable interrupts to avoid interference while we calibrate |
| 195 | * things. |
| 196 | */ |
| 197 | critical_enter(); |
| 198 |
nothing calls this directly
no test coverage detected