提交 0ee57d47 创建 作者: Silas Boyd-Wickizer's avatar Silas Boyd-Wickizer

Merge..i confused git somehow..

......@@ -72,4 +72,3 @@ enum {
};
extern percpu<kmem> kmems;
extern percpu<kmem> slabmem[slab_type_max];
......@@ -102,7 +102,7 @@ class xns : public rcu_freed {
e->next = root.load();
if (cmpxch(&table[i].chain, e->next.load(), e)) {
int c = mycpuid();
int c = myid();
acquire(&percore_lock[c]);
e->percore_c = c;
e->percore_next = percore[c].load();
......@@ -180,7 +180,7 @@ class xns : public rcu_freed {
template<class CB>
void enumerate(CB cb) {
scoped_gc_epoch gc;
int cpuoffset = mycpuid();
int cpuoffset = myid();
for (int i = 0; i < NCPU; i++) {
auto e = percore[(i + cpuoffset) % NCPU].load();
while (e) {
......
#pragma once
extern int mycpuid(void);
#include "cpu.hh"
template <typename T>
struct percpu {
......@@ -11,15 +11,15 @@ struct percpu {
percpu &operator=(const percpu &o) = delete;
T* get() const {
return cpu(mycpuid());
return cpu(myid());
}
T* operator->() const {
return cpu(mycpuid());
return cpu(myid());
}
T& operator*() const {
return *cpu(mycpuid());
return *cpu(myid());
}
T& operator[](int id) const {
......
......@@ -243,6 +243,8 @@ struct radix_iterator {
}
radix_elem* operator*() const {
// XXX(austin) If we don't hold a lock on this element, it's
// possible it will morph into a node under us.
return path_[level_]->load().elem();
}
......
......@@ -5,7 +5,6 @@
#include "uwq.hh"
#include "wqtypes.hh"
int mycpuid(void);
uwq_ipcbuf* allocipc(void);
static inline void*
......
......@@ -191,7 +191,7 @@ ialloc(u32 dev, short type)
struct superblock sb;
readsb(dev, &sb);
for (int k = mycpuid()*IPB; k < sb.ninodes; k += (NCPU*IPB)) {
for (int k = myid()*IPB; k < sb.ninodes; k += (NCPU*IPB)) {
for(int inum = k; inum < k+IPB && inum < sb.ninodes; inum++){
if (inum == 0)
continue;
......
......@@ -269,7 +269,4 @@ initfutex(void)
nsfutex = new xns<futexkey_t, futexaddr*, futexkey_hash>(false);
if (nsfutex == 0)
panic("initfutex");
for (int i = 0; i < NCPU; i++)
new (&nscache_[i]) nscache();
}
......@@ -150,8 +150,8 @@ initidle(void)
}
}
SLIST_INIT(&idlem[myid()].zombies);
initlock(&idlem[myid()].lock, "idle_lock", LOCKSTAT_IDLE);
SLIST_INIT(&idlem->zombies);
initlock(&idlem->lock, "idle_lock", LOCKSTAT_IDLE);
snprintf(p->name, sizeof(p->name), "idle_%u", myid());
mycpu()->proc = p;
......
......@@ -141,7 +141,7 @@ cmain(u64 mbmagic, u64 mbaddr)
initmp();
inittls(); // thread local storage
// Some global constructors require mycpu()->id (via mycpuid())
// Some global constructors require mycpu()->id (via myid())
// which we setup in inittls
extern const uptr sctors[], ectors[];
for (const uptr *ctorva = ectors; ctorva > sctors; ) {
......
......@@ -21,12 +21,6 @@ proc::hash(const u32 &p)
return p;
}
int
mycpuid(void)
{
return mycpu()->id;
}
xns<u32, proc*, proc::hash> *xnspid __mpalign__;
struct proc *bootproc __mpalign__;
......
......@@ -339,9 +339,6 @@ statread(struct inode *inode, char *dst, u32 off, u32 n)
void
initsched(void)
{
for (int i = 0; i < NCPU; i++)
new (&schedule_[i]) schedule();
devsw[MAJ_STAT].write = nullptr;
devsw[MAJ_STAT].read = statread;
}
......@@ -174,7 +174,7 @@ trap(struct trapframe *tf)
// In user space, assume process misbehaved.
uerr.println("pid ", myproc()->pid, ' ', myproc()->name,
": trap ", (u64)tf->trapno, " err ", (u32)tf->err,
" on cpu ", mycpuid(), " rip ", shex(tf->rip),
" on cpu ", myid(), " rip ", shex(tf->rip),
" rsp ", shex(tf->rsp), " addr ", shex(rcr2()),
"--kill proc");
myproc()->killed = 1;
......@@ -291,7 +291,8 @@ getcallerpcs(void *v, uptr pcs[], int n)
if(rbp == 0 || rbp < (uptr*)KBASE || rbp == (uptr*)(~0UL) ||
(rbp >= (uptr*)KBASEEND && rbp < (uptr*)KCODE))
break;
pcs[i] = rbp[1]; // saved %rip
pcs[i] = rbp[1] - 1; // saved %rip; - 1 so it points to the call
// instruction
rbp = (uptr*)rbp[0]; // saved %rbp
}
for(; i < n; i++)
......
......@@ -28,7 +28,7 @@ uwq_trywork(void)
for (i = 0; i < NCPU; i++) {
u64 j = (i+k) % NCPU;
if (j == mycpuid())
if (j == myid())
continue;
struct cpu *c = &cpus[j];
......@@ -199,7 +199,7 @@ uwq::tryworker(void)
proc* p = w->proc_;
acquire(&p->lock);
p->cpuid = mycpuid();
p->cpuid = myid();
release(&p->lock);
w->running_ = true;
......@@ -226,7 +226,7 @@ again:
w->running_ = true;
acquire(&p->lock);
p->cpuid = mycpuid();
p->cpuid = myid();
addrun(p);
release(&p->lock);
......
......@@ -270,9 +270,9 @@ vmap::replace_vma(vma *a, vma *b)
assert(a->vma_start == b->vma_start);
assert(a->vma_end == b->vma_end);
auto span = vmas.search_lock(a->vma_start, a->vma_end - a->vma_start);
#if VM_CRANGE
if (a->deleted())
return false;
#if VM_CRANGE
for (auto e: span)
assert(a == e);
span.replace(b);
......@@ -477,11 +477,6 @@ again:
updatepages(pml4, e->vma_start, e->vma_end, [&needtlb](atomic<pme_t> *p) {
for (;;) {
pme_t v = p->load();
// XXX(austin) Huh? Why is it okay to skip it if it's
// locked? The page fault could be faulting in a page from
// the old VMA, in which case we need to shoot it down
// (though if it's already faulting a page from the new VMA,
// we need to *not* shoot it down).
if (v & PTE_LOCK)
continue;
if (!(v & PTE_P))
......@@ -623,7 +618,12 @@ vmap::pagefault(uptr va, u32 err)
}
scoped_gc_epoch gc;
#if VM_CRANGE
vma *m = lookup(va, 1);
#elif VM_RADIX
auto vma_it = vmas.find(va);
vma *m = static_cast<vma*>(*vma_it);
#endif
if (m == 0)
return -1;
......@@ -664,10 +664,20 @@ vmap::pagefault(uptr va, u32 err)
if (!cmpxch(pte, ptev, ptev | PTE_LOCK))
goto retry;
#if VM_CRANGE
if (m->deleted()) {
*pte = ptev;
goto retry;
}
#elif VM_RADIX
// The radix tree is the source of truth about where the VMA is
// mapped. It might have been unmapped from this va but still be
// around, so we can't just test if it's deleted.
if (*vma_it != m) {
*pte = ptev;
goto retry;
}
#endif
if (m->va_type == COW) {
*pte = v2p(m->n->page[npg]) | PTE_P | PTE_U | PTE_COW;
......
......@@ -31,7 +31,7 @@ int
wq_push(work *w)
{
assert(wq_);
return wq_->push(w, mycpuid());
return wq_->push(w, myid());
}
void
......
......@@ -158,7 +158,7 @@ wq::trywork(bool dosteal)
// A "random" victim CPU
k = rdtsc();
w = pop(mycpuid());
w = pop(myid());
if (w != nullptr) {
w->run();
return 1;
......@@ -170,7 +170,7 @@ wq::trywork(bool dosteal)
for (i = 0; i < NCPU; i++) {
u64 j = (i+k) % NCPU;
if (j == mycpuid())
if (j == myid())
continue;
w = steal(j);
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论