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

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

...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
Q ?= @ Q ?= @
TOOLPREFIX ?= x86_64-jos-elf- TOOLPREFIX ?= x86_64-jos-elf-
QEMU ?= qemu-system-x86_64 QEMU ?= qemu-system-x86_64
QEMUSMP ?= 4 QEMUSMP ?= 8
QEMUSRC ?= ../mtrace QEMUSRC ?= ../mtrace
MTRACE ?= $(QEMU) MTRACE ?= $(QEMU)
HW ?= qemu HW ?= qemu
......
...@@ -3,12 +3,19 @@ ...@@ -3,12 +3,19 @@
#include "user.h" #include "user.h"
#include "lib.h" #include "lib.h"
#include "fcntl.h" #include "fcntl.h"
#include "wq.hh"
static int branch;
static void static void
dolevel(int fd, int branch, int depth) dolevel(int fd, int depth)
{ {
if (depth > 0) { if (depth > 0) {
for (int i = 0; i < branch; i++) { int it = 0;
wq_for_serial<int>(it,
[](int &it)->bool { return it < branch; },
[&fd, &depth](int i)->void
{
char name[] = "a"; char name[] = "a";
*name += i; *name += i;
if (mkdirat(fd, name) < 0) if (mkdirat(fd, name) < 0)
...@@ -16,9 +23,9 @@ dolevel(int fd, int branch, int depth) ...@@ -16,9 +23,9 @@ dolevel(int fd, int branch, int depth)
int nfd = openat(fd, name, O_RDONLY); int nfd = openat(fd, name, O_RDONLY);
if (nfd < 0) if (nfd < 0)
die("openat"); die("openat: %s at %u", name, depth);
dolevel(nfd, branch, depth-1); dolevel(nfd, depth-1);
} });
} }
close(fd); close(fd);
...@@ -30,8 +37,10 @@ main(int ac, char **av) ...@@ -30,8 +37,10 @@ main(int ac, char **av)
if (ac < 4) if (ac < 4)
die("usage: %s dir branch depth", av[0]); die("usage: %s dir branch depth", av[0]);
initwq();
const char *dir = av[1]; const char *dir = av[1];
int branch = atoi(av[2]); branch = atoi(av[2]);
int depth = atoi(av[3]); int depth = atoi(av[3]);
if (mkdir(dir)) if (mkdir(dir))
...@@ -41,5 +50,5 @@ main(int ac, char **av) ...@@ -41,5 +50,5 @@ main(int ac, char **av)
if (fd < 0) if (fd < 0)
die("open"); die("open");
dolevel(fd, branch, depth); dolevel(fd, depth);
} }
...@@ -127,6 +127,5 @@ main(int ac, char **av) ...@@ -127,6 +127,5 @@ main(int ac, char **av)
test0(); test0();
testfork(); testfork();
execwork::test(); execwork::test();
exitwq();
return 0; return 0;
} }
...@@ -51,15 +51,12 @@ du(int fd) ...@@ -51,15 +51,12 @@ du(int fd)
[](dirit &i)->bool { return !i.end(); }, [](dirit &i)->bool { return !i.end(); },
[&size, &fd](const char *name)->void [&size, &fd](const char *name)->void
{ {
if (!strcmp(name, ".") || !strcmp(name, "..")) { if (!strcmp(name, ".") || !strcmp(name, ".."))
free((void*)name);
return; return;
}
int nfd = openat(fd, name, 0); int nfd = openat(fd, name, 0);
if (nfd >= 0) if (nfd >= 0)
size += du(nfd); // should go into work queue size += du(nfd); // should go into work queue
free((void*)name);
}); });
} else { } else {
close(fd); close(fd);
...@@ -79,6 +76,5 @@ main(int ac, char **av) ...@@ -79,6 +76,5 @@ main(int ac, char **av)
perf_stop(); perf_stop();
printf("%ld\n", s); printf("%ld\n", s);
wq_dump(); wq_dump();
exitwq();
return 0; return 0;
} }
...@@ -67,14 +67,12 @@ ls(const char *path) ...@@ -67,14 +67,12 @@ ls(const char *path)
struct stat st; struct stat st;
if (xfstatat(fd, name, &st) < 0){ if (xfstatat(fd, name, &st) < 0){
printf("ls: cannot stat %s\n", name); printf("ls: cannot stat %s\n", name);
free((void*)name);
return; return;
} }
if (!silent) if (!silent)
printf("%u %10lu %10lu %s\n", printf("%u %10lu %10lu %s\n",
ST_TYPE(st), ST_INO(st), ST_SIZE(st), name); ST_TYPE(st), ST_INO(st), ST_SIZE(st), name);
free((void*)name);
}); });
} else { } else {
close(fd); close(fd);
...@@ -99,6 +97,5 @@ main(int argc, char *argv[]) ...@@ -99,6 +97,5 @@ main(int argc, char *argv[])
perf_stop(); perf_stop();
wq_dump(); wq_dump();
exitwq();
return 0; return 0;
} }
...@@ -13,14 +13,6 @@ public: ...@@ -13,14 +13,6 @@ public:
return *this; return *this;
} }
const char * copy_value() {
char *buf = (char*)malloc(256);
return name(buf, 256);
}
bool end() const { return end_; }
private:
char *name(char *buf, size_t n) const { char *name(char *buf, size_t n) const {
n = MIN(DIRSIZ+1, n); n = MIN(DIRSIZ+1, n);
memmove(buf, de_.name, n-1); memmove(buf, de_.name, n-1);
...@@ -28,6 +20,9 @@ private: ...@@ -28,6 +20,9 @@ private:
return buf; return buf;
} }
bool end() const { return end_; }
private:
void refill(void) { void refill(void) {
int r; int r;
...@@ -45,3 +40,16 @@ private: ...@@ -45,3 +40,16 @@ private:
bool end_; bool end_;
struct dirent de_; struct dirent de_;
}; };
static inline const char*
copy_value(dirit &it)
{
char *buf = (char*)malloc(256);
return it.name(buf, 256);
}
static inline void
free_value(dirit &it, const char *name)
{
free((void*)name);
}
...@@ -52,6 +52,7 @@ struct klockstat; ...@@ -52,6 +52,7 @@ struct klockstat;
#define LOCKSTAT_KALLOC 1 #define LOCKSTAT_KALLOC 1
#define LOCKSTAT_KMALLOC 1 #define LOCKSTAT_KMALLOC 1
#define LOCKSTAT_NET 1 #define LOCKSTAT_NET 1
#define LOCKSTAT_NS 1
#define LOCKSTAT_PIPE 1 #define LOCKSTAT_PIPE 1
#define LOCKSTAT_PROC 1 #define LOCKSTAT_PROC 1
#define LOCKSTAT_SCHED 1 #define LOCKSTAT_SCHED 1
......
...@@ -56,6 +56,10 @@ class xns : public rcu_freed { ...@@ -56,6 +56,10 @@ class xns : public rcu_freed {
nextkey = 1; nextkey = 1;
for (int i = 0; i < NHASH; i++) for (int i = 0; i < NHASH; i++)
table[i].chain = 0; table[i].chain = 0;
for (int i = 0; i < NCPU; i++) {
percore[i] = nullptr;
initlock(&percore_lock[i], "xns_lock", LOCKSTAT_NS);
}
} }
~xns() { ~xns() {
......
...@@ -13,7 +13,7 @@ struct forwork : public work { ...@@ -13,7 +13,7 @@ struct forwork : public work {
: it_(it), cond_(cond), body_(body), frame_(frame) {} : it_(it), cond_(cond), body_(body), frame_(frame) {}
virtual void run() { virtual void run() {
decltype(it_.copy_value()) v = it_.copy_value(); decltype(copy_value(it_)) v = copy_value(it_);
++it_; ++it_;
if (cond_(it_)) { if (cond_(it_)) {
forwork<IT, BODY> *w = new forwork<IT, BODY>(it_, cond_, body_, frame_); forwork<IT, BODY> *w = new forwork<IT, BODY>(it_, cond_, body_, frame_);
...@@ -21,6 +21,7 @@ struct forwork : public work { ...@@ -21,6 +21,7 @@ struct forwork : public work {
wq_push(w); wq_push(w);
} }
body_(v); body_(v);
free_value(it_, v);
frame_.dec(); frame_.dec();
delete this; delete this;
} }
...@@ -48,15 +49,48 @@ wq_for(IT &init, bool (*cond)(IT &it), BODY body) ...@@ -48,15 +49,48 @@ wq_for(IT &init, bool (*cond)(IT &it), BODY body)
// XXX(sbw) should be able to coarsen loop // XXX(sbw) should be able to coarsen loop
decltype(init.copy_value()) v = init.copy_value(); if (!cond(init))
return;
decltype(copy_value(init)) v = copy_value(init);
++init; ++init;
if (cond(init)) { if (cond(init)) {
forwork<IT, BODY> *w = new forwork<IT, BODY>(init, cond, body, frame); forwork<IT, BODY> *w = new forwork<IT, BODY>(init, cond, body, frame);
frame.inc(); frame.inc();
wq_push(w); wq_push(w);
} }
body(v); body(v);
free_value(init, v);
while (!frame.zero()) while (!frame.zero())
wq_trywork(); wq_trywork();
} }
// For debugging
// Same API as wq_for but serially executes body
template <typename IT, typename BODY>
static inline void
wq_for_serial(IT &init, bool (*cond)(IT &it), BODY body)
{
for (; cond(init); ++init) {
decltype(copy_value(init)) v = copy_value(init);
body(v);
free_value(init, v);
}
}
// Default copy_value
template <typename T>
static inline T
copy_value(T &it)
{
return it;
}
// Default free_value
template <typename T>
static inline void
free_value(T &it, T &v)
{
}
...@@ -43,9 +43,4 @@ wqarch_init(void) ...@@ -43,9 +43,4 @@ wqarch_init(void)
{ {
} }
static inline void
wqarch_exit(void)
{
}
#define xprintf cprintf #define xprintf cprintf
...@@ -92,12 +92,6 @@ wqarch_init(void) ...@@ -92,12 +92,6 @@ wqarch_init(void)
pthread_setspecific(idkey, (void*)(u64)id); pthread_setspecific(idkey, (void*)(u64)id);
} }
static inline void
wqarch_exit(void)
{
exiting = 1;
}
#define xprintf printf #define xprintf printf
#define pushcli() #define pushcli()
#define popcli() #define popcli()
...@@ -201,7 +201,7 @@ ialloc(u32 dev, short type) ...@@ -201,7 +201,7 @@ ialloc(u32 dev, short type)
//cprintf("ialloc oops %d\n", inum); // XXX harmless //cprintf("ialloc oops %d\n", inum); // XXX harmless
} }
} }
cprintf("ialloc: no inodes\n"); cprintf("ialloc: 0/%u inodes\n", sb.ninodes);
return nullptr; return nullptr;
} }
......
...@@ -79,12 +79,6 @@ initwq(void) ...@@ -79,12 +79,6 @@ initwq(void)
wqarch_init(); wqarch_init();
} }
void
exitwq(void)
{
wqarch_exit();
}
// //
// wq // wq
// //
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
#include "include/stat.h" #include "include/stat.h"
int nblocks = 4067; int nblocks = 4067;
int ninodes = 200; int ninodes = 800;
int size = 4096; int size = 4172;
int fsfd; int fsfd;
struct superblock sb; struct superblock sb;
......
...@@ -83,11 +83,6 @@ wqarch_init(void) ...@@ -83,11 +83,6 @@ wqarch_init(void)
} }
} }
static inline void
wqarch_exit(void)
{
}
#define xprintf printf #define xprintf printf
#define pushcli() #define pushcli()
#define popcli() #define popcli()
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论