diff options
Diffstat (limited to 'sys/arch/amd64')
-rw-r--r-- | sys/arch/amd64/amd64/mp.c | 18 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/proc_machdep.c | 5 |
2 files changed, 23 insertions, 0 deletions
diff --git a/sys/arch/amd64/amd64/mp.c b/sys/arch/amd64/amd64/mp.c index dbee32c..21881b2 100644 --- a/sys/arch/amd64/amd64/mp.c +++ b/sys/arch/amd64/amd64/mp.c @@ -81,6 +81,24 @@ cpu_get(uint32_t index) return ci_list[index]; } +/* + * Grab the CPU stat structured of a specified + * processor + * + * @cpu_index: CPU index number + */ +struct sched_cpu * +cpu_get_stat(uint32_t cpu_index) +{ + struct cpu_info *ci; + + if ((ci = cpu_get(cpu_index)) == NULL) { + return NULL; + } + + return &ci->stat; +} + uint32_t cpu_count(void) { diff --git a/sys/arch/amd64/amd64/proc_machdep.c b/sys/arch/amd64/amd64/proc_machdep.c index 72c2b56..ad807fe 100644 --- a/sys/arch/amd64/amd64/proc_machdep.c +++ b/sys/arch/amd64/amd64/proc_machdep.c @@ -245,6 +245,7 @@ static void sched_switch_to(struct trapframe *tf, struct proc *td) { struct cpu_info *ci; + struct sched_cpu *cpustat; struct pcb *pcbp; ci = this_cpu(); @@ -253,6 +254,10 @@ sched_switch_to(struct trapframe *tf, struct proc *td) memcpy(tf, &td->tf, sizeof(*tf)); } + /* Update stats */ + cpustat = &ci->stat; + cpustat->nswitch++; + ci->curtd = td; pcbp = &td->pcb; pmap_switch_vas(pcbp->addrsp); |