提交 be61fd64 创建 作者: Nickolai Zeldovich's avatar Nickolai Zeldovich

use TLS mycpu() instead of the more expensive LAPIC-based cpunum()

上级 b979d25a
......@@ -83,7 +83,7 @@ sampstart(void)
{
pushcli();
for(struct cpu *c = cpus; c < cpus+ncpu; c++) {
if(c == cpus+cpunum())
if(c == cpus+mycpu()->id)
continue;
lapic_sampconf(c->id);
}
......@@ -95,7 +95,7 @@ static int
samplog(struct trapframe *tf)
{
struct pmulog *l;
l = &pmulog[cpunum()];
l = &pmulog[mycpu()->id];
if (l->count == l->capacity)
return 0;
......
......@@ -60,7 +60,7 @@ steal(void)
pushcli();
for (i = 1; i < ncpu; i++) {
struct runq *q = &runq[(i+cpunum()) % ncpu];
struct runq *q = &runq[(i+mycpu()->id) % ncpu];
struct proc *p;
// XXX(sbw) Look for a process to steal. Acquiring q->lock
......@@ -109,7 +109,7 @@ schednext(void)
struct proc *p = NULL;
pushcli();
q = &runq[cpunum()];
q = &runq[mycpu()->id];
acquire(&q->lock);
p = STAILQ_LAST(&q->q, proc, runqlink);
if (p) {
......
......@@ -17,7 +17,7 @@ static int lockstat_enable;
static inline struct cpulockstat *
mylockstat(struct spinlock *lk)
{
return &lk->stat->s.cpu[cpunum()];
return &lk->stat->s.cpu[mycpu()->id];
}
void*
......
......@@ -31,7 +31,7 @@ static inline struct wqueue *
getwq(void)
{
pushcli();
return &queue[cpunum()];
return &queue[mycpu()->id];
}
static inline void
......@@ -43,7 +43,7 @@ putwq(struct wqueue *wq)
static inline struct wqstat *
wq_stat(void)
{
return &stat[cpunum()];
return &stat[mycpu()->id];
}
struct work *
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论