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

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

...@@ -81,7 +81,7 @@ int e1000tx(void *buf, u32 len); ...@@ -81,7 +81,7 @@ int e1000tx(void *buf, u32 len);
void e1000hwaddr(u8 *hwaddr); void e1000hwaddr(u8 *hwaddr);
// exec.c // exec.c
int exec(const char*, char**); int exec(const char*, char**, void* ascope);
// fs.c // fs.c
int namecmp(const char*, const char*); int namecmp(const char*, const char*);
......
...@@ -67,21 +67,43 @@ static inline void mtresume(struct proc *p) ...@@ -67,21 +67,43 @@ static inline void mtresume(struct proc *p)
class mt_ascope class mt_ascope
{ {
char name[64]; char name[64];
bool active;
public: public:
explicit mt_ascope(const char *fmt, ...) explicit mt_ascope(const char *fmt, ...)
{ {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
vsnprintf(name, sizeof(name) - 1, fmt, ap); vopen(fmt, ap);
va_end(ap);
}
~mt_ascope()
{
close();
}
void open(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vopen(fmt, ap);
va_end(ap); va_end(ap);
}
void vopen(const char *fmt, va_list ap)
{
vsnprintf(name, sizeof(name) - 1, fmt, ap);
mtrace_ascope_register(0, name); mtrace_ascope_register(0, name);
active = true;
} }
~mt_ascope() void close()
{ {
mtrace_ascope_register(1, name); if (active)
mtrace_ascope_register(1, name);
active = false;
} }
}; };
......
...@@ -80,6 +80,7 @@ struct proc : public rcu_freed { ...@@ -80,6 +80,7 @@ struct proc : public rcu_freed {
u64 user_fs_; u64 user_fs_;
u64 unmap_tlbreq_; u64 unmap_tlbreq_;
int exec_cpuid_; int exec_cpuid_;
int run_cpuid_;
int in_exec_; int in_exec_;
int uaccess_; int uaccess_;
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "cpu.hh" #include "cpu.hh"
#include "wq.hh" #include "wq.hh"
#include "sperf.hh" #include "sperf.hh"
#include "kmtrace.hh"
#define BRK (USERTOP >> 1) #define BRK (USERTOP >> 1)
...@@ -149,7 +150,7 @@ exec_cleanup(vmap *oldvmap, uwq *olduwq) ...@@ -149,7 +150,7 @@ exec_cleanup(vmap *oldvmap, uwq *olduwq)
} }
int int
exec(const char *path, char **argv) exec(const char *path, char **argv, void *ascopev)
{ {
ANON_REGION(__func__, &perfgroup); ANON_REGION(__func__, &perfgroup);
struct inode *ip = nullptr; struct inode *ip = nullptr;
...@@ -167,10 +168,15 @@ exec(const char *path, char **argv) ...@@ -167,10 +168,15 @@ exec(const char *path, char **argv)
myproc()->exec_cpuid_ = mycpuid(); myproc()->exec_cpuid_ = mycpuid();
mt_ascope *ascope = (mt_ascope*) ascopev;
ascope->close();
myproc()->in_exec_ = 1; myproc()->in_exec_ = 1;
yield(); yield();
myproc()->in_exec_ = 0; myproc()->in_exec_ = 0;
ascope->open("sys_exec2(%s)", path);
myproc()->run_cpuid_ = mycpuid();
if((ip = namei(myproc()->cwd, path)) == 0) if((ip = namei(myproc()->cwd, path)) == 0)
return -1; return -1;
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "vm.hh" #include "vm.hh"
#include "ns.hh" #include "ns.hh"
#include "fcntl.h" #include "fcntl.h"
#include "wq.hh"
u64 u64
proc_hash(const u32 &p) proc_hash(const u32 &p)
...@@ -368,6 +369,8 @@ fork(int flags) ...@@ -368,6 +369,8 @@ fork(int flags)
np->parent = myproc(); np->parent = myproc();
*np->tf = *myproc()->tf; *np->tf = *myproc()->tf;
np->cpu_pin = myproc()->cpu_pin; np->cpu_pin = myproc()->cpu_pin;
np->exec_cpuid_ = myproc()->exec_cpuid_;
np->run_cpuid_ = myproc()->run_cpuid_;
// Clear %eax so that fork returns 0 in the child. // Clear %eax so that fork returns 0 in the child.
np->tf->rax = 0; np->tf->rax = 0;
...@@ -408,8 +411,6 @@ finishproc(struct proc *p) ...@@ -408,8 +411,6 @@ finishproc(struct proc *p)
p->uwq->dec(); p->uwq->dec();
ksfree(slab_stack, p->kstack); ksfree(slab_stack, p->kstack);
p->kstack = 0; p->kstack = 0;
if (!xnspid->remove(p->pid, &p))
panic("wait: ns_remove");
p->pid = 0; p->pid = 0;
p->parent = 0; p->parent = 0;
p->name[0] = 0; p->name[0] = 0;
...@@ -437,7 +438,16 @@ wait(void) ...@@ -437,7 +438,16 @@ wait(void)
pid = p->pid; pid = p->pid;
SLIST_REMOVE(&myproc()->childq, p, proc, child_next); SLIST_REMOVE(&myproc()->childq, p, proc, child_next);
release(&myproc()->lock); release(&myproc()->lock);
finishproc(p);
cwork *w = new cwork();
assert(w);
w->rip = (void*) finishproc;
w->arg0 = p;
assert(wq_pushto(w, p->run_cpuid_) >= 0);
if (!xnspid->remove(pid, &p))
panic("wait: ns_remove");
return pid; return pid;
} }
release(&p->lock); release(&p->lock);
......
...@@ -449,7 +449,7 @@ sys_exec(const char *upath, u64 uargv) ...@@ -449,7 +449,7 @@ sys_exec(const char *upath, u64 uargv)
goto clean; goto clean;
} }
argv[i] = 0; argv[i] = 0;
r = exec(path, argv); r = exec(path, argv, &ascope);
clean: clean:
for (i=i-i; i >= 0; i--) for (i=i-i; i >= 0; i--)
kmfree(argv[i], len); kmfree(argv[i], len);
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#define NSLOTS (1 << WQSHIFT) #define NSLOTS (1 << WQSHIFT)
enum { wq_steal_others = 1 };
class wq { class wq {
public: public:
wq(); wq();
...@@ -187,6 +189,9 @@ wq::pop(int c) ...@@ -187,6 +189,9 @@ wq::pop(int c)
inline work* inline work*
wq::steal(int c) wq::steal(int c)
{ {
if (!wq_steal_others && (c != mycpuid()))
return 0;
struct wqueue *q = &q_[c]; struct wqueue *q = &q_[c];
work *w; work *w;
int i; int i;
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论