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

close and re-open sys_exec() scope after migration

上级 c99d71b6
......@@ -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;
}
};
......
......@@ -14,6 +14,7 @@
#include "cpu.hh"
#include "wq.hh"
#include "cilk.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)
{
struct inode *ip = nullptr;
struct vmap *vmp = nullptr;
......@@ -166,10 +167,13 @@ 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);
if((ip = namei(myproc()->cwd, path)) == 0)
return -1;
......
......@@ -447,7 +447,7 @@ sys_exec(const char *upath, u64 uargv)
if(argcheckstr(argv[i]) < 0)
return -1;
}
return exec(path, argv);
return exec(path, argv, &ascope);
}
long
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论