39#include <sys/sysproto.h>
40#include <sys/kernel.h>
44#include <sys/resourcevar.h>
45#include <sys/sysctl.h>
47#include <machine/cpu.h>
55#ifndef _SYS_SYSPROTO_H_
70 if (uap->
scale > (1 << 16))
74 if (uap->
scale == 0) {
81 upp = &td->td_proc->p_stats->p_prof;
84 upp->pr_scale = uap->
scale;
86 upp->pr_size = uap->
size;
99#define PC_TO_INDEX(pc, prof) \
100 ((int)(((u_quad_t)((pc) - (prof)->pr_off) * \
101 (u_quad_t)((prof)->pr_scale)) >> 16) & ~1)
122 prof = &td->td_proc->p_stats->p_prof;
123 PROC_PROFLOCK(td->td_proc);
124 if (pc < prof->pr_off ||
PC_TO_INDEX(pc, prof) >= prof->pr_size) {
125 PROC_PROFUNLOCK(td->td_proc);
129 PROC_PROFUNLOCK(td->td_proc);
130 td->td_profil_addr = pc;
131 td->td_profil_ticks =
ticks;
132 td->td_pflags |= TDP_OWEUPC;
134 td->td_flags |= TDF_ASTPENDING;
145 struct proc *p = td->td_proc;
156 if (!(p->p_flag & P_PROFIL)) {
161 prof = &p->p_stats->p_prof;
163 if (pc < prof->pr_off ||
169 addr = prof->pr_base + i;
172 if (copyin(
addr, &v,
sizeof(v)) == 0) {
174 if (copyout(&v,
addr,
sizeof(v)) == 0) {
183 if (--p->p_profthreads == 0) {
184 if (p->p_flag & P_STOPPROF) {
185 wakeup(&p->p_profthreads);
186 p->p_flag &= ~P_STOPPROF;
void stopprofclock(struct proc *p)
void startprofclock(struct proc *p)
void wakeup(const void *ident)
int sys_profil(struct thread *td, struct profil_args *uap)
void addupc_intr(struct thread *td, uintfptr_t pc, u_int ticks)
void addupc_task(struct thread *td, uintfptr_t pc, u_int ticks)
#define PC_TO_INDEX(pc, prof)