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