提交 a64fdf99 创建 作者: Austin Clements's avatar Austin Clements

asharing: Annotate sharing in sys_map, sys_unmap, pagefault, and sys_openat

上级 9275cbb6
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "buf.hh" #include "buf.hh"
#include "file.hh" #include "file.hh"
#include "cpu.hh" #include "cpu.hh"
#include "kmtrace.hh"
#define min(a, b) ((a) < (b) ? (a) : (b)) #define min(a, b) ((a) < (b) ? (a) : (b))
static void itrunc(struct inode*); static void itrunc(struct inode*);
...@@ -757,6 +758,16 @@ namex(inode *cwd, const char *path, int nameiparent, char *name) ...@@ -757,6 +758,16 @@ namex(inode *cwd, const char *path, int nameiparent, char *name)
ip = idup(cwd); ip = idup(cwd);
while((r = skipelem(&path, name)) == 1){ while((r = skipelem(&path, name)) == 1){
// XXX Doing this here requires some annoying reasoning about all
// of the callers of namei/nameiparent. Also, since the abstract
// scope is implicit, it might be wrong (or non-existent) and
// documenting the abstract object sets of each scope becomes
// difficult and probably unmaintainable. We have to compute this
// information here because it's the only place that's canonical.
// Maybe this should return the set of inodes traversed and let
// the caller declare the variables? Would it help for the caller
// to pass in an abstract scope?
mtreadavar("inode:%x.%x", ip->dev, ip->inum);
next = 0; next = 0;
if(next == 0){ if(next == 0){
if(ip->type == 0) if(ip->type == 0)
...@@ -785,6 +796,7 @@ namex(inode *cwd, const char *path, int nameiparent, char *name) ...@@ -785,6 +796,7 @@ namex(inode *cwd, const char *path, int nameiparent, char *name)
gc_end_epoch(); gc_end_epoch();
return 0; return 0;
} }
mtreadavar("inode:%x.%x", ip->dev, ip->inum);
gc_end_epoch(); gc_end_epoch();
return ip; return ip;
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "fcntl.h" #include "fcntl.h"
#include "cpu.hh" #include "cpu.hh"
#include "net.hh" #include "net.hh"
#include "kmtrace.hh"
static bool static bool
getfile(int fd, sref<file> *f) getfile(int fd, sref<file> *f)
...@@ -280,6 +281,12 @@ sys_openat(int dirfd, const char *path, int omode) ...@@ -280,6 +281,12 @@ sys_openat(int dirfd, const char *path, int omode)
if(argcheckstr(path) < 0) if(argcheckstr(path) < 0)
return -1; return -1;
// Reads the dirfd FD, dirfd's inode, the inodes of all files in
// path; writes the returned FD
mt_ascope ascope("%s(%d,%s,%d)", __func__, dirfd, path, omode);
mtreadavar("inode:%x.%x", cwd->dev, cwd->inum);
if(omode & O_CREATE){ if(omode & O_CREATE){
if((ip = create(cwd, path, T_FILE, 0, 0)) == 0) if((ip = create(cwd, path, T_FILE, 0, 0)) == 0)
return -1; return -1;
...@@ -309,6 +316,7 @@ sys_openat(int dirfd, const char *path, int omode) ...@@ -309,6 +316,7 @@ sys_openat(int dirfd, const char *path, int omode)
return -1; return -1;
} }
iunlock(ip); iunlock(ip);
mtwriteavar("fd:%x.%x", myproc()->pid, fd);
f->type = file::FD_INODE; f->type = file::FD_INODE;
f->ip = ip; f->ip = ip;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "cpu.hh" #include "cpu.hh"
#include "vm.hh" #include "vm.hh"
#include "sperf.hh" #include "sperf.hh"
#include "kmtrace.hh"
long long
sys_fork(int flags) sys_fork(int flags)
...@@ -87,6 +88,12 @@ sys_map(uptr addr, u64 len) ...@@ -87,6 +88,12 @@ sys_map(uptr addr, u64 len)
{ {
ANON_REGION(__func__, &perfgroup); ANON_REGION(__func__, &perfgroup);
#if MTRACE
mt_ascope ascope("%s(%p,%lx)", __func__, addr, len);
for (uptr i = PGROUNDDOWN(addr); i < PGROUNDUP(addr + len); i += PGSIZE)
mtwriteavar("page:%016x", i);
#endif
vmnode *vmn = new vmnode(PGROUNDUP(len) / PGSIZE); vmnode *vmn = new vmnode(PGROUNDUP(len) / PGSIZE);
if (vmn == 0) if (vmn == 0)
return -1; return -1;
...@@ -104,6 +111,12 @@ sys_unmap(uptr addr, u64 len) ...@@ -104,6 +111,12 @@ sys_unmap(uptr addr, u64 len)
{ {
ANON_REGION(__func__, &perfgroup); ANON_REGION(__func__, &perfgroup);
#if MTRACE
mt_ascope ascope("%s(%p,%lx)", __func__, addr, len);
for (uptr i = PGROUNDDOWN(addr); i < PGROUNDUP(addr + len); i += PGSIZE)
mtwriteavar("page:%016x", i);
#endif
uptr align_addr = PGROUNDDOWN(addr); uptr align_addr = PGROUNDDOWN(addr);
uptr align_len = PGROUNDUP(addr + len) - align_addr; uptr align_len = PGROUNDUP(addr + len) - align_addr;
if (myproc()->vmap->remove(align_addr, align_len) < 0) if (myproc()->vmap->remove(align_addr, align_len) < 0)
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "crange.hh" #include "crange.hh"
#include "cpputil.hh" #include "cpputil.hh"
#include "sperf.hh" #include "sperf.hh"
#include "kmtrace.hh"
enum { vm_debug = 0 }; enum { vm_debug = 0 };
...@@ -555,6 +556,11 @@ vmap::pagefault(uptr va, u32 err) ...@@ -555,6 +556,11 @@ vmap::pagefault(uptr va, u32 err)
int int
pagefault(struct vmap *vmap, uptr va, u32 err) pagefault(struct vmap *vmap, uptr va, u32 err)
{ {
#if MTRACE
mt_ascope ascope("%s(%p)", __func__, va);
mtwriteavar("page:%016x", PGROUNDDOWN(va));
#endif
return vmap->pagefault(va, err); return vmap->pagefault(va, err);
} }
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论