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