Add a uwq member to cpu and only write to it when necessary

上级 e38988a8
......@@ -7,6 +7,8 @@ using std::atomic;
extern atomic<u64> tlbflush_req;
class uwq;
// Per-CPU state
struct cpu {
cpuid_t id; // Index into cpus[] below
......@@ -20,6 +22,7 @@ struct cpu {
atomic<u64> tlbflush_done; // last tlb flush req done on this cpu
struct proc *prev; // The previously-running process
uwq* uwq __mpalign__; // Current userspace wq (might be nullptr)
hwid_t hwid __mpalign__; // Local APIC ID, accessed by other CPUs
// Cpu-local storage variables; see below
......
......@@ -291,6 +291,9 @@ sched(void)
mycpu()->proc = next;
mycpu()->prev = prev;
if (mycpu()->uwq != nullptr || next->uwq != nullptr)
mycpu()->uwq = next->uwq;
if (prev->get_state() == ZOMBIE)
mtstop(prev);
else
......
......@@ -31,14 +31,11 @@ uwq_trywork(void)
continue;
struct cpu *c = &cpus[j];
// The gc_epoch is for p and uwq
// The gc_epoch is for uwq
scoped_gc_epoch xgc();
barrier();
struct proc *p = c->proc;
if (p == nullptr)
continue;
uwq* uwq = p->uwq;
uwq* uwq = c->uwq;
if (uwq == nullptr)
continue;
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论