提交 cd61c6de 创建 作者: Robert Morris's avatar Robert Morris

Merge branch 'scale' of git+ssh://pdos.csail.mit.edu/home/am0/6.828/xv6 into scale

...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "proc.h" #include "proc.h"
#include "xv6-mtrace.h" #include "xv6-mtrace.h"
struct ptable ptables[NCPU];
struct runq runqs[NCPU]; struct runq runqs[NCPU];
int idle[NCPU]; int idle[NCPU];
static struct proc *initproc; static struct proc *initproc;
...@@ -28,13 +27,7 @@ pinit(void) ...@@ -28,13 +27,7 @@ pinit(void)
panic("pinit"); panic("pinit");
for (c = 0; c < NCPU; c++) { for (c = 0; c < NCPU; c++) {
idle[c] = 1; idle[c] = 1;
ptables[c].nextpid = (c << 16) | (1);
ptables[c].name[0] = (char) (c + '0');
safestrcpy(ptables[c].name+1, "ptable", MAXNAME-1);
initlock(&ptables[c].lock, ptables[c].name);
runqs[c].name[0] = (char) (c + '0'); runqs[c].name[0] = (char) (c + '0');
safestrcpy(runqs[c].name+1, "runq", MAXNAME-1); safestrcpy(runqs[c].name+1, "runq", MAXNAME-1);
initlock(&runqs[c].lock, runqs[c].name); initlock(&runqs[c].lock, runqs[c].name);
...@@ -61,7 +54,6 @@ allocproc(void) ...@@ -61,7 +54,6 @@ allocproc(void)
initcondvar(&p->cv, "proc"); initcondvar(&p->cv, "proc");
p->state = EMBRYO; p->state = EMBRYO;
// p->pid = ptable->nextpid++;
p->pid = ns_allockey(nspid); p->pid = ns_allockey(nspid);
if (ns_insert(nspid, p->pid, (void *) p) < 0) if (ns_insert(nspid, p->pid, (void *) p) < 0)
panic("allocproc: ns_insert"); panic("allocproc: ns_insert");
...@@ -487,9 +479,7 @@ scheduler(void) ...@@ -487,9 +479,7 @@ scheduler(void)
struct proc *p; struct proc *p;
int pid; int pid;
acquire(&ptable->lock); pid = ns_allockey(nspid);
pid = ptable->nextpid++;
release(&ptable->lock);
// Enabling mtrace calls in scheduler generates many mtrace_call_entrys. // Enabling mtrace calls in scheduler generates many mtrace_call_entrys.
// mtrace_call_set(1, cpunum()); // mtrace_call_set(1, cpunum());
......
...@@ -37,7 +37,6 @@ struct vmnode { ...@@ -37,7 +37,6 @@ struct vmnode {
uint npages; uint npages;
char *page[128]; char *page[128];
uint ref; uint ref;
uint alloc; // in use?
enum vmntype type; enum vmntype type;
struct inode *ip; struct inode *ip;
uint offset; uint offset;
...@@ -110,7 +109,6 @@ struct cpu { ...@@ -110,7 +109,6 @@ struct cpu {
// Cpu-local storage variables; see below // Cpu-local storage variables; see below
struct cpu *cpu; struct cpu *cpu;
struct proc *proc; // The currently-running process. struct proc *proc; // The currently-running process.
struct ptable *ptable; // The per-core proc table
struct kmem *kmem; // The per-core memory table struct kmem *kmem; // The per-core memory table
struct runq *runq; // The per-core runq struct runq *runq; // The per-core runq
}; };
...@@ -121,20 +119,12 @@ struct runq { ...@@ -121,20 +119,12 @@ struct runq {
STAILQ_HEAD(runlist, proc) runq; STAILQ_HEAD(runlist, proc) runq;
}; };
struct ptable {
char name[MAXNAME];
struct spinlock lock;
struct proc *runq;
int nextpid;
};
struct condtab { struct condtab {
char name[MAXNAME]; char name[MAXNAME];
struct spinlock lock; struct spinlock lock;
struct condvar condtab[NPROC]; struct condvar condtab[NPROC];
}; };
extern struct ptable ptables[NCPU];
extern struct cpu cpus[NCPU]; extern struct cpu cpus[NCPU];
extern struct runq runqs[NCPU]; extern struct runq runqs[NCPU];
extern struct condtab condtabs[NCPU]; extern struct condtab condtabs[NCPU];
...@@ -150,6 +140,5 @@ extern int ncpu; ...@@ -150,6 +140,5 @@ extern int ncpu;
// in thread libraries such as Linux pthreads. // in thread libraries such as Linux pthreads.
extern struct cpu *cpu __asm("%gs:0"); // &cpus[cpunum()] extern struct cpu *cpu __asm("%gs:0"); // &cpus[cpunum()]
extern struct proc *proc __asm("%gs:4"); // cpus[cpunum()].proc extern struct proc *proc __asm("%gs:4"); // cpus[cpunum()].proc
extern struct ptable *ptable __asm("%gs:8"); // &ptables[cpunum()] extern struct kmem *kmem __asm("%gs:8"); // &kmems[cpunum()]
extern struct kmem *kmem __asm("%gs:12"); // &kmems[cpunum()] extern struct runq *runq __asm("%gs:12"); // &runqs[cpunum()]
extern struct runq *runq __asm("%gs:16"); // &runqs[cpunum()]
...@@ -31,8 +31,8 @@ seginit(void) ...@@ -31,8 +31,8 @@ seginit(void)
c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER);
c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER); c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER);
// Map cpu, curproc, ptable, kmem, runq // Map cpu, curproc, kmem, runq
c->gdt[SEG_KCPU] = SEG(STA_W, &c->cpu, 20, 0); c->gdt[SEG_KCPU] = SEG(STA_W, &c->cpu, 16, 0);
lgdt(c->gdt, sizeof(c->gdt)); lgdt(c->gdt, sizeof(c->gdt));
loadgs(SEG_KCPU << 3); loadgs(SEG_KCPU << 3);
...@@ -40,7 +40,6 @@ seginit(void) ...@@ -40,7 +40,6 @@ seginit(void)
// Initialize cpu-local storage. // Initialize cpu-local storage.
cpu = c; cpu = c;
proc = 0; proc = 0;
ptable = &ptables[cpunum()];
kmem = &kmems[cpunum()]; kmem = &kmems[cpunum()];
runq = &runqs[cpunum()]; runq = &runqs[cpunum()];
} }
...@@ -259,9 +258,9 @@ struct { ...@@ -259,9 +258,9 @@ struct {
struct vmnode * struct vmnode *
vmn_alloc(uint npg, uint type) vmn_alloc(uint npg, uint type)
{ {
for(uint i = 0; i < NELEM(vmnodes.n); i++) { struct vmnode *n = kmalloc(sizeof(struct vmnode));
struct vmnode *n = &vmnodes.n[i]; if (n == 0)
if(n->alloc == 0 && __sync_bool_compare_and_swap(&n->alloc, 0, 1)) { panic("out of vmnodes");
if(npg > NELEM(n->page)) { if(npg > NELEM(n->page)) {
panic("vmnode too big\n"); panic("vmnode too big\n");
} }
...@@ -272,9 +271,6 @@ vmn_alloc(uint npg, uint type) ...@@ -272,9 +271,6 @@ vmn_alloc(uint npg, uint type)
n->ip = 0; n->ip = 0;
n->type = type; n->type = type;
return n; return n;
}
}
panic("out of vmnodes");
} }
static int static int
...@@ -311,7 +307,7 @@ vmn_free(struct vmnode *n) ...@@ -311,7 +307,7 @@ vmn_free(struct vmnode *n)
if (n->ip) if (n->ip)
iput(n->ip); iput(n->ip);
n->ip = 0; n->ip = 0;
n->alloc = 0; kmfree(n);
} }
void void
...@@ -449,8 +445,7 @@ vmap_remove(struct vmap *m, uint va_start, uint len) ...@@ -449,8 +445,7 @@ vmap_remove(struct vmap *m, uint va_start, uint len)
cprintf("vmap_remove: partial unmap unsupported\n"); cprintf("vmap_remove: partial unmap unsupported\n");
return -1; return -1;
} }
vmn_decref(m->e[i].n);
__sync_fetch_and_sub(&m->e[i].n->ref, 1); // XXX shouldn't use vmn_decref?
m->e[i].n = 0; m->e[i].n = 0;
} }
} }
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论