diff options
| author | Jonathan Herman <hermanjl@cs.unc.edu> | 2012-05-03 16:46:21 -0400 |
|---|---|---|
| committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2012-05-03 16:46:21 -0400 |
| commit | b71e2f3c0796b66d118fd0166ae80c7d9a547740 (patch) | |
| tree | e6d5843888e3ba43cbc9b5b705c892b00c88f2f1 | |
| parent | ff87ca319b0cd76f96f78f0347ad9aaa967bb16e (diff) | |
| parent | 7bd1ec8308f63bffda37127d02a178c5fc91dac3 (diff) | |
Removed mixed-criticality codewip-color-jlh
| -rw-r--r-- | .gitignore | 3 | ||||
| -rw-r--r-- | Makefile | 22 | ||||
| -rw-r--r-- | bin/color.c | 50 | ||||
| -rw-r--r-- | bin/colorbench.c | 460 | ||||
| -rw-r--r-- | bin/colortest.c | 94 | ||||
| -rw-r--r-- | bin/perfcounters.c | 197 | ||||
| -rw-r--r-- | bin/rtspin.c | 33 | ||||
| -rw-r--r-- | bin/testcounters.c | 401 | ||||
| -rw-r--r-- | include/color.h | 9 | ||||
| -rw-r--r-- | include/internal.h | 5 | ||||
| -rw-r--r-- | include/litmus.h | 1 | ||||
| -rw-r--r-- | include/perfcounters.h | 36 | ||||
| -rw-r--r-- | src/kernel_iface.c | 15 | ||||
| -rw-r--r-- | src/syscalls.c | 7 |
14 files changed, 1284 insertions, 49 deletions
| @@ -22,6 +22,9 @@ showst | |||
| 22 | rtspin | 22 | rtspin |
| 23 | cycles | 23 | cycles |
| 24 | measure_syscall | 24 | measure_syscall |
| 25 | colortest | ||
| 26 | colorbench | ||
| 27 | testcounters | ||
| 25 | 28 | ||
| 26 | # build system files | 29 | # build system files |
| 27 | .config | 30 | .config |
| @@ -12,7 +12,7 @@ host-arch := $(shell uname -m | \ | |||
| 12 | ARCH ?= ${host-arch} | 12 | ARCH ?= ${host-arch} |
| 13 | 13 | ||
| 14 | # LITMUS_KERNEL -- where to find the litmus kernel? | 14 | # LITMUS_KERNEL -- where to find the litmus kernel? |
| 15 | LITMUS_KERNEL ?= ../litmus-rt | 15 | LITMUS_KERNEL ?= ../backup-litmus-rt |
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | # ############################################################################## | 18 | # ############################################################################## |
| @@ -71,8 +71,8 @@ AR := ${CROSS_COMPILE}${AR} | |||
| 71 | # Targets | 71 | # Targets |
| 72 | 72 | ||
| 73 | all = lib ${rt-apps} | 73 | all = lib ${rt-apps} |
| 74 | rt-apps = cycles base_task rt_launch locktest rtspin rtspin.ovh rtspin.beta release_ts \ | 74 | rt-apps = cycles base_task rt_launch rtspin release_ts measure_syscall \ |
| 75 | measure_syscall base_mt_task runtests bespin | 75 | base_mt_task runtests colortest colorbench testcounters bespin |
| 76 | 76 | ||
| 77 | .PHONY: all lib clean dump-config TAGS tags cscope help | 77 | .PHONY: all lib clean dump-config TAGS tags cscope help |
| 78 | 78 | ||
| @@ -155,7 +155,7 @@ arch/${include-${ARCH}}/include/asm/%.h: \ | |||
| 155 | cp $< $@ | 155 | cp $< $@ |
| 156 | 156 | ||
| 157 | litmus-headers = include/litmus/rt_param.h include/litmus/unistd_32.h \ | 157 | litmus-headers = include/litmus/rt_param.h include/litmus/unistd_32.h \ |
| 158 | include/litmus/unistd_64.h include/litmus/sched_mc.h include/litmus/color.h | 158 | include/litmus/unistd_64.h include/litmus/color.h |
| 159 | 159 | ||
| 160 | unistd-headers = \ | 160 | unistd-headers = \ |
| 161 | $(foreach file,${unistd-${ARCH}},arch/${include-${ARCH}}/include/asm/$(file)) | 161 | $(foreach file,${unistd-${ARCH}},arch/${include-${ARCH}}/include/asm/$(file)) |
| @@ -230,12 +230,21 @@ lib-locktest = -lrt -pthread | |||
| 230 | obj-measure_syscall = null_call.o | 230 | obj-measure_syscall = null_call.o |
| 231 | lib-measure_syscall = -lm | 231 | lib-measure_syscall = -lm |
| 232 | 232 | ||
| 233 | obj-colortest = colortest.o color.o | ||
| 234 | lib-colortest = -static | ||
| 235 | |||
| 236 | obj-colorbench = colorbench.o color.o perfcounters.o common.o | ||
| 237 | lib-colorbench = -lpthread -lrt -lgsl -lgslcblas | ||
| 238 | |||
| 239 | obj-testcounters = testcounters.o | ||
| 240 | lib-testcounters = | ||
| 241 | |||
| 233 | # ############################################################################## | 242 | # ############################################################################## |
| 234 | # Build everything that depends on liblitmus. | 243 | # Build everything that depends on liblitmus. |
| 235 | 244 | ||
| 236 | .SECONDEXPANSION: | 245 | .SECONDEXPANSION: |
| 237 | ${rt-apps}: $${obj-$$@} liblitmus.a | 246 | ${rt-apps}: $${obj-$$@} liblitmus.a |
| 238 | $(CC) -o $@ $(LDFLAGS) ${ldf-$@} $(filter-out liblitmus.a,$+) $(LOADLIBS) $(LDLIBS) ${lib-$@} ${liblitmus-flags} | 247 | $(CC) -o $@ $(LDFLAGS) ${ldf-$@} $(filter-out liblitmus.a,$+) $(LOADLIBS) $(LDLIBS) ${liblitmus-flags} ${lib-$@} |
| 239 | 248 | ||
| 240 | # ############################################################################## | 249 | # ############################################################################## |
| 241 | # Dependency resolution. | 250 | # Dependency resolution. |
| @@ -273,7 +282,7 @@ $(error Cannot build without access to the LITMUS^RT kernel source) | |||
| 273 | endif | 282 | endif |
| 274 | 283 | ||
| 275 | kernel-unistd-hdrs := $(foreach file,${unistd-headers},${LITMUS_KERNEL}/$(file)) | 284 | kernel-unistd-hdrs := $(foreach file,${unistd-headers},${LITMUS_KERNEL}/$(file)) |
| 276 | hdr-ok := $(shell egrep '\#include ["<]litmus/unistd' ${kernel-unistd-hdrs} ) | 285 | hdr-ok := $(shell egrep '\#include .*litmus/unistd' ${kernel-unistd-hdrs} ) |
| 277 | ifeq ($(strip $(hdr-ok)),) | 286 | ifeq ($(strip $(hdr-ok)),) |
| 278 | $(info (!!) Could not find LITMUS^RT system calls in ${kernel-unistd-hdrs}.) | 287 | $(info (!!) Could not find LITMUS^RT system calls in ${kernel-unistd-hdrs}.) |
| 279 | $(error Your kernel headers do not seem to be LITMUS^RT headers) | 288 | $(error Your kernel headers do not seem to be LITMUS^RT headers) |
| @@ -290,4 +299,3 @@ $(error Cannot build without access to the architecture-specific files) | |||
| 290 | endif | 299 | endif |
| 291 | 300 | ||
| 292 | endif | 301 | endif |
| 293 | |||
diff --git a/bin/color.c b/bin/color.c new file mode 100644 index 0000000..2ec97a4 --- /dev/null +++ b/bin/color.c | |||
| @@ -0,0 +1,50 @@ | |||
| 1 | #include <stdlib.h> | ||
| 2 | #include <stdint.h> | ||
| 3 | #include <sys/mman.h> | ||
| 4 | #include <sys/fcntl.h> | ||
| 5 | #include <unistd.h> | ||
| 6 | |||
| 7 | #include <litmus/rt_param.h> | ||
| 8 | |||
| 9 | #include "color.h" | ||
| 10 | |||
| 11 | #define LITMUS_COLOR_ALLOC "/dev/litmus/color_alloc" | ||
| 12 | #define LITMUS_COLOR_CTRL "/dev/litmus/color_ctrl" | ||
| 13 | |||
| 14 | static int map_file(const char* filename, void **addr, size_t size) | ||
| 15 | { | ||
| 16 | int error = 0; | ||
| 17 | int fd; | ||
| 18 | |||
| 19 | if (size > 0) { | ||
| 20 | fd = open(filename, O_RDWR); | ||
| 21 | if (fd >= 0) { | ||
| 22 | *addr = mmap(NULL, size, | ||
| 23 | PROT_READ | PROT_WRITE, | ||
| 24 | MAP_PRIVATE, | ||
| 25 | fd, 0); | ||
| 26 | if (*addr == MAP_FAILED) | ||
| 27 | error = -1; | ||
| 28 | close(fd); | ||
| 29 | } else | ||
| 30 | error = fd; | ||
| 31 | } else | ||
| 32 | *addr = NULL; | ||
| 33 | return error; | ||
| 34 | } | ||
| 35 | |||
| 36 | int map_color_ctrl(void **addr) | ||
| 37 | { | ||
| 38 | return map_file(LITMUS_COLOR_CTRL, addr, PAGE_SIZE); | ||
| 39 | } | ||
| 40 | |||
| 41 | void* color_malloc(size_t size) | ||
| 42 | { | ||
| 43 | int err; | ||
| 44 | void *mem; | ||
| 45 | |||
| 46 | err = map_file(LITMUS_COLOR_ALLOC, &mem, size); | ||
| 47 | if (err) | ||
| 48 | mem = NULL; | ||
| 49 | return mem; | ||
| 50 | } | ||
diff --git a/bin/colorbench.c b/bin/colorbench.c new file mode 100644 index 0000000..c91b731 --- /dev/null +++ b/bin/colorbench.c | |||
| @@ -0,0 +1,460 @@ | |||
| 1 | #include <stdint.h> /* rt_param needs uint types */ | ||
| 2 | #include <stdlib.h> | ||
| 3 | #include <limits.h> | ||
| 4 | #include <pthread.h> | ||
| 5 | #include <sched.h> | ||
| 6 | #include <errno.h> | ||
| 7 | #include <stdio.h> | ||
| 8 | #include <unistd.h> | ||
| 9 | #include <sys/mman.h> /* mlockall */ | ||
| 10 | #include <sys/ioctl.h> | ||
| 11 | |||
| 12 | #include <litmus/rt_param.h> | ||
| 13 | |||
| 14 | #include "perfcounters.h" | ||
| 15 | #include "color.h" | ||
| 16 | #include "litmus.h" | ||
| 17 | |||
| 18 | #define DEBUG 1 | ||
| 19 | #define NR_LOOPS 10 | ||
| 20 | |||
| 21 | /* Pound */ | ||
| 22 | #define NR_CPUS 4 | ||
| 23 | #define CACHE_SIZE_MB 8 | ||
| 24 | #define ASSOC 16 | ||
| 25 | #define LINE_SIZE 64 | ||
| 26 | |||
| 27 | #define CACHE_SIZE (CACHE_SIZE_MB * 1024 * 1024) | ||
| 28 | #define TOTAL_COLORS (CACHE_SIZE / ASSOC / PAGE_SIZE) | ||
| 29 | |||
| 30 | /* number of colors we actually use */ | ||
| 31 | #define USE_COLORS (TOTAL_COLORS >> color_shift) | ||
| 32 | |||
| 33 | /* how many adjacent pages of the same color we need to allocate */ | ||
| 34 | #define CONTIG_COLORS (ARENA_PAGES / USE_COLORS) | ||
| 35 | |||
| 36 | /* number of pages in arena */ | ||
| 37 | #define ARENA_PAGES (arena_size / PAGE_SIZE) | ||
| 38 | |||
| 39 | /* page offset bit mask */ | ||
| 40 | #define PAGE_LOWER ((PAGE_SIZE - 1)) | ||
| 41 | |||
| 42 | /* number of integers in arena */ | ||
| 43 | #define ARENA_INTS (arena_size / sizeof(int)) | ||
| 44 | |||
| 45 | /* number of pages in arena */ | ||
| 46 | #define ARENA_PAGES (arena_size / PAGE_SIZE) | ||
| 47 | |||
| 48 | /* number of cache lines in arena */ | ||
| 49 | #define ARENA_LINES (arena_size / LINE_SIZE) | ||
| 50 | |||
| 51 | /* number of cache lines per page */ | ||
| 52 | #define PAGE_LINES (PAGE_SIZE / LINE_SIZE) | ||
| 53 | |||
| 54 | /* number of integers in a page */ | ||
| 55 | #define PAGE_INTS (PAGE_SIZE / sizeof(int)) | ||
| 56 | |||
| 57 | /* number of integers in a cache line */ | ||
| 58 | #define LINE_INTS (LINE_SIZE / sizeof(int)) | ||
| 59 | |||
