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