Add highest priority wq to the kernel.

The critical wq allows pushing to remote cores and cores never steal from the critical wq.
上级 828175bd
......@@ -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);
......@@ -84,6 +83,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;
......
......@@ -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");
......
......@@ -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");
}
......@@ -7,8 +7,6 @@
#endif
#include "wq.hh"
enum { wq_steal_others = 1 };
//
// wq
//
......@@ -112,9 +110,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;
......@@ -137,7 +132,7 @@ wq::steal(int c)
}
int
wq::trywork(void)
wq::trywork(bool dosteal)
{
work *w;
u64 i, k;
......@@ -151,6 +146,9 @@ wq::trywork(void)
return 1;
}
if (!dosteal)
return 0;
for (i = 0; i < NCPU; i++) {
u64 j = (i+k) % NCPU;
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论