From d7cd65d54c33f7ce57310d8d4df6178dc250c2d1 Mon Sep 17 00:00:00 2001 From: John Kacur Date: Tue, 14 Feb 2012 01:47:25 +0100 Subject: gitignore: differentiate between program names and directories Many rt-test programs including cyclictest have directories with the same name as the generated binaries. Tell .gitignore to only ignore the program names and not the directories by using a slash prefix. Signed-off-by: John Kacur --- .gitignore | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 44b3d4d..047925c 100644 --- a/.gitignore +++ b/.gitignore @@ -10,19 +10,24 @@ releases BUILD RPMS SRPMS -classic_pi -pi_stress -cyclictest -signaltest + +# +# Top-level programs +# +/classic_pi +/pi_stress +/cyclictest +/signaltest +/hwlatdetect +/rt-migrate-test +/ptsematest +/sendme +/sigwaittest +/svsematest +/pip_stress +/hackbench +/pmqtest + rt-tests.spec -hwlatdetect tags TAGS -rt-migrate-test -ptsematest -sendme -sigwaittest -svsematest -pip_stress -hackbench -pmqtest -- cgit 1.2.3-korg From b52b383192e7a38e129ac0e10a361214721fcb83 Mon Sep 17 00:00:00 2001 From: Steven Rostedt Date: Wed, 21 Mar 2012 13:06:43 -0400 Subject: rt-tests: Update rt-migrate-test to use ftrace infrastructure The rt-migrate-test in the rt-tests is still using the old logdev interface that requires the logdev patch. Ftrace has been introduced into mainline Linux since 2.6.27 and has many more features than logdev. The rt-migrate-test should interact with ftrace instead of logdev. Signed-off-by: Steven Rostedt Signed-off-by: John Kacur --- src/rt-migrate-test/rt-migrate-test.c | 85 +++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 39 deletions(-) diff --git a/src/rt-migrate-test/rt-migrate-test.c b/src/rt-migrate-test/rt-migrate-test.c index 1963641..e3c7a09 100644 --- a/src/rt-migrate-test/rt-migrate-test.c +++ b/src/rt-migrate-test/rt-migrate-test.c @@ -44,39 +44,55 @@ #include #include #include -#ifdef LOGDEV -# include -# define do_logdev_open() open("/debug/logdev/write", O_WRONLY) -# define do_logdev_close(ld) close(ld) -__thread char buff[BUFSIZ]; -static lgprint(int fd, const char *fmt, ...) + +#define gettid() syscall(__NR_gettid) + +#ifndef VERSION_STRING +#define VERSION_STRING 0.3 +#endif + +int nr_tasks; +int lfd; + +static int mark_fd = -1; +static __thread char buff[BUFSIZ+1]; + +static void setup_ftrace_marker(void) +{ + struct stat st; + char *files[] = { + "/sys/kernel/debug/tracing/trace_marker", + "/debug/tracing/trace_marker", + "/debugfs/tracing/trace_marker", + }; + int ret; + int i; + + for (i = 0; i < (sizeof(files) / sizeof(char *)); i++) { + ret = stat(files[i], &st); + if (ret >= 0) + goto found; + } + /* todo, check mounts system */ + return; +found: + mark_fd = open(files[i], O_WRONLY); +} + +static void ftrace_write(const char *fmt, ...) { va_list ap; int n; + if (mark_fd < 0) + return; + va_start(ap, fmt); n = vsnprintf(buff, BUFSIZ, fmt, ap); va_end(ap); - write(fd, buff, n); + write(mark_fd, buff, n); } -#else -# define do_logdev_open() (0) -# define do_logdev_close(lfd) do { } while(0) -# define logdev_print_set(x) do { } while(0) -# define logdev_switch_set(x) do { } while(0) -# define lgprint(x...) do { } while(0) -#endif - - -#define gettid() syscall(__NR_gettid) - -#ifndef VERSION_STRING -#define VERSION_STRING "V 0.3" -#endif - -int nr_tasks; -int lfd; #define nano2sec(nan) (nan / 1000000000ULL) #define nano2ms(nan) (nan / 1000000ULL) @@ -360,8 +376,8 @@ void *start_task(void *data) } pthread_barrier_wait(&start_barrier); start_time = get_time(); - lgprint(lfd, "Thread %d: started %lld diff %lld\n", - pid, start_time, start_time - now); + ftrace_write("Thread %d: started %lld diff %lld\n", + pid, start_time, start_time - now); l = busy_loop(start_time); record_time(id, start_time, l); pthread_barrier_wait(&end_barrier); @@ -403,8 +419,6 @@ static int check_times(int l) static void stop_log(int sig) { - logdev_print_set(0); - logdev_switch_set(0); stop = 1; } @@ -527,27 +541,25 @@ int main (int argc, char **argv) print_progress_bar(0); - lfd = do_logdev_open(); - logdev_print_set(1); - logdev_switch_set(1); + setup_ftrace_marker(); for (loop=0; loop < nr_runs; loop++) { unsigned long long end; now = get_time(); - lgprint(lfd, "Loop %d now=%lld\n", loop, now); + ftrace_write("Loop %d now=%lld\n", loop, now); pthread_barrier_wait(&start_barrier); - lgprint(lfd, "All running!!!\n"); + ftrace_write("All running!!!\n"); nanosleep(&intv, NULL); print_progress_bar((loop * 100)/ nr_runs); end = get_time(); - lgprint(lfd, "Loop %d end now=%lld diff=%lld\n", loop, end, end - now); + ftrace_write("Loop %d end now=%lld diff=%lld\n", loop, end, end - now); pthread_barrier_wait(&end_barrier); @@ -557,8 +569,6 @@ int main (int argc, char **argv) break; } } - do_logdev_close(lfd); - putc('\n', stderr); pthread_barrier_wait(&start_barrier); @@ -568,9 +578,6 @@ int main (int argc, char **argv) for (i=0; i < nr_tasks; i++) pthread_join(threads[i], (void*)&thread_pids[i]); - logdev_print_set(0); - logdev_switch_set(0); - print_results(); if (stop) { -- cgit 1.2.3-korg From 9eef81de2f8a0b16e183070a1ff7d1580d650fb3 Mon Sep 17 00:00:00 2001 From: John Kacur Date: Wed, 21 Mar 2012 22:29:43 +0100 Subject: pi_stress: Check the status of sched_getaffinity Check the status of sched_getaffinity and exit upon error. CPU_ISSET only checks whether a cpu is in a mask, and not whether the mask is valid. Checking the status ensures we aren't working with garbage values. This also removes the warning from gcc about the status variable being unused as reported by Darren Hart. Reported-by: Darren Hart Signed-off-by: John Kacur --- src/pi_tests/pi_stress.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/pi_tests/pi_stress.c b/src/pi_tests/pi_stress.c index 0940567..e273d62 100644 --- a/src/pi_tests/pi_stress.c +++ b/src/pi_tests/pi_stress.c @@ -597,9 +597,17 @@ void *reporter(void *arg) int verify_cpu(int cpu) { int status; + int err; cpu_set_t mask; + CPU_ZERO(&mask); + status = sched_getaffinity(0, sizeof(cpu_set_t), &mask); + if (status == -1) { + err = errno; + fprintf(stderr, "sched_getaffinity %s\n", strerror(err)); + exit(-1); + } if (CPU_ISSET(cpu, &mask)) return SUCCESS; -- cgit 1.2.3-korg From d276bb4b2d75f847fc1719b8d42f12930ad3b2d2 Mon Sep 17 00:00:00 2001 From: Darren Hart Date: Tue, 20 Mar 2012 12:05:01 -0700 Subject: Makefile: Support user supplied CFLAGS and LDFLAGS Accept user supplied CFLAGS and LDFLAGS, overwriting the Makefile supplied versions. This can cause the build to fail if the user does not provide at least what the Makefile defines, but so be it. Signed-off-by: Darren Hart CC: Clark Williams CC: John Kacur CC: Denys Dmytriyenko Signed-off-by: John Kacur --- Makefile | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 4038dcc..e1edf6c 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,8 @@ ifneq ($(filter x86_64 i386 ia64 mips powerpc,$(machinetype)),) NUMA := 1 endif -CFLAGS = -D_GNU_SOURCE -Wall -Wno-nonnull -Isrc/include +CFLAGS ?= -D_GNU_SOURCE -Wall -Wno-nonnull -Isrc/include +LDFLAGS ?= PYLIB := $(shell python -c 'import distutils.sysconfig; print distutils.sysconfig.get_python_lib()') @@ -61,41 +62,41 @@ all: $(TARGETS) hwlatdetect -include $(sources:.c=.d) cyclictest: cyclictest.o rt-utils.o - $(CC) $(CFLAGS) -o $@ $^ $(LIBS) $(NUMA_LIBS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(NUMA_LIBS) signaltest: signaltest.o rt-utils.o - $(CC) $(CFLAGS) -o $@ $^ $(LIBS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) pi_stress: pi_stress.o - $(CC) $(CFLAGS) -o $@ $^ $(LIBS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) hwlatdetect: src/hwlatdetect/hwlatdetect.py chmod +x src/hwlatdetect/hwlatdetect.py ln -s src/hwlatdetect/hwlatdetect.py hwlatdetect rt-migrate-test: rt-migrate-test.o - $(CC) $(CFLAGS) -o $@ $^ $(LIBS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) ptsematest: ptsematest.o rt-utils.o rt-get_cpu.o - $(CC) $(CFLAGS) -o $@ $^ $(LIBS) $(EXTRA_LIBS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(EXTRA_LIBS) sigwaittest: sigwaittest.o rt-utils.o rt-get_cpu.o - $(CC) $(CFLAGS) -o $@ $^ $(LIBS) $(EXTRA_LIBS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(EXTRA_LIBS) svsematest: svsematest.o rt-utils.o rt-get_cpu.o - $(CC) $(CFLAGS) -o $@ $^ $(LIBS) $(EXTRA_LIBS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(EXTRA_LIBS) pmqtest: pmqtest.o rt-utils.o rt-get_cpu.o - $(CC) $(CFLAGS) -o $@ $^ $(LIBS) $(EXTRA_LIBS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(EXTRA_LIBS) sendme: sendme.o rt-utils.o rt-get_cpu.o - $(CC) $(CFLAGS) -o $@ $^ $(LIBS) $(EXTRA_LIBS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(EXTRA_LIBS) pip_stress: pip_stress.o error.o rt-utils.o - $(CC) $(CFLAGS) -o $@ $^ $(LIBS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) hackbench: hackbench.o - $(CC) $(CFLAGS) -o $@ $^ $(LIBS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) CLEANUP = $(TARGETS) *.o .depend *.*~ *.orig *.rej rt-tests.spec *.d CLEANUP += $(if $(wildcard .git), ChangeLog) -- cgit 1.2.3-korg From fb7ef61416b6b191a5186a715e51792847de883c Mon Sep 17 00:00:00 2001 From: John Kacur Date: Thu, 22 Mar 2012 00:53:26 +0100 Subject: Makefile: Introduce a static library Introduce a static libray. Currently it contains the functions in rt-utils.c error.c and rt-get_cpu.c Signed-off-by: John Kacur --- Makefile | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index e1edf6c..ff697ca 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ sources = cyclictest.c signaltest.c pi_stress.c rt-migrate-test.c \ TARGETS = $(sources:.c=) -LIBS = -lrt -lpthread +LIBS = -lrt -lpthread -lrttest -L. EXTRA_LIBS ?= -ldl # for get_cpu DESTDIR ?= prefix ?= /usr/local @@ -61,10 +61,10 @@ all: $(TARGETS) hwlatdetect # Include dependency files, automatically generate them if needed. -include $(sources:.c=.d) -cyclictest: cyclictest.o rt-utils.o +cyclictest: cyclictest.o librttest.a $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(NUMA_LIBS) -signaltest: signaltest.o rt-utils.o +signaltest: signaltest.o librttest.a $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) pi_stress: pi_stress.o @@ -77,28 +77,31 @@ hwlatdetect: src/hwlatdetect/hwlatdetect.py rt-migrate-test: rt-migrate-test.o $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) -ptsematest: ptsematest.o rt-utils.o rt-get_cpu.o +ptsematest: ptsematest.o librttest.a $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(EXTRA_LIBS) -sigwaittest: sigwaittest.o rt-utils.o rt-get_cpu.o +sigwaittest: sigwaittest.o librttest.a $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(EXTRA_LIBS) -svsematest: svsematest.o rt-utils.o rt-get_cpu.o +svsematest: svsematest.o librttest.a $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(EXTRA_LIBS) -pmqtest: pmqtest.o rt-utils.o rt-get_cpu.o +pmqtest: pmqtest.o librttest.a $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(EXTRA_LIBS) -sendme: sendme.o rt-utils.o rt-get_cpu.o +sendme: sendme.o librttest.a $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(EXTRA_LIBS) -pip_stress: pip_stress.o error.o rt-utils.o +pip_stress: pip_stress.o librttest.a $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) hackbench: hackbench.o $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) -CLEANUP = $(TARGETS) *.o .depend *.*~ *.orig *.rej rt-tests.spec *.d +librttest.a: rt-utils.o error.o rt-get_cpu.o + $(AR) rcs librttest.a rt-utils.o error.o rt-get_cpu.o + +CLEANUP = $(TARGETS) *.o .depend *.*~ *.orig *.rej rt-tests.spec *.d *.a CLEANUP += $(if $(wildcard .git), ChangeLog) .PHONY: clean -- cgit 1.2.3-korg From 6f2665250edf49194a4b383d0897050ee57c760d Mon Sep 17 00:00:00 2001 From: John Kacur Date: Thu, 22 Mar 2012 01:19:40 +0100 Subject: Move info, warn, and fatal functions to error.[ch] Move warning, error and fatal function to the error files. This is a first step in cleaning up rt-tests. Signed-off-by: John Kacur --- src/cyclictest/rt_numa.h | 1 + src/include/error.h | 3 +++ src/include/rt-utils.h | 5 ----- src/lib/error.c | 31 +++++++++++++++++++++++++++++++ src/lib/rt-utils.c | 32 +------------------------------- src/pmqtest/pmqtest.c | 1 + src/ptsematest/ptsematest.c | 1 + src/svsematest/svsematest.c | 1 + 8 files changed, 39 insertions(+), 36 deletions(-) diff --git a/src/cyclictest/rt_numa.h b/src/cyclictest/rt_numa.h index 2b91615..4ae10ee 100644 --- a/src/cyclictest/rt_numa.h +++ b/src/cyclictest/rt_numa.h @@ -15,6 +15,7 @@ #define _RT_NUMA_H #include "rt-utils.h" +#include "error.h" static int numa = 0; diff --git a/src/include/error.h b/src/include/error.h index 512b3a6..1e33f6c 100644 --- a/src/include/error.h +++ b/src/include/error.h @@ -10,6 +10,9 @@ void err_exit(int err, char *fmt, ...); void err_msg(char *fmt, ...); void err_msg_n(int err, char *fmt, ...); void err_quit(char *fmt, ...); +void info(char *fmt, ...); +void warn(char *fmt, ...); +void fatal(char *fmt, ...); void err_doit(int err, const char *fmt, va_list ap); #endif /* __ERROR_H */ diff --git a/src/include/rt-utils.h b/src/include/rt-utils.h index 316b09c..4a7d01f 100644 --- a/src/include/rt-utils.h +++ b/src/include/rt-utils.h @@ -1,7 +1,6 @@ #ifndef __RT_UTILS_H #define __RT_UTILS_H - #define _STR(x) #x #define STR(x) _STR(x) #define MAX_PATH 256 @@ -18,8 +17,4 @@ int event_disable(char *event); int event_enable_all(void); int event_disable_all(void); -void warn(char *fmt, ...); -void fatal(char *fmt, ...); -void info(char *fmt, ...); - #endif /* __RT_UTILS.H */ diff --git a/src/lib/error.c b/src/lib/error.c index e9fe58f..1b5de5d 100644 --- a/src/lib/error.c +++ b/src/lib/error.c @@ -46,6 +46,37 @@ void err_quit(char *fmt, ...) exit(1); } +void info(char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + fputs("INFO: ", stderr); + err_doit(0, fmt, ap); + va_end(ap); +} + +void warn(char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + fputs("WARN: ", stderr); + err_doit(0, fmt, ap); + va_end(ap); +} + +void fatal(char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + fputs("FATAL: ", stderr); + err_doit(0, fmt, ap); + va_end(ap); + exit(EXIT_FAILURE); +} + void err_doit(int err, const char *fmt, va_list ap) { if (err) diff --git a/src/lib/rt-utils.c b/src/lib/rt-utils.c index ec71dbd..f4da4b3 100644 --- a/src/lib/rt-utils.c +++ b/src/lib/rt-utils.c @@ -17,6 +17,7 @@ #include #include #include "rt-utils.h" +#include "error.h" static char debugfileprefix[MAX_PATH]; @@ -272,34 +273,3 @@ int check_privs(void) return sched_setscheduler(0, policy, &old_param); } -void info(char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - fputs("INFO: ", stderr); - vfprintf(stderr, fmt, ap); - va_end(ap); -} - -void warn(char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - fputs("WARNING: ", stderr); - vfprintf(stderr, fmt, ap); - va_end(ap); -} - -void fatal(char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - fputs("FATAL: ", stderr); - vfprintf(stderr, fmt, ap); - va_end(ap); - exit(EXIT_FAILURE); -} - diff --git a/src/pmqtest/pmqtest.c b/src/pmqtest/pmqtest.c index 2ac6c55..b811d95 100644 --- a/src/pmqtest/pmqtest.c +++ b/src/pmqtest/pmqtest.c @@ -37,6 +37,7 @@ #include #include "rt-utils.h" #include "rt-get_cpu.h" +#include "error.h" #include diff --git a/src/ptsematest/ptsematest.c b/src/ptsematest/ptsematest.c index 14c3f81..92f0ab5 100644 --- a/src/ptsematest/ptsematest.c +++ b/src/ptsematest/ptsematest.c @@ -36,6 +36,7 @@ #include #include "rt-utils.h" #include "rt-get_cpu.h" +#include "error.h" #include diff --git a/src/svsematest/svsematest.c b/src/svsematest/svsematest.c index d4ee1c4..89473a5 100644 --- a/src/svsematest/svsematest.c +++ b/src/svsematest/svsematest.c @@ -42,6 +42,7 @@ #include #include "rt-utils.h" #include "rt-get_cpu.h" +#include "error.h" #define gettid() syscall(__NR_gettid) -- cgit 1.2.3-korg From 3ff3300ba0dd4027ec64c0ef0c00585e681a55ea Mon Sep 17 00:00:00 2001 From: John Kacur Date: Fri, 23 Mar 2012 02:07:16 +0100 Subject: install: Fix failed to create symbolic link hwlatdetect file exists The following build error can occur if you have done a previous make install if test -n "/usr/lib/python2.7/site-packages" ; then \ install -D -m 755 src/hwlatdetect/hwlatdetect.py /usr/lib/python2.7/site-packages/hwlatdetect.py ; \ ln -s /usr/lib/python2.7/site-packages/hwlatdetect.py "/usr/local/bin/hwlatdetect" ; \ fi ln: failed to create symbolic link `/usr/local/bin/hwlatdetect': File exists make: *** [install] Error 1 Fix the error by removing the symbolic link. Signed-off-by: John Kacur --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index ff697ca..31e1792 100644 --- a/Makefile +++ b/Makefile @@ -125,6 +125,7 @@ install: all cp $(TARGETS) "$(DESTDIR)$(bindir)" if test -n "$(PYLIB)" ; then \ install -D -m 755 src/hwlatdetect/hwlatdetect.py $(DESTDIR)$(PYLIB)/hwlatdetect.py ; \ + rm -f "$(DESTDIR)$(bindir)/hwlatdetect" ; \ ln -s $(PYLIB)/hwlatdetect.py "$(DESTDIR)$(bindir)/hwlatdetect" ; \ fi install -D -m 644 src/backfire/backfire.c "$(DESTDIR)$(srcdir)/backfire/backfire.c" -- cgit 1.2.3-korg