154
155 dtrace_probe(prof->prof_id, CPU->cpu_profile_pc,
156 CPU->cpu_profile_upc, 0, 0, 0);
157 }
158
159 static void
160 profile_create(hrtime_t interval, const char *name, int kind)
161 {
162 profile_probe_t *prof;
163 int nr_frames = PROF_ARTIFICIAL_FRAMES + dtrace_mach_aframes();
164
165 if (profile_aframes)
166 nr_frames = profile_aframes;
167
168 if (interval < profile_interval_min)
169 return;
170
171 if (dtrace_probe_lookup(profile_id, NULL, NULL, name) != 0)
172 return;
173
174 atomic_add_32(&profile_total, 1);
175 if (profile_total > profile_max) {
176 atomic_add_32(&profile_total, -1);
177 return;
178 }
179
180 prof = kmem_zalloc(sizeof (profile_probe_t), KM_SLEEP);
181 (void) strcpy(prof->prof_name, name);
182 prof->prof_interval = interval;
183 prof->prof_cyclic = CYCLIC_NONE;
184 prof->prof_kind = kind;
185 prof->prof_id = dtrace_probe_create(profile_id,
186 NULL, NULL, name, nr_frames, prof);
187 }
188
189 /*ARGSUSED*/
190 static void
191 profile_provide(void *arg, const dtrace_probedesc_t *desc)
192 {
193 int i, j, rate, kind;
194 hrtime_t val = 0, mult = 1, len;
195 const char *name, *suffix = NULL;
196
311 * The default is frequency-per-second.
312 */
313 val = NANOSEC / val;
314 } else {
315 val *= mult;
316 }
317
318 profile_create(val, name, kind);
319 }
320
321 /*ARGSUSED*/
322 static void
323 profile_destroy(void *arg, dtrace_id_t id, void *parg)
324 {
325 profile_probe_t *prof = parg;
326
327 ASSERT(prof->prof_cyclic == CYCLIC_NONE);
328 kmem_free(prof, sizeof (profile_probe_t));
329
330 ASSERT(profile_total >= 1);
331 atomic_add_32(&profile_total, -1);
332 }
333
334 /*ARGSUSED*/
335 static void
336 profile_online(void *arg, cpu_t *cpu, cyc_handler_t *hdlr, cyc_time_t *when)
337 {
338 profile_probe_t *prof = arg;
339 profile_probe_percpu_t *pcpu;
340
341 pcpu = kmem_zalloc(sizeof (profile_probe_percpu_t), KM_SLEEP);
342 pcpu->profc_probe = prof;
343
344 hdlr->cyh_func = profile_fire;
345 hdlr->cyh_arg = pcpu;
346 hdlr->cyh_level = CY_HIGH_LEVEL;
347
348 when->cyt_interval = prof->prof_interval;
349 when->cyt_when = dtrace_gethrtime() + when->cyt_interval;
350
351 pcpu->profc_expected = when->cyt_when;
|
154
155 dtrace_probe(prof->prof_id, CPU->cpu_profile_pc,
156 CPU->cpu_profile_upc, 0, 0, 0);
157 }
158
159 static void
160 profile_create(hrtime_t interval, const char *name, int kind)
161 {
162 profile_probe_t *prof;
163 int nr_frames = PROF_ARTIFICIAL_FRAMES + dtrace_mach_aframes();
164
165 if (profile_aframes)
166 nr_frames = profile_aframes;
167
168 if (interval < profile_interval_min)
169 return;
170
171 if (dtrace_probe_lookup(profile_id, NULL, NULL, name) != 0)
172 return;
173
174 atomic_inc_32(&profile_total);
175 if (profile_total > profile_max) {
176 atomic_dec_32(&profile_total);
177 return;
178 }
179
180 prof = kmem_zalloc(sizeof (profile_probe_t), KM_SLEEP);
181 (void) strcpy(prof->prof_name, name);
182 prof->prof_interval = interval;
183 prof->prof_cyclic = CYCLIC_NONE;
184 prof->prof_kind = kind;
185 prof->prof_id = dtrace_probe_create(profile_id,
186 NULL, NULL, name, nr_frames, prof);
187 }
188
189 /*ARGSUSED*/
190 static void
191 profile_provide(void *arg, const dtrace_probedesc_t *desc)
192 {
193 int i, j, rate, kind;
194 hrtime_t val = 0, mult = 1, len;
195 const char *name, *suffix = NULL;
196
311 * The default is frequency-per-second.
312 */
313 val = NANOSEC / val;
314 } else {
315 val *= mult;
316 }
317
318 profile_create(val, name, kind);
319 }
320
321 /*ARGSUSED*/
322 static void
323 profile_destroy(void *arg, dtrace_id_t id, void *parg)
324 {
325 profile_probe_t *prof = parg;
326
327 ASSERT(prof->prof_cyclic == CYCLIC_NONE);
328 kmem_free(prof, sizeof (profile_probe_t));
329
330 ASSERT(profile_total >= 1);
331 atomic_dec_32(&profile_total);
332 }
333
334 /*ARGSUSED*/
335 static void
336 profile_online(void *arg, cpu_t *cpu, cyc_handler_t *hdlr, cyc_time_t *when)
337 {
338 profile_probe_t *prof = arg;
339 profile_probe_percpu_t *pcpu;
340
341 pcpu = kmem_zalloc(sizeof (profile_probe_percpu_t), KM_SLEEP);
342 pcpu->profc_probe = prof;
343
344 hdlr->cyh_func = profile_fire;
345 hdlr->cyh_arg = pcpu;
346 hdlr->cyh_level = CY_HIGH_LEVEL;
347
348 when->cyt_interval = prof->prof_interval;
349 when->cyt_when = dtrace_gethrtime() + when->cyt_interval;
350
351 pcpu->profc_expected = when->cyt_when;
|