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