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

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

......@@ -8,7 +8,6 @@ class work;
int wq_trywork(void);
int wq_push(work *w);
int wq_pushto(work *w, int tcpuid);
void wq_dump(void);
size_t wq_size(void);
void initwq(void);
......@@ -48,7 +47,7 @@ class wq {
public:
wq();
int push(work *w, int tcpuid);
int trywork();
int trywork(bool steal = true);
void dump();
static void* operator new(unsigned long);
......@@ -85,6 +84,10 @@ private:
void* xallocwork(unsigned long nbytes);
void xfreework(void* ptr, unsigned long nbytes);
#if defined(XV6_KERNEL)
int wqcrit_push(work* w, int c);
#endif
#if defined(XV6_USER)
void* wqalloc(unsigned long nbytes);
void wqfree(void *ptr);
......
......@@ -248,7 +248,7 @@ exec(const char *path, char **argv, void *ascopev)
w->rip = (void*) exec_cleanup;
w->arg0 = oldvmap;
w->arg1 = olduwq;
assert(wq_pushto(w, myproc()->exec_cpuid_) >= 0);
assert(wqcrit_push(w, myproc()->exec_cpuid_) >= 0);
gc_end_epoch();
return 0;
......
......@@ -287,7 +287,7 @@ initkalloc(u64 mbaddr)
strncpy(slabmem[slab_wq][c].name, " wq", MAXNAME);
slabmem[slab_wq][c].size = PGROUNDUP(wq_size());
slabmem[slab_wq][c].ninit = NCPU;
slabmem[slab_wq][c].ninit = 2;
strncpy(slabmem[slab_userwq][c].name, " uwq", MAXNAME);
slabmem[slab_userwq][c].size = USERWQSIZE;
......@@ -315,7 +315,6 @@ initkalloc(u64 mbaddr)
void
kfree(void *v)
{
verifyfree((char*) v, mykmem()->size);
kfree_pool(mykmem(), (char*) v);
}
......@@ -324,22 +323,3 @@ ksfree(int slab, void *v)
{
kfree_pool(slabmem[slab], (char*) v);
}
void
verifyfree(char *ptr, u64 nbytes)
{
#if VERIFYFREE
char *p = ptr;
char *e = p + nbytes;
for (; p < e; p++) {
// Search for pointers in the ptr region
u64 x = *(uptr *)p;
if ((KBASE < x && x < KBASE+(128ull<<30)) || (KCODE < x)) {
struct klockstat *kls = (struct klockstat *) x;
if (kls->magic == LOCKSTAT_MAGIC)
panic("LOCKSTAT_MAGIC %p(%lu):%p->%p",
ptr, nbytes, p, kls);
}
}
#endif
}
......@@ -117,7 +117,6 @@ kmfree(void *ap, u64 nbytes)
int b = bucket(nbytes);
struct header *h = (struct header *) ap;
verifyfree((char *) ap, (1<<b));
if (ALLOC_MEMSET)
memset(ap, 3, (1<<b));
......
......@@ -443,7 +443,7 @@ wait(void)
assert(w);
w->rip = (void*) finishproc;
w->arg0 = p;
assert(wq_pushto(w, p->run_cpuid_) >= 0);
assert(wqcrit_push(w, p->run_cpuid_) >= 0);
if (!xnspid->remove(pid, &p))
panic("wait: ns_remove");
......
......@@ -142,7 +142,9 @@ uwq::uwq(vmap* vmap, filetable* ftable, uwq_ipcbuf* ipc)
ipc_->len[i].v_ = 0;
initlock(&lock_, "uwq_lock", 0);
memset(worker_, 0, sizeof(worker_));
for (int i = 0; i < NWORKERS; i++)
worker_[i].store(nullptr);
}
uwq::~uwq(void)
......
......@@ -7,6 +7,7 @@
#include "wq.hh"
static wq *wq_;
static wq *wqcrit_;
void*
xallocwork(unsigned long nbytes)
......@@ -33,15 +34,15 @@ wq_push(work *w)
}
int
wq_pushto(work *w, int tcpuid)
wqcrit_push(work *w, int c)
{
return wq_->push(w, tcpuid);
return wqcrit_->push(w, c);
}
int
wq_trywork(void)
{
return wq_->trywork();
return wqcrit_->trywork(false) || wq_->trywork(true);
}
void
......@@ -54,4 +55,7 @@ void
initwq(void)
{
wq_ = new wq();
wqcrit_ = new wq();
if (wq_ == nullptr || wqcrit_ == nullptr)
panic("initwq");
}
......@@ -50,3 +50,10 @@ wqfree(void *ptr)
b->next = *block;
*block = b;
}
void
wqallocinit(void)
{
for (int i = 0; i < NCPU; i++)
block[i] = nullptr;
}
......@@ -7,8 +7,6 @@
#endif
#include "wq.hh"
enum { wq_steal_others = 1 };
//
// wq
//
......@@ -118,9 +116,6 @@ wq::pop(int c)
inline work*
wq::steal(int c)
{
if (!wq_steal_others && (c != mycpuid()))
return 0;
struct wqueue *q = &q_[c];
work *w;
int i;
......@@ -143,7 +138,7 @@ wq::steal(int c)
}
int
wq::trywork(void)
wq::trywork(bool dosteal)
{
work *w;
u64 i, k;
......@@ -157,6 +152,9 @@ wq::trywork(void)
return 1;
}
if (!dosteal)
return 0;
for (i = 0; i < NCPU; i++) {
u64 j = (i+k) % NCPU;
......
......@@ -83,12 +83,16 @@ xfreework(void* ptr, unsigned long nbytes)
void
initwq(void)
{
extern void wqallocinit(void);
if (pthread_key_create(&idkey, 0))
die("wqarch_init: pthread_key_create");
int id = nextid++;
pthread_setspecific(idkey, (void*)(u64)id);
wqallocinit();
wq_ = new wq();
if (wq_ == nullptr)
die("initwq");
......
#pragma once
#define DEBUG 0
#define NPROC 64 // maximum number of processes
#define KSTACKSIZE 8192 // size of per-process kernel stack
#define NOFILE 64 // open files per process
......@@ -14,13 +13,11 @@
#define CACHELINE 64 // cache line size
#define CPUKSTACKS (NPROC + NCPU*2)
#define QUANTUM 10 // scheduling time quantum and tick length (in msec)
#define CILKSHIFT 4 // 2^WORKSHIFT work queue slots
#define VICTIMAGE 1000000 // cycles a proc executes before an eligible victim
#define VERBOSE 0 // print kernel diagnostics
#define SPINLOCK_DEBUG DEBUG // Debug spin locks
#define RCU_TYPE_DEBUG DEBUG
#define LOCKSTAT DEBUG
#define VERIFYFREE 0 // Unreliable, e.g. vma's vmnode pointer gets reused
#define ALLOC_MEMSET DEBUG
#define KSHAREDSIZE (32 << 10)
#define USERWQSIZE (1 << 14)
......@@ -28,29 +25,34 @@
#define WQSHIFT 7
#define CILKENABLE 0
#if defined(HW_qemu)
#define NCPU 8 // maximum number of CPUs
#define MTRACE 0
#define PERFSIZE (16<<20ull)
#define NCPU 8 // maximum number of CPUs
#define MTRACE 0
#define PERFSIZE (16<<20ull)
#elif defined(HW_josmp)
#define NCPU 16 // maximum number of CPUs
#define MTRACE 0
#define PERFSIZE (1<<20ull)
#define DEBUG 0
#define NCPU 16 // maximum number of CPUs
#define MTRACE 0
#define PERFSIZE (1<<20ull)
#elif defined(HW_ud0)
#define NCPU 4 // maximum number of CPUs
#define MTRACE 0
#define PERFSIZE (512<<20ull)
#define NCPU 4 // maximum number of CPUs
#define MTRACE 0
#define PERFSIZE (512<<20ull)
#elif defined(HW_tom)
#define NCPU 48 // maximum number of CPUs
#define MTRACE 0
#define PERFSIZE (1<<20ull)
#define NCPU 48 // maximum number of CPUs
#define MTRACE 0
#define PERFSIZE (1<<20ull)
#elif defined(HW_user)
#define NCPU 256
#define MTRACE 0
#define PERFSIZE (16<<20ull)
#define NCPU 256
#define MTRACE 0
#define PERFSIZE (16<<20ull)
#elif defined(HW_wq)
#define NCPU 2
#define MTRACE 0
#define PERFSIZE (16<<20ull)
#define NCPU 2
#define MTRACE 0
#define PERFSIZE (16<<20ull)
#else
#error "Unknown HW"
#endif
#ifndef DEBUG
#define DEBUG 1
#endif
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论