Linux filebench fixes

上级 5f68e711
...@@ -16,7 +16,6 @@ static inline void xwait() ...@@ -16,7 +16,6 @@ static inline void xwait()
edie("wait"); edie("wait");
if (!WIFEXITED(status)) if (!WIFEXITED(status))
die("bad status %u", status); die("bad status %u", status);
} }
#define xmkdir(pathname) mkdir((pathname), S_IWUSR|S_IRUSR); #define xmkdir(pathname) mkdir((pathname), S_IWUSR|S_IRUSR);
#define xcreat(name) open((name), O_CREATE, S_IRUSR|S_IWUSR) #define xcreat(name) open((name), O_CREATE, S_IRUSR|S_IWUSR)
......
...@@ -4,9 +4,18 @@ ...@@ -4,9 +4,18 @@
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <assert.h> #include <assert.h>
#include <sys/wait.h>
#define O_CREATE O_CREAT #define O_CREATE O_CREAT
#define xfork() fork() #define xfork() fork()
#define xexit() exit(EXIT_SUCCESS) #define xexit() exit(EXIT_SUCCESS)
static inline void xwait()
{
int status;
if (wait(&status) < 0)
edie("wait");
if (!WIFEXITED(status))
die("bad status %u", status);
}
#define xcreat(name) open((name), O_CREATE|O_WRONLY, S_IRUSR|S_IWUSR) #define xcreat(name) open((name), O_CREATE|O_WRONLY, S_IRUSR|S_IWUSR)
#define mtenable(x) do { } while(0) #define mtenable(x) do { } while(0)
#define mtdisable(x) do { } while(0) #define mtdisable(x) do { } while(0)
...@@ -29,12 +38,12 @@ static const bool pinit = true; ...@@ -29,12 +38,12 @@ static const bool pinit = true;
static char chunkbuf[CHUNKSZ]; static char chunkbuf[CHUNKSZ];
static void static void
bench(int tid, int nloop) bench(int tid, int nloop, const char* path)
{ {
if (pinit) if (pinit)
setaffinity(tid); setaffinity(tid);
int fd = open("filebenchx", O_RDWR); int fd = open(path, O_RDWR);
if (fd < 0) if (fd < 0)
die("open"); die("open");
...@@ -57,6 +66,7 @@ bench(int tid, int nloop) ...@@ -57,6 +66,7 @@ bench(int tid, int nloop)
int int
main(int ac, char **av) main(int ac, char **av)
{ {
const char* path;
int nthread; int nthread;
int nloop; int nloop;
...@@ -65,17 +75,20 @@ main(int ac, char **av) ...@@ -65,17 +75,20 @@ main(int ac, char **av)
#else #else
nloop = 1000; nloop = 1000;
#endif #endif
path = "fbx";
if (ac < 2) if (ac < 2)
die("usage: %s nthreads [nloop]", av[0]); die("usage: %s nthreads [nloop] [path]", av[0]);
nthread = atoi(av[1]); nthread = atoi(av[1]);
if (ac > 2) if (ac > 2)
nloop = atoi(av[2]); nloop = atoi(av[2]);
if (ac > 3)
path = av[3];
// Setup shared file // Setup shared file
unlink("filebenchx"); unlink(path);
int fd = xcreat("filebenchx"); int fd = xcreat(path);
if (fd < 0) if (fd < 0)
die("open O_CREAT failed"); die("open O_CREAT failed");
for (int i = 0; i < FILESZ; i += CHUNKSZ) { for (int i = 0; i < FILESZ; i += CHUNKSZ) {
...@@ -90,13 +103,13 @@ main(int ac, char **av) ...@@ -90,13 +103,13 @@ main(int ac, char **av)
for (int i = 0; i < nthread; i++) { for (int i = 0; i < nthread; i++) {
int pid = xfork(); int pid = xfork();
if (pid == 0) if (pid == 0)
bench(i, nloop); bench(i, nloop, path);
else if (pid < 0) else if (pid < 0)
die("fork"); die("fork");
} }
for (int i = 0; i < nthread; i++) for (int i = 0; i < nthread; i++)
wait(); xwait();
u64 t1 = rdtsc(); u64 t1 = rdtsc();
mtdisable("xv6-filebench"); mtdisable("xv6-filebench");
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论