Skip to content

Commit

Permalink
Merge branch 'scale-amd64' of ssh://amsterdam.csail.mit.edu/home/am0/…
Browse files Browse the repository at this point in the history
…6.828/xv6 into scale-amd64
  • Loading branch information
Frans Kaashoek committed Feb 4, 2013
2 parents 4ced3a4 + 000590e commit 2a720d1
Show file tree
Hide file tree
Showing 178 changed files with 91,885 additions and 65,099 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ o.qemu/
o.ben/
o.josmp/
o.tom/
o.user/
o.native/
o.linux/
/mtrace.out
/mtrace.txt
/mscan.out
Expand Down
44 changes: 37 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ EXCEPTIONS ?= y
RUN ?= $(empty)
PYTHON ?= python
O = o.$(HW)
CODEX ?= 0

ifeq ($(HW),linux)
PLATFORM := native
else
PLATFORM := xv6
endif

ifeq ($(CODEX),1)
CODEXINC = -Icodexinc
else
CODEXINC =
endif

ifdef USE_CLANG
CC = $(TOOLPREFIX)clang
Expand All @@ -31,15 +44,29 @@ NM = $(TOOLPREFIX)nm
OBJCOPY = $(TOOLPREFIX)objcopy
STRIP = $(TOOLPREFIX)strip

INCLUDES = --sysroot=$(O)/sysroot -iquote include -iquote$(O)/include -Istdinc -I$(QEMUSRC) -include param.h -include include/compiler.h
COMFLAGS = -static -g -MD -MP -m64 -O3 -Wall -Werror -DHW_$(HW) -DXV6_HW=$(HW) -DXV6 \
ifeq ($(PLATFORM),xv6)
INCLUDES = --sysroot=$(O)/sysroot \
-iquote include -iquote$(O)/include \
-iquote libutil/include \
-Istdinc $(CODEXINC) -I$(QEMUSRC) \
-include param.h -include libutil/include/compiler.h
COMFLAGS = -static -DXV6_HW=$(HW) -DXV6 -DCODEX=$(CODEX) \
-fno-builtin -fno-strict-aliasing -fno-omit-frame-pointer -fms-extensions \
-mno-red-zone $(INCLUDES)
-mno-red-zone
COMFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1 && echo -fno-stack-protector) -I$(shell $(CC) -print-file-name=include)
LDFLAGS = -m elf_x86_64
else
INCLUDES := -include param.h -iquote libutil/include -I$(QEMUSRC)
COMFLAGS := -pthread -Wno-unused-result
LDFLAGS := -pthread
# No mere mortal can call ld correctly on a real machine, so use gcc's
# link driver instead.
LD = $(TOOLPREFIX)gcc
endif
COMFLAGS += -g -MD -MP -O3 -Wall -Werror -DHW_$(HW) $(INCLUDES)
CFLAGS := $(COMFLAGS) -std=c99 $(CFLAGS)
CXXFLAGS := $(COMFLAGS) -std=c++0x -Wno-sign-compare $(CXXFLAGS)
ASFLAGS := $(ASFLAGS) -Iinclude -I$(O)/include -m64 -gdwarf-2 -MD -MP -DHW_$(HW) -include param.h
LDFLAGS = -m elf_x86_64

ALL :=
all:
Expand All @@ -51,10 +78,13 @@ define SYSCALLGEN
$(Q)cmp -s $@.tmp $@ || mv $@.tmp $@
endef

ifeq ($(PLATFORM),xv6)
include net/Makefrag
include kernel/Makefrag
endif
include lib/Makefrag
include libutil/Makefrag
include bin/Makefrag
include kernel/Makefrag
include tools/Makefrag
include metis/Makefrag
-include user/Makefrag.$(HW)
Expand Down Expand Up @@ -120,9 +150,9 @@ QEMUOPTS = -smp $(QEMUSMP) -m 512 -serial mon:stdio -nographic \
$(if $(RUN),-append "\$$ $(RUN)",)

qemu: $(KERN)
$(QEMU) $(QEMUOPTS) -kernel $(KERN)
$(QEMU) $(QEMUOPTS) $(QEMUKVMFLAGS) -kernel $(KERN)
gdb: $(KERN)
$(QEMU) $(QEMUOPTS) -kernel $(KERN) -s
$(QEMU) $(QEMUOPTS) $(QEMUKVMFLAGS) -kernel $(KERN) -s

codex: $(KERN)

Expand Down
32 changes: 26 additions & 6 deletions bin/Makefrag
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# -*-Makefile-*-
# -*- makefile-gmake -*-
$(O)/bin/%.o: CFLAGS:=$(CFLAGS)
$(O)/bin/%.o: CXXFLAGS:=$(CXXFLAGS) -fno-exceptions -fno-rtti

ifeq ($(PLATFORM),xv6)
$(O)/bin/%.o: CFLAGS:=$(CFLAGS) -DXV6_USER
$(O)/bin/%.o: CXXFLAGS:=$(CXXFLAGS) -DXV6_USER -fno-exceptions -fno-rtti
$(O)/bin/%.o: CXXFLAGS:=$(CXXFLAGS) -DXV6_USER
endif

UPROGS_BIN= \
bench \
Expand All @@ -26,9 +31,7 @@ UPROGS_BIN= \
dirbench \
usertests \
lockstat \
preadtest \
scripttest \
ftest \
cp \
perf \
xtime \
Expand All @@ -52,6 +55,7 @@ UPROGS_BIN= \
lsocketbench \
fstest \
base64 \
tee \

ifeq ($(HAVE_LWIP),y)
UPROGS_BIN += \
Expand All @@ -66,17 +70,33 @@ UPROGS := $(UPROGS_BIN) \

UPROGS := $(addprefix $(O)/bin/, $(UPROGS))

# Binaries that are known to build on PLATFORM=native
UPROGS_NATIVE := \
benchhdr \
mapbench \
tee \
fstest \

FSEXTRA += \
bin/linkbench-tom \
bin/mapbench-ben \
bin/metis_wrmem-josmp \
bin/lsocket \
bin/countbench-ben \

$(O)/bin/%.unstripped: $(O)/bin/%.o $(ULIBA)
ifeq ($(PLATFORM),native)
ALL += $(addprefix $(O)/bin/, $(UPROGS_NATIVE))
endif

ifneq ($(PLATFORM),native)
UPROGS_LIBS += $(ULIBA)
endif
UPROGS_LIBS += $(LIBUTIL_A)

$(O)/bin/%.unstripped: $(O)/bin/%.o $(UPROGS_LIBS)
@echo " LD $@"
$(Q)mkdir -p $(@D)
$(Q)$(LD) $(LDFLAGS) -o $@ $< $(ULIBA)
$(Q)$(LD) $(LDFLAGS) -o $@ $^

$(O)/bin/%: $(O)/bin/%.unstripped
@echo " STRIP $@"
Expand Down
5 changes: 4 additions & 1 deletion bin/allocbench.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
#include "pthread.h"
#endif
#include "xsys.h"
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <unistd.h>

Expand All @@ -22,7 +25,7 @@ static int niter;
void*
thr(void *arg)
{
u64 tid = (u64)arg;
int tid = (uintptr_t)arg;

if (setaffinity(tid) < 0)
die("setaffinity err");
Expand Down
4 changes: 3 additions & 1 deletion bin/appendtest.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#include "types.h"
#include "user.h"
#include <fcntl.h>
#include "pthread.h"

#include <fcntl.h>
#include <string.h>

static pthread_barrier_t bar;

static void*
Expand Down
10 changes: 6 additions & 4 deletions bin/asharing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
#include "pthread.h"
#include "rnd.hh"

#include <stdio.h>
#include <string.h>
#include <sys/mman.h>

#include "atomic.hh"
#include <atomic>
#include <utility>

static int cpu;
Expand Down Expand Up @@ -105,7 +107,7 @@ vm2sharing(void *arg)
void*
fssharing(void* arg)
{
u64 i = (u64) arg;
int i = (uintptr_t) arg;

// Note that we keep these files open; otherwise all of these
// operations will share the abstract FD object and we won't get any
Expand All @@ -118,7 +120,7 @@ fssharing(void* arg)

ready();

for (u64 j = 0; j < ncore; j++) {
for (int j = 0; j < ncore; j++) {
snprintf(filename, sizeof(filename), "f%d", j);
open(filename, O_RDWR);
}
Expand All @@ -136,7 +138,7 @@ main(int ac, char **av)
else if (ac == 2 && strcmp(av[1], "fs") == 0)
op = fssharing;
else
fprintf(1, "usage: %s vm|fs\n", av[0]);
die("usage: %s vm|fs", av[0]);

if (op) {
barrier = ncore + 1;
Expand Down
4 changes: 3 additions & 1 deletion bin/avar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "user.h"
#include "mtrace.h"

#include <string.h>

int
main(int ac, char **av)
{
Expand All @@ -12,5 +14,5 @@ main(int ac, char **av)
else if (ac == 2 && strcmp(av[1], "off") == 0)
mtdisable("xv6-asharing");
else
fprintf(1, "usage: %s on|off\n", av[0]);
die("usage: %s on|off\n", av[0]);
}
36 changes: 2 additions & 34 deletions bin/base64.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#include "libutil.h"

#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#if defined(LINUX)
#include "user/util.h"
#else
#include "user.h"
#endif

static const char charset[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
Expand Down Expand Up @@ -37,35 +34,6 @@ encode(const void *data, size_t len, void *out)
return (len + 2) / 3 * 4;
}

static size_t
xread(int fd, const void *buf, size_t n)
{
size_t pos = 0;
while (pos < n) {
int r = read(fd, (char*)buf + pos, n - pos);
if (r < 0)
die("read failed");
if (r == 0)
break;
pos += r;
}
return pos;
}

static void
xwrite(int fd, const void *buf, size_t n)
{
int r;

while (n) {
r = write(fd, buf, n);
if (r < 0 || r == 0)
die("write failed");
buf = (char *) buf + r;
n -= r;
}
}

static void
encodefd(int fdin, int fdout)
{
Expand Down
6 changes: 5 additions & 1 deletion bin/bench.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
#include "amd64.h"
#include "lib.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static u64
time_this(const char *av[])
{
Expand Down Expand Up @@ -82,7 +86,7 @@ struct LoopsBench : public Bench
r = (r*(1000*1000)) / cpuhz();
min = MIN(r, min);
}
snprintf(res, n, "%u %lu %lu\n", ncore, min, nloops_);
snprintf(res, n, "%u %lu %u\n", ncore, min, nloops_);
return res + strlen(res);
}

Expand Down
23 changes: 22 additions & 1 deletion bin/benchhdr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <unistd.h>

#include <sys/utsname.h>

Expand All @@ -33,7 +35,7 @@ print_escaped(const char *x)
const char *eq = strchr(x, '=');
if (eq && eq != x) {
++eq;
printf("%.*s", (eq - x), x);
printf("%.*s", (int)(eq - x), x);
x = eq;
}

Expand All @@ -46,6 +48,21 @@ print_escaped(const char *x)
printf("\"");
}

void
print_iso8601(void)
{
time_t now = time(nullptr);
struct tm tm;
localtime_r(&now, &tm);

printf("%04d-%02d-%02dT%02d:%02d:%02d%c%02d%02d",
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec,
TZ_SECS < 0 ? '+' : '-',
std::max(TZ_SECS, -TZ_SECS) / 3600,
(std::max(TZ_SECS, -TZ_SECS) % 3600) / 60);
}

void
print_kconfig(void)
{
Expand Down Expand Up @@ -81,6 +98,10 @@ int main(int argc, char **argv)
uname(&uts);

printf("==");

printf(" id=");
print_iso8601();

for (int i = 1; i < argc; ++i) {
printf(" ");
print_escaped(argv[i]);
Expand Down
8 changes: 4 additions & 4 deletions bin/cat.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "types.h"
#include "user.h"

#include <fcntl.h>

char buf[512];

void
Expand All @@ -11,8 +13,7 @@ cat(int fd)
while((n = read(fd, buf, sizeof(buf))) > 0)
write(1, buf, n);
if(n < 0){
fprintf(1, "cat: read error\n");
exit();
die("cat: read error");
}
}

Expand All @@ -28,8 +29,7 @@ main(int argc, char *argv[])

for(i = 1; i < argc; i++){
if((fd = open(argv[i], 0)) < 0){
fprintf(1, "cat: cannot open %s\n", argv[i]);
exit();
die("cat: cannot open %s", argv[i]);
}
cat(fd);
close(fd);
Expand Down
Loading

0 comments on commit 2a720d1

Please sign in to comment.