linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] *** Add a get_cpu() library ***
@ 2009-12-21 21:45 John Kacur
  2009-12-21 21:45 ` [PATCH 1/4] rt-tests: Makefile - Changes to unify and simplify the Makefile John Kacur
  2009-12-21 22:54 ` [PATCH 0/4] *** Add a get_cpu() library *** Clark Williams
  0 siblings, 2 replies; 10+ messages in thread
From: John Kacur @ 2009-12-21 21:45 UTC (permalink / raw)
  To: Clark Williams, Carsten Emde, Thomas Gleixner; +Cc: John Kacur, linux-rt-users

I have added a get_cpu() library which should just do the right thing for you
whether your system uses sched_getcpu() (the most common case), getcpu()
or the vsyscall version of getcpu().

I have tested on Fedora, RHEL5 both 32 and 64-bit versions which cover all of
the cases above. I would really appreciate more testing and reports on other
distributions. Of course comments and patches are also welcome.

While doing this I changed the Makefile quite extensively. I hope you will find
the changes simply and unify the Make process considerably. This could be
further improved too - for example by creating a build directory.

In addition to the changes below, Clark has fixed the odd CRLF issue, and
has a patch queued-up from Carsten that was missed last time.

Clark, you can pull the following changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/jkacur/rt-tests.git
branch: rt-tests-dev

Thanks

Carsten Emde (1):
  Completely remove VERSION_STRING until we have a better solution.

John Kacur (3):
  rt-tests: Makefile - Changes to unify and simplify the Makefile
  rt-tests: Add a get_cpu() function to the library.
  rt-tests: Clean-up - protect rt-utils.h

 Makefile                              |   53 ++++++++++++++++++++------------
 src/backfire/backfire.c               |    2 +-
 src/backfire/sendme.c                 |    9 +++--
 src/cyclictest/cyclictest.c           |    1 -
 src/lib/rt-get_cpu.c                  |   25 +++++++++++++++
 src/lib/rt-get_cpu.h                  |   46 ++++++++++++++++++++++++++++
 src/lib/rt-utils.h                    |    5 +++
 src/pi_tests/pi_stress.c              |    7 +---
 src/ptsematest/ptsematest.c           |   12 +++----
 src/rt-migrate-test/rt-migrate-test.c |    2 +-
 src/sigwaittest/sigwaittest.c         |    8 +++--
 src/svsematest/svsematest.c           |   31 ++++---------------
 12 files changed, 135 insertions(+), 66 deletions(-)
 create mode 100644 src/lib/rt-get_cpu.c
 create mode 100644 src/lib/rt-get_cpu.h


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/4] rt-tests: Makefile - Changes to unify and simplify the Makefile
  2009-12-21 21:45 [PATCH 0/4] *** Add a get_cpu() library *** John Kacur
@ 2009-12-21 21:45 ` John Kacur
  2009-12-21 21:45   ` [PATCH 2/4] rt-tests: Add a get_cpu() function to the library John Kacur
  2009-12-21 22:54 ` [PATCH 0/4] *** Add a get_cpu() library *** Clark Williams
  1 sibling, 1 reply; 10+ messages in thread
From: John Kacur @ 2009-12-21 21:45 UTC (permalink / raw)
  To: Clark Williams, Carsten Emde, Thomas Gleixner; +Cc: John Kacur, linux-rt-users

- These changes simplify the Makefile. For example, notice that we no
longer need to specify the full path to the source file
- These changes also unify the Makefile, for example, every program
gets VERSION_STRING as an floating point number.
- Due to the above change I had to make a number of changes in the programs
that expected VERSION_STRING as a string.
- By unifying what we CFLAGS, to include -D_GNU_SOURCE, I had to remove
__USE_GNU which is reduncant in a number of files.

Signed-off-by: John Kacur <jkacur@redhat.com>
---
 Makefile                              |   52 ++++++++++++++++++++------------
 src/backfire/sendme.c                 |    2 -
 src/cyclictest/cyclictest.c           |    1 -
 src/pi_tests/pi_stress.c              |    7 +---
 src/ptsematest/ptsematest.c           |    1 -
 src/rt-migrate-test/rt-migrate-test.c |    2 +-
 src/sigwaittest/sigwaittest.c         |    1 -
 src/svsematest/svsematest.c           |    1 -
 8 files changed, 35 insertions(+), 32 deletions(-)

diff --git a/Makefile b/Makefile
index 9a42532..4ca4470 100644
--- a/Makefile
+++ b/Makefile
@@ -10,48 +10,60 @@ bindir  ?= $(prefix)/bin
 mandir	?= $(prefix)/share/man
 srcdir	?= $(prefix)/src
 
-CFLAGS = -Wall -Wno-nonnull -Isrc/lib
+CFLAGS = -D_GNU_SOURCE -Wall -Wno-nonnull -Isrc/lib
+
 ifndef DEBUG
 	CFLAGS	+= -O2
 else
 	CFLAGS	+= -O0 -g
 endif
 
-UTILS	= src/lib/rt-utils.o
+VPATH	= src/cyclictest:
+VPATH	+= src/signaltest:
+VPATH	+= src/pi_tests:
+VPATH	+= src/rt-migrate-test:
+VPATH	+= src/ptsematest:
+VPATH	+= src/sigwaittest:
+VPATH	+= src/svsematest:
+VPATH	+= src/backfire:
+VPATH	+= src/lib
+
+%.o: %.c
+	$(CC) -D VERSION_STRING=$(VERSION_STRING) -c $< $(CFLAGS)
 
 .PHONY: all
 all: $(TARGETS)
 
-cyclictest: src/cyclictest/cyclictest.c $(UTILS)
-	$(CC) $(CFLAGS) -D VERSION_STRING=$(VERSION_STRING) $^ -o $@ $(LIBS)
+cyclictest: cyclictest.o rt-utils.o
+	$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
 
-signaltest: src/signaltest/signaltest.c $(UTILS)
-	$(CC) $(CFLAGS) -D VERSION_STRING=$(VERSION_STRING) $^ -o $@ $(LIBS)
+signaltest: signaltest.o rt-utils.o
+	$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
 
-classic_pi: src/pi_tests/classic_pi.c
-	$(CC) $(CFLAGS) -D_GNU_SOURCE -D VERSION_STRING=\"$(VERSION_STRING)\" $^ -o $@ $(LIBS)
+classic_pi: classic_pi.o
+	$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
 
-pi_stress:  src/pi_tests/pi_stress.c
-	$(CC) $(CFLAGS) -D_GNU_SOURCE -D VERSION_STRING=\"$(VERSION_STRING)\" $^ -o $@ $(LIBS)
+pi_stress: pi_stress.o
+	$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
 
 hwlatdetect:  src/hwlatdetect/hwlatdetect.py
 	chmod +x src/hwlatdetect/hwlatdetect.py
 	ln -s src/hwlatdetect/hwlatdetect.py hwlatdetect
 
-rt-migrate-test: src/rt-migrate-test/rt-migrate-test.c
-	$(CC) $(CFLAGS) -D_GNU_SOURCE -D VERSION_STRING=\"$(VERSION_STRING)\" $^ -o $@ $(LIBS)
+rt-migrate-test: rt-migrate-test.o
+	$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
 
-ptsematest: src/ptsematest/ptsematest.c $(UTILS)
-	$(CC) $(CFLAGS) -D VERSION_STRING=$(VERSION_STRING) $^ -o $@ $(LIBS)
+ptsematest: ptsematest.o rt-utils.o
+	$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
 
-sigwaittest: src/sigwaittest/sigwaittest.c $(UTILS)
-	$(CC) $(CFLAGS) -D VERSION_STRING=$(VERSION_STRING) $^ -o $@ $(LIBS)
+sigwaittest: sigwaittest.o rt-utils.o
+	$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
 
-svsematest: src/svsematest/svsematest.c $(UTILS)
-	$(CC) $(CFLAGS) -D VERSION_STRING=$(VERSION_STRING) $^ -o $@ $(LIBS)
+svsematest: svsematest.o rt-utils.o
+	$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
 
-sendme: src/backfire/sendme.c $(UTILS)
-	$(CC) $(CFLAGS) -D VERSION_STRING=$(VERSION_STRING) $^ -o $@ $(LIBS)
+sendme: sendme.o rt-utils.o
+	$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
 
 CLEANUP  = $(TARGETS) *.o .depend *.*~ *.orig *.rej rt-tests.spec
 CLEANUP += $(if $(wildcard .git), ChangeLog)
diff --git a/src/backfire/sendme.c b/src/backfire/sendme.c
index 3736ddb..8621a9e 100644
--- a/src/backfire/sendme.c
+++ b/src/backfire/sendme.c
@@ -22,7 +22,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <limits.h>
-#define __USE_GNU
 #include <fcntl.h>
 #include <getopt.h>
 #include <signal.h>
@@ -31,7 +30,6 @@
 #include <time.h>
 #include "rt-utils.h"
 
-#define _GNU_SOURCE
 #include <utmpx.h>
 #include <sys/types.h>
 #include <sys/stat.h>
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 811ce9f..20251a0 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -13,7 +13,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
-#define __USE_GNU
 #include <fcntl.h>
 #include <getopt.h>
 #include <pthread.h>
diff --git a/src/pi_tests/pi_stress.c b/src/pi_tests/pi_stress.c
index 89a749c..0940567 100644
--- a/src/pi_tests/pi_stress.c
+++ b/src/pi_tests/pi_stress.c
@@ -55,10 +55,6 @@
 #include <sys/wait.h>
 #include <termios.h>
 
-/* version */
-const char *version =
-    "pi_stress v" VERSION_STRING " (" __DATE__ " " __TIME__ ")";
-
 /* conversions */
 #define USEC_PER_SEC 	1000000
 #define NSEC_PER_SEC 	1000000000
@@ -1230,7 +1226,8 @@ void process_command_line(int argc, char **argv)
 			debugging = 1;
 			break;
 		case 'V':
-			puts(version);
+			printf("pi_stress v%1.2f ", VERSION_STRING);
+			printf("(%s %s)\n", __DATE__, __TIME__);
 			exit(0);
 		case 'u':
 			uniprocessor = 1;
diff --git a/src/ptsematest/ptsematest.c b/src/ptsematest/ptsematest.c
index aaae92a..2d19364 100644
--- a/src/ptsematest/ptsematest.c
+++ b/src/ptsematest/ptsematest.c
@@ -36,7 +36,6 @@
 #include <utmpx.h>
 #include "rt-utils.h"
 
-#define __USE_GNU
 #include <pthread.h>
 
 #define gettid() syscall(__NR_gettid)
diff --git a/src/rt-migrate-test/rt-migrate-test.c b/src/rt-migrate-test/rt-migrate-test.c
index e22d188..1963641 100644
--- a/src/rt-migrate-test/rt-migrate-test.c
+++ b/src/rt-migrate-test/rt-migrate-test.c
@@ -162,7 +162,7 @@ static void usage(char **argv)
 		p--;
 	p++;
 
-	printf("%s %s\n", p, VERSION_STRING);
+	printf("%s %1.2f\n", p, VERSION_STRING);
 	printf("Usage:\n"
 	       "%s <options> nr_tasks\n\n"
 	       "-p prio --prio  prio        base priority to start RT tasks with (2) \n"
diff --git a/src/sigwaittest/sigwaittest.c b/src/sigwaittest/sigwaittest.c
index adb51cf..3c5aacf 100644
--- a/src/sigwaittest/sigwaittest.c
+++ b/src/sigwaittest/sigwaittest.c
@@ -38,7 +38,6 @@
 #include <utmpx.h>
 #include "rt-utils.h"
 
-#define __USE_GNU
 #include <pthread.h>
 
 #define gettid() syscall(__NR_gettid)
diff --git a/src/svsematest/svsematest.c b/src/svsematest/svsematest.c
index 50224de..ead78c7 100644
--- a/src/svsematest/svsematest.c
+++ b/src/svsematest/svsematest.c
@@ -24,7 +24,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <limits.h>
-#define __USE_GNU
 #include <fcntl.h>
 #include <getopt.h>
 #include <pthread.h>
-- 
1.6.5.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/4] rt-tests: Add a get_cpu() function to the library.
  2009-12-21 21:45 ` [PATCH 1/4] rt-tests: Makefile - Changes to unify and simplify the Makefile John Kacur
@ 2009-12-21 21:45   ` John Kacur
  2009-12-21 21:45     ` [PATCH 3/4] rt-tests: Clean-up - protect rt-utils.h John Kacur
  0 siblings, 1 reply; 10+ messages in thread
From: John Kacur @ 2009-12-21 21:45 UTC (permalink / raw)
  To: Clark Williams, Carsten Emde, Thomas Gleixner; +Cc: John Kacur, linux-rt-users

Add a get_cpu() function to the library.
Most platforms will simply use sched_getcpu()
However, if you have a glibc < 2.6 then
64-bits will use vsyscall for getcpu (if available).
32-bits will use getcpu() (if available)

Signed-off-by: John Kacur <jkacur@redhat.com>
---
 Makefile                      |   17 ++++++++-------
 src/backfire/sendme.c         |    7 ++++-
 src/lib/rt-get_cpu.c          |   25 ++++++++++++++++++++++
 src/lib/rt-get_cpu.h          |   46 +++++++++++++++++++++++++++++++++++++++++
 src/ptsematest/ptsematest.c   |   11 ++++-----
 src/sigwaittest/sigwaittest.c |    7 ++++-
 src/svsematest/svsematest.c   |   30 ++++++--------------------
 7 files changed, 102 insertions(+), 41 deletions(-)
 create mode 100644 src/lib/rt-get_cpu.c
 create mode 100644 src/lib/rt-get_cpu.h

diff --git a/Makefile b/Makefile
index 4ca4470..aa95e78 100644
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,7 @@ TARGETS	= cyclictest signaltest classic_pi pi_stress \
 	  hwlatdetect rt-migrate-test ptsematest sigwaittest svsematest \
 	  sendme
 LIBS 	= -lpthread -lrt
+EXTRA_LIBS ?= -ldl	# for get_cpu
 DESTDIR	?=
 prefix  ?= /usr/local
 bindir  ?= $(prefix)/bin
@@ -53,17 +54,17 @@ hwlatdetect:  src/hwlatdetect/hwlatdetect.py
 rt-migrate-test: rt-migrate-test.o
 	$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
 
-ptsematest: ptsematest.o rt-utils.o
-	$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
+ptsematest: ptsematest.o rt-utils.o rt-get_cpu.o
+	$(CC) $(CFLAGS) -o $@ $^ $(LIBS) $(EXTRA_LIBS)
 
-sigwaittest: sigwaittest.o rt-utils.o
-	$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
+sigwaittest: sigwaittest.o rt-utils.o rt-get_cpu.o
+	$(CC) $(CFLAGS) -o $@ $^ $(LIBS) $(EXTRA_LIBS)
 
-svsematest: svsematest.o rt-utils.o
-	$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
+svsematest: svsematest.o rt-utils.o rt-get_cpu.o
+	$(CC) $(CFLAGS) -o $@ $^ $(LIBS) $(EXTRA_LIBS)
 
-sendme: sendme.o rt-utils.o
-	$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
+sendme: sendme.o rt-utils.o rt-get_cpu.o
+	$(CC) $(CFLAGS) -o $@ $^ $(LIBS) $(EXTRA_LIBS)
 
 CLEANUP  = $(TARGETS) *.o .depend *.*~ *.orig *.rej rt-tests.spec
 CLEANUP += $(if $(wildcard .git), ChangeLog)
diff --git a/src/backfire/sendme.c b/src/backfire/sendme.c
index 8621a9e..fdc1056 100644
--- a/src/backfire/sendme.c
+++ b/src/backfire/sendme.c
@@ -29,6 +29,7 @@
 #include <string.h>
 #include <time.h>
 #include "rt-utils.h"
+#include "rt-get_cpu.h"
 
 #include <utmpx.h>
 #include <sys/types.h>
@@ -195,8 +196,10 @@ int main(int argc, char *argv[])
 
 	if (setaffinity != AFFINITY_UNSPECIFIED) {
 		CPU_ZERO(&mask);
-		if (setaffinity == AFFINITY_USECURRENT)
-			affinity = sched_getcpu();
+		if (setaffinity == AFFINITY_USECURRENT) {
+			get_cpu_setup();
+			affinity = get_cpu();
+		}
 		CPU_SET(affinity, &mask);
 		if (sched_setaffinity(0, sizeof(mask), &mask) == -1)
 			fprintf(stderr,	"WARNING: Could not set CPU affinity "
diff --git a/src/lib/rt-get_cpu.c b/src/lib/rt-get_cpu.c
new file mode 100644
index 0000000..6ebda90
--- /dev/null
+++ b/src/lib/rt-get_cpu.c
@@ -0,0 +1,25 @@
+#include "rt-get_cpu.h"
+#ifdef __NR_getcpu
+#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__)	\
+	&& __GLIBC__>=2 && __GLIBC_MINOR__>=6
+#else
+int (*get_cpu)(void);
+int (*get_cpu_vdsop)(unsigned int *, unsigned int *, void *);
+
+int get_cpu_setup(void)
+{
+	void *handle = dlopen("linux-vdso.so.1", RTLD_LAZY);
+	get_cpu_vdsop = NULL;
+	if (handle) {
+		get_cpu_vdsop = dlsym(handle, "getcpu");
+		dlclose(handle);
+		if (get_cpu_vdsop) {
+			get_cpu = getcpu_vdso;
+			return 0;
+		}
+	}
+	return -1;
+}
+
+#endif
+
diff --git a/src/lib/rt-get_cpu.h b/src/lib/rt-get_cpu.h
new file mode 100644
index 0000000..68ac17a
--- /dev/null
+++ b/src/lib/rt-get_cpu.h
@@ -0,0 +1,46 @@
+#ifndef RT_GET_CPU_H
+#define RT_GET_CPU_H
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/syscall.h>   /* For SYS_xxx definitions */
+#include <sched.h>
+#include <dlfcn.h>
+#ifdef __NR_getcpu
+static inline int get_cpu_setup(void) { return 0; }
+static inline int get_cpu(void)
+{
+        int c,s;
+	/* Show the source of get_cpu */
+#ifdef DEBUG
+	fprintf(stderr, "__NR_getcpu\n");
+#endif
+        s = syscall(__NR_getcpu, &c, NULL, NULL);
+        return (s == -1) ? s : c;
+}
+#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__)	\
+	&& __GLIBC__>=2 && __GLIBC_MINOR__>=6
+#include <utmpx.h>
+static inline int get_cpu_setup(void) { return 0; }
+static inline int get_cpu(void) { return sched_getcpu(); }
+#else
+extern int get_cpu_setup(void);
+extern int (*get_cpu)(void);
+extern int (*get_cpu_vdsop)(unsigned int *, unsigned int *, void *);
+
+static inline int getcpu_vdso(void)
+{
+	unsigned int c,s;
+	/* Show the source of get_cpu */
+#ifdef DEBUG
+	fprintf(stderr, "getcpu_vdso\n");
+#endif
+	s = get_cpu_vdsop(&c, NULL, NULL);
+        return (s == -1) ? s : c;
+}
+
+#endif
+
+#endif	/* RT_GET_CPU_H */
+
diff --git a/src/ptsematest/ptsematest.c b/src/ptsematest/ptsematest.c
index 2d19364..2683a2e 100644
--- a/src/ptsematest/ptsematest.c
+++ b/src/ptsematest/ptsematest.c
@@ -35,6 +35,7 @@
 #include <linux/unistd.h>
 #include <utmpx.h>
 #include "rt-utils.h"
+#include "rt-get_cpu.h"
 
 #include <pthread.h>
 
@@ -106,9 +107,8 @@ void *semathread(void *param)
 			par->samples++;
 			if(par->max_cycles && par->samples >= par->max_cycles)
 				par->shutdown = 1;
-			if (mustgetcpu) {
-				par->cpu = sched_getcpu();
-			}
+			if (mustgetcpu)
+				par->cpu = get_cpu();
 		} else {
 			/* Receiver */
 			if (!first) {
@@ -148,9 +148,8 @@ void *semathread(void *param)
 
 			if (par->max_cycles && par->samples >= par->max_cycles)
 				par->shutdown = 1;
-			if (mustgetcpu) {
-				par->cpu = sched_getcpu();
-		        }
+			if (mustgetcpu)
+				par->cpu = get_cpu();
 			nanosleep(&par->delay, NULL);
 			pthread_mutex_unlock(&syncmutex[par->num]);
 		}
diff --git a/src/sigwaittest/sigwaittest.c b/src/sigwaittest/sigwaittest.c
index 3c5aacf..1948d76 100644
--- a/src/sigwaittest/sigwaittest.c
+++ b/src/sigwaittest/sigwaittest.c
@@ -37,6 +37,7 @@
 #include <linux/unistd.h>
 #include <utmpx.h>
 #include "rt-utils.h"
+#include "rt-get_cpu.h"
 
 #include <pthread.h>
 
@@ -138,7 +139,7 @@ void *semathread(void *param)
 				par->shutdown = 1;
 
 			if (mustgetcpu) {
-				par->cpu = sched_getcpu();
+				par->cpu = get_cpu();
 			}
 			sigwait(&sigset, &sig);
 		} else {
@@ -162,7 +163,7 @@ void *semathread(void *param)
 				par->shutdown = 1;
 
 			if (mustgetcpu) {
-				par->cpu = sched_getcpu();
+				par->cpu = get_cpu();
 		        }
 			/*
 			 * Latency is the time spent between sending and
@@ -358,6 +359,8 @@ int main(int argc, char *argv[])
 		return 1;
 	}
 
+	get_cpu_setup();	/* init get_cpu() */
+
 	if (mustfork) {
 		int shmem;
 
diff --git a/src/svsematest/svsematest.c b/src/svsematest/svsematest.c
index ead78c7..a9f8f53 100644
--- a/src/svsematest/svsematest.c
+++ b/src/svsematest/svsematest.c
@@ -41,13 +41,9 @@
 #include <sys/time.h>
 #include <sys/mman.h>
 #include "rt-utils.h"
-
-#define HAS_SCHED_GETCPU
+#include "rt-get_cpu.h"
 
 #define gettid() syscall(__NR_gettid)
-#ifndef HAS_SCHED_GETCPU
-#define getcpu(cpu, node, cache) syscall(__NR_getcpu, cpu, node, cache)
-#endif
 
 #define USEC_PER_SEC 1000000
 
@@ -143,15 +139,8 @@ void *semathread(void *param)
 			if(par->max_cycles && par->samples >= par->max_cycles)
 				par->shutdown = 1;
 
-			if (mustgetcpu) {
-#ifdef HAS_SCHED_GETCPU
-				par->cpu = sched_getcpu();
-#else
-				int c, s;
-	                        s = getcpu(&c, NULL, NULL);
-			        par->cpu = (s == -1) ? s : c;
-#endif
-			}
+			if (mustgetcpu)
+				par->cpu = get_cpu();
 
  			sb.sem_num = SEM_WAIT_FOR_RECEIVER;
  			sb.sem_op = SEM_LOCK;
@@ -182,15 +171,8 @@ void *semathread(void *param)
 			if (par->max_cycles && par->samples >= par->max_cycles)
 				par->shutdown = 1;
 
-			if (mustgetcpu) {
-#ifdef HAS_SCHED_GETCPU
-				par->cpu = sched_getcpu();
-#else
-				int c, s;
-	                        s = getcpu(&c, NULL, NULL);
-			        par->cpu = (s == -1) ? s : c;
-#endif
-			}
+			if (mustgetcpu)
+				par->cpu = get_cpu();
 
 			timersub(&par->received, &neighbor->unblocked,
 			    &par->diff);
@@ -408,6 +390,8 @@ int main(int argc, char *argv[])
 		return 1;
 	}
 
+	get_cpu_setup();
+
 	if (mustfork) {
 		int shmem;
 
-- 
1.6.5.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/4] rt-tests: Clean-up - protect rt-utils.h
  2009-12-21 21:45   ` [PATCH 2/4] rt-tests: Add a get_cpu() function to the library John Kacur
@ 2009-12-21 21:45     ` John Kacur
  2009-12-21 21:45       ` [PATCH 4/4] Completely remove VERSION_STRING until we have a better solution John Kacur
  2009-12-21 23:09       ` [PATCH 3/4] rt-tests: Clean-up - protect rt-utils.h Carsten Emde
  0 siblings, 2 replies; 10+ messages in thread
From: John Kacur @ 2009-12-21 21:45 UTC (permalink / raw)
  To: Clark Williams, Carsten Emde, Thomas Gleixner; +Cc: John Kacur, linux-rt-users

Clean-up: Protect rt-utils.h with #ifndef RT_UTILS_H

Signed-off-by: John Kacur <jkacur@redhat.com>
---
 src/lib/rt-utils.h |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/lib/rt-utils.h b/src/lib/rt-utils.h
index e9c8cdd..fbdcf2b 100644
--- a/src/lib/rt-utils.h
+++ b/src/lib/rt-utils.h
@@ -1,6 +1,11 @@
+#ifndef RT_UTILS.H
+#define RT_UTILS.H
+
 #define _STR(x) #x
 #define STR(x) _STR(x)
 #define MAX_PATH 256
 
 int check_privs(void);
 char *get_debugfileprefix(void);
+
+#endif	/* RT_UTILS.H */
-- 
1.6.5.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/4] Completely remove VERSION_STRING until we have a better solution.
  2009-12-21 21:45     ` [PATCH 3/4] rt-tests: Clean-up - protect rt-utils.h John Kacur
@ 2009-12-21 21:45       ` John Kacur
  2009-12-21 23:09       ` [PATCH 3/4] rt-tests: Clean-up - protect rt-utils.h Carsten Emde
  1 sibling, 0 replies; 10+ messages in thread
From: John Kacur @ 2009-12-21 21:45 UTC (permalink / raw)
  To: Clark Williams, Carsten Emde, Thomas Gleixner
  Cc: Carsten Emde, linux-rt-users, John Kacur

From: Carsten Emde <C.Emde@osadl.org>

Signed-off-by: Carsten Emde <C.Emde@osadl.org>
Signed-off-by: John Kacur <jkacur@redhat.com>
---
 src/backfire/backfire.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/backfire/backfire.c b/src/backfire/backfire.c
index d737347..aaf9c4a 100644
--- a/src/backfire/backfire.c
+++ b/src/backfire/backfire.c
@@ -132,7 +132,7 @@ static int __init backfire_init(void)
 	if (ret)
 		printk(KERN_ERR "backfire: can't register dynamic misc device\n");
 	else
-		printk(KERN_INFO "backfire driver v__VERSION_STRING__ misc device %d\n",
+		printk(KERN_INFO "backfire driver misc device %d\n",
 			backfire_dev.minor);
 	return ret;
 }
-- 
1.6.5.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/4] *** Add a get_cpu() library ***
  2009-12-21 21:45 [PATCH 0/4] *** Add a get_cpu() library *** John Kacur
  2009-12-21 21:45 ` [PATCH 1/4] rt-tests: Makefile - Changes to unify and simplify the Makefile John Kacur
@ 2009-12-21 22:54 ` Clark Williams
  1 sibling, 0 replies; 10+ messages in thread
From: Clark Williams @ 2009-12-21 22:54 UTC (permalink / raw)
  To: John Kacur; +Cc: Carsten Emde, Thomas Gleixner, John Kacur, linux-rt-users

[-- Attachment #1: Type: text/plain, Size: 1322 bytes --]

On Mon, 21 Dec 2009 22:45:46 +0100
John Kacur <jkacur@redhat.com> wrote:

> I have added a get_cpu() library which should just do the right thing for you
> whether your system uses sched_getcpu() (the most common case), getcpu()
> or the vsyscall version of getcpu().
> 
> I have tested on Fedora, RHEL5 both 32 and 64-bit versions which cover all of
> the cases above. I would really appreciate more testing and reports on other
> distributions. Of course comments and patches are also welcome.
> 
> While doing this I changed the Makefile quite extensively. I hope you will find
> the changes simply and unify the Make process considerably. This could be
> further improved too - for example by creating a build directory.
> 
> In addition to the changes below, Clark has fixed the odd CRLF issue, and
> has a patch queued-up from Carsten that was missed last time.
> 
> Clark, you can pull the following changes from:
> git://git.kernel.org/pub/scm/linux/kernel/git/jkacur/rt-tests.git
> branch: rt-tests-dev
> 

Pulled and merged.

Tarball rt-tests-0.58.tar.gz pushed to kernel.org:

http://www.kernel.org/pub/linux//kernel/people/clrkwllms/rt-tests/rt-tests-0.58.tar.gz

Git tree updated with tag v0.58:

git://git.kernel.org/pub/scm/linux/kernel/git/clrkwllms/rt-tests.git


Clark

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/4] rt-tests: Clean-up - protect rt-utils.h
  2009-12-21 21:45     ` [PATCH 3/4] rt-tests: Clean-up - protect rt-utils.h John Kacur
  2009-12-21 21:45       ` [PATCH 4/4] Completely remove VERSION_STRING until we have a better solution John Kacur
@ 2009-12-21 23:09       ` Carsten Emde
  2009-12-21 23:19         ` Clark Williams
  2009-12-21 23:41         ` John Kacur
  1 sibling, 2 replies; 10+ messages in thread
From: Carsten Emde @ 2009-12-21 23:09 UTC (permalink / raw)
  To: John Kacur; +Cc: Clark Williams, Thomas Gleixner, linux-rt-users

On 12/21/2009 10:45 PM, John Kacur wrote:
> Clean-up: Protect rt-utils.h with #ifndef RT_UTILS_H
> [..]
> +#ifndef RT_UTILS.H
Macro names should only consist of alphanumeric characters and
underscores, i.e. 'a-z', 'A-Z', '0-9', and '_', and the first character
should not be a digit.

Signed-off-by: Carsten Emde <C.Emde@osadl.org>

diff --git a/src/lib/rt-utils.h b/src/lib/rt-utils.h
index fbdcf2b..e7a1908 100644
--- a/src/lib/rt-utils.h
+++ b/src/lib/rt-utils.h
@@ -1,5 +1,5 @@
-#ifndef RT_UTILS.H
-#define RT_UTILS.H
+#ifndef RT_UTILS_H
+#define RT_UTILS_H

 #define _STR(x) #x
 #define STR(x) _STR(x)
@@ -8,4 +8,4 @@
 int check_privs(void);
 char *get_debugfileprefix(void);

-#endif /* RT_UTILS.H */
+#endif /* RT_UTILS_H */

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/4] rt-tests: Clean-up - protect rt-utils.h
  2009-12-21 23:09       ` [PATCH 3/4] rt-tests: Clean-up - protect rt-utils.h Carsten Emde
@ 2009-12-21 23:19         ` Clark Williams
  2009-12-21 23:43           ` Carsten Emde
  2009-12-21 23:41         ` John Kacur
  1 sibling, 1 reply; 10+ messages in thread
From: Clark Williams @ 2009-12-21 23:19 UTC (permalink / raw)
  To: Carsten Emde; +Cc: John Kacur, Thomas Gleixner, linux-rt-users

[-- Attachment #1: Type: text/plain, Size: 509 bytes --]

On Tue, 22 Dec 2009 00:09:35 +0100
Carsten Emde <Carsten.Emde@osadl.org> wrote:

> On 12/21/2009 10:45 PM, John Kacur wrote:
> > Clean-up: Protect rt-utils.h with #ifndef RT_UTILS_H
> > [..]
> > +#ifndef RT_UTILS.H
> Macro names should only consist of alphanumeric characters and
> underscores, i.e. 'a-z', 'A-Z', '0-9', and '_', and the first character
> should not be a digit.
> 
>

Yeah, I caught that and also pushed it out of application name space
with two leading underscores. 

Clark

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/4] rt-tests: Clean-up - protect rt-utils.h
  2009-12-21 23:09       ` [PATCH 3/4] rt-tests: Clean-up - protect rt-utils.h Carsten Emde
  2009-12-21 23:19         ` Clark Williams
@ 2009-12-21 23:41         ` John Kacur
  1 sibling, 0 replies; 10+ messages in thread
From: John Kacur @ 2009-12-21 23:41 UTC (permalink / raw)
  To: Carsten Emde; +Cc: Clark Williams, Thomas Gleixner, linux-rt-users

On Tue, Dec 22, 2009 at 12:09 AM, Carsten Emde <Carsten.Emde@osadl.org> wrote:
> On 12/21/2009 10:45 PM, John Kacur wrote:
>> Clean-up: Protect rt-utils.h with #ifndef RT_UTILS_H
>> [..]
>> +#ifndef RT_UTILS.H
> Macro names should only consist of alphanumeric characters and
> underscores, i.e. 'a-z', 'A-Z', '0-9', and '_', and the first character
> should not be a digit.
>
> Signed-off-by: Carsten Emde <C.Emde@osadl.org>
>
> diff --git a/src/lib/rt-utils.h b/src/lib/rt-utils.h
> index fbdcf2b..e7a1908 100644
> --- a/src/lib/rt-utils.h
> +++ b/src/lib/rt-utils.h
> @@ -1,5 +1,5 @@
> -#ifndef RT_UTILS.H
> -#define RT_UTILS.H
> +#ifndef RT_UTILS_H
> +#define RT_UTILS_H
>
>  #define _STR(x) #x
>  #define STR(x) _STR(x)
> @@ -8,4 +8,4 @@
>  int check_privs(void);
>  char *get_debugfileprefix(void);
>
> -#endif /* RT_UTILS.H */
> +#endif /* RT_UTILS_H */
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

Thanks Carsten.

That was a good sign that I was getting tired! I think Clark already
fixed that up.

John
--
To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/4] rt-tests: Clean-up - protect rt-utils.h
  2009-12-21 23:19         ` Clark Williams
@ 2009-12-21 23:43           ` Carsten Emde
  0 siblings, 0 replies; 10+ messages in thread
From: Carsten Emde @ 2009-12-21 23:43 UTC (permalink / raw)
  To: Clark Williams; +Cc: John Kacur, Thomas Gleixner, linux-rt-users

[-- Attachment #1: Type: text/plain, Size: 781 bytes --]

Clark,

>>> Clean-up: Protect rt-utils.h with #ifndef RT_UTILS_H
>>> [..]
>>> +#ifndef RT_UTILS.H
>> Macro names should only consist of alphanumeric characters and
>> underscores, i.e. 'a-z', 'A-Z', '0-9', and '_', and the first character
>> should not be a digit.
> Yeah, I caught that and also pushed it out of application name space
> with two leading underscores. 
Great.

I did some first tests on 0.58, and all works very well now. Thanks a
lot, you and John, for all the work!

As a very minor issue, the below patch still didn't make it into your
tree.

	Carsten.

-=--------------------------------------------------------------------=-
Explain in the sendme error message how to make the backfire module,
if not available.

Signed-off-by: Carsten Emde <C.Emde@osadl.org>

[-- Attachment #2: explain-howto-make-backfire-module.patch --]
[-- Type: text/x-patch, Size: 657 bytes --]

diff --git a/src/backfire/sendme.c b/src/backfire/sendme.c
index fdc1056..1f02c72 100644
--- a/src/backfire/sendme.c
+++ b/src/backfire/sendme.c
@@ -209,7 +209,12 @@ int main(int argc, char *argv[])
 	path = open("/dev/backfire", O_RDWR);
 	if (path < 0) {
 		fprintf(stderr, "ERROR: Could not access backfire device, "
-				"try 'modprobe backfire'\n");
+				"try 'modprobe backfire'.\n"
+				"If the module backfire can't be loaded, "
+				"it may need to be built first.\n"
+				"Execute 'cd src/backfire; make' in the "
+				"rt-tests directory (requires rt-tests\n"
+				"sources and kernel-devel package).\n");
 		return 1;
 	}
 	fl.l_type = F_WRLCK;

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-12-21 23:49 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-21 21:45 [PATCH 0/4] *** Add a get_cpu() library *** John Kacur
2009-12-21 21:45 ` [PATCH 1/4] rt-tests: Makefile - Changes to unify and simplify the Makefile John Kacur
2009-12-21 21:45   ` [PATCH 2/4] rt-tests: Add a get_cpu() function to the library John Kacur
2009-12-21 21:45     ` [PATCH 3/4] rt-tests: Clean-up - protect rt-utils.h John Kacur
2009-12-21 21:45       ` [PATCH 4/4] Completely remove VERSION_STRING until we have a better solution John Kacur
2009-12-21 23:09       ` [PATCH 3/4] rt-tests: Clean-up - protect rt-utils.h Carsten Emde
2009-12-21 23:19         ` Clark Williams
2009-12-21 23:43           ` Carsten Emde
2009-12-21 23:41         ` John Kacur
2009-12-21 22:54 ` [PATCH 0/4] *** Add a get_cpu() library *** Clark Williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).