* [PATCH 0/5] rt-tests: rt_numa.h clean-ups, and dependency files
@ 2010-01-27 20:24 John Kacur
2010-01-27 20:24 ` [PATCH 1/5] rt-tests: Add header including copyright notice to rt_numa.h John Kacur
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: John Kacur @ 2010-01-27 20:24 UTC (permalink / raw)
To: Clark Williams
Cc: Thomas Gleixner, lkml, Ingo Molnar, Carsten Emde, rt-users,
John Kacur
This set of patches are mostly clean-up to our new rt_numa.h file.
We need to add a copyright notice in every file for some distributions.
This also creates some changes to simplify and clean-up
the differences between the code for the older LIBNUMA_API_VERSION and the
newer ones. (or at least I hope you will think so).
Finally there is a change to automatically generate dependencies for the
Makefile.
John Kacur (5):
rt-tests: Add header including copyright notice to rt_numa.h
rt-tests: Separate the #ifdef LIBNUMA_API_VERSION functions.
rt-tests: Remove the ret variable, the end label and the goto.
rt-tests: Fix some style problems, such as spaces instead of tabs.
rt-tests: Automatically generate dependencies.
Makefile | 20 ++++++++++++---
src/cyclictest/rt_numa.h | 58 ++++++++++++++++++++++++++++-----------------
2 files changed, 52 insertions(+), 26 deletions(-)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/5] rt-tests: Add header including copyright notice to rt_numa.h
2010-01-27 20:24 [PATCH 0/5] rt-tests: rt_numa.h clean-ups, and dependency files John Kacur
@ 2010-01-27 20:24 ` John Kacur
2010-01-27 20:24 ` [PATCH 2/5] rt-tests: Separate the #ifdef LIBNUMA_API_VERSION functions John Kacur
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: John Kacur @ 2010-01-27 20:24 UTC (permalink / raw)
To: Clark Williams
Cc: Thomas Gleixner, lkml, Ingo Molnar, Carsten Emde, rt-users,
John Kacur
Add a header which includes a copyright notice to rt_numa.h for cyclictest.
Signed-off-by: John Kacur <jkacur@redhat.com>
---
src/cyclictest/rt_numa.h | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/src/cyclictest/rt_numa.h b/src/cyclictest/rt_numa.h
index a0ebe7f..14837ff 100644
--- a/src/cyclictest/rt_numa.h
+++ b/src/cyclictest/rt_numa.h
@@ -1,3 +1,16 @@
+/*
+ * A numa library for cyclictest.
+ * The functions here are designed to work whether cyclictest has been
+ * compiled with numa support or not, and whether the user uses the --numa
+ * option or not.
+ * They should also work correctly with older versions of the numactl lib
+ * such as the one found on RHEL5, or with the newer version 2 and above.
+ *
+ * (C) 2010 John Kacur <jkacur@redhat.com>
+ * (C) 2010 Clark Williams <williams@redhat.com>
+ *
+ */
+
#ifndef _RT_NUMA_H
#define _RT_NUMA_H
--
1.6.6
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/5] rt-tests: Separate the #ifdef LIBNUMA_API_VERSION functions.
2010-01-27 20:24 [PATCH 0/5] rt-tests: rt_numa.h clean-ups, and dependency files John Kacur
2010-01-27 20:24 ` [PATCH 1/5] rt-tests: Add header including copyright notice to rt_numa.h John Kacur
@ 2010-01-27 20:24 ` John Kacur
2010-01-27 20:24 ` [PATCH 3/5] rt-tests: Remove the ret variable, the end label and the goto John Kacur
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: John Kacur @ 2010-01-27 20:24 UTC (permalink / raw)
To: Clark Williams
Cc: Thomas Gleixner, lkml, Ingo Molnar, Carsten Emde, rt-users,
John Kacur
Separate the #ifdef LIBNUMA_API_VERSION of function rt_numa_numa_node_of_cpu,
it is slightly cleaner this way.
Signed-off-by: John Kacur <jkacur@redhat.com>
---
src/cyclictest/rt_numa.h | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/cyclictest/rt_numa.h b/src/cyclictest/rt_numa.h
index 14837ff..8d44097 100644
--- a/src/cyclictest/rt_numa.h
+++ b/src/cyclictest/rt_numa.h
@@ -58,15 +58,20 @@ static void numa_on_and_available()
fatal("--numa specified and numa functions not available.\n");
}
+#if LIBNUMA_API_VERSION >= 2
static int rt_numa_numa_node_of_cpu(int cpu)
{
-#if LIBNUMA_API_VERSION >= 2
int node;
node = numa_node_of_cpu(cpu);
if (node == -1)
fatal("invalid cpu passed to numa_node_of_cpu(%d)\n", cpu);
return node;
-#else
+}
+
+#else /* LIBNUMA_API_VERSION == 1 */
+
+static int rt_numa_numa_node_of_cpu(int cpu)
+{
unsigned char cpumask[16];
int node, ret, idx, bit;
int max_node, max_cpus;
@@ -96,10 +101,10 @@ static int rt_numa_numa_node_of_cpu(int cpu)
errno = EINVAL;
end:
return ret;
-
-#endif
}
+#endif /* LIBNUMA_API_VERSION */
+
static void *rt_numa_numa_alloc_onnode(size_t size, int node, int cpu)
{
void *stack;
--
1.6.6
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/5] rt-tests: Remove the ret variable, the end label and the goto.
2010-01-27 20:24 [PATCH 0/5] rt-tests: rt_numa.h clean-ups, and dependency files John Kacur
2010-01-27 20:24 ` [PATCH 1/5] rt-tests: Add header including copyright notice to rt_numa.h John Kacur
2010-01-27 20:24 ` [PATCH 2/5] rt-tests: Separate the #ifdef LIBNUMA_API_VERSION functions John Kacur
@ 2010-01-27 20:24 ` John Kacur
2010-01-27 20:24 ` [PATCH 4/5] rt-tests: Fix some style problems, such as spaces instead of tabs John Kacur
2010-01-27 20:24 ` [PATCH 5/5] rt-tests: Automatically generate dependencies John Kacur
4 siblings, 0 replies; 6+ messages in thread
From: John Kacur @ 2010-01-27 20:24 UTC (permalink / raw)
To: Clark Williams
Cc: Thomas Gleixner, lkml, Ingo Molnar, Carsten Emde, rt-users,
John Kacur
Remove the ret variable, the end lable and the goto. We already have
inconsistent exit points for the function, and the end lable wasn't strictly
for errors. Directly returning simplifies and shortens the code.
Signed-off-by: John Kacur <jkacur@redhat.com>
---
src/cyclictest/rt_numa.h | 14 +++++---------
1 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/src/cyclictest/rt_numa.h b/src/cyclictest/rt_numa.h
index 8d44097..ac2aca2 100644
--- a/src/cyclictest/rt_numa.h
+++ b/src/cyclictest/rt_numa.h
@@ -73,7 +73,7 @@ static int rt_numa_numa_node_of_cpu(int cpu)
static int rt_numa_numa_node_of_cpu(int cpu)
{
unsigned char cpumask[16];
- int node, ret, idx, bit;
+ int node, idx, bit;
int max_node, max_cpus;
max_node = numa_max_node();
@@ -88,19 +88,15 @@ static int rt_numa_numa_node_of_cpu(int cpu)
idx = cpu / 8;
bit = cpu % 8;
- for (node = 0; node <= max_node; node++){
+ for (node = 0; node <= max_node; node++) {
if (numa_node_to_cpus(node, (void *) cpumask, sizeof(cpumask)))
return -1;
- if (cpumask[idx] & (1<<bit)) {
- ret = node;
- goto end;
- }
+ if (cpumask[idx] & (1<<bit))
+ return node;
}
- ret = -1;
errno = EINVAL;
-end:
- return ret;
+ return -1;
}
#endif /* LIBNUMA_API_VERSION */
--
1.6.6
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/5] rt-tests: Fix some style problems, such as spaces instead of tabs.
2010-01-27 20:24 [PATCH 0/5] rt-tests: rt_numa.h clean-ups, and dependency files John Kacur
` (2 preceding siblings ...)
2010-01-27 20:24 ` [PATCH 3/5] rt-tests: Remove the ret variable, the end label and the goto John Kacur
@ 2010-01-27 20:24 ` John Kacur
2010-01-27 20:24 ` [PATCH 5/5] rt-tests: Automatically generate dependencies John Kacur
4 siblings, 0 replies; 6+ messages in thread
From: John Kacur @ 2010-01-27 20:24 UTC (permalink / raw)
To: Clark Williams
Cc: Thomas Gleixner, lkml, Ingo Molnar, Carsten Emde, rt-users,
John Kacur, John Kacur
From: John Kacur <jkacur@localhost.localdomain>
Fix some style problems, such as spaces instead of tabs, trailing spaces,
spaces required before }
Signed-off-by: John Kacur <jkacur@redhat.com>
---
src/cyclictest/rt_numa.h | 22 +++++++++++-----------
1 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/cyclictest/rt_numa.h b/src/cyclictest/rt_numa.h
index ac2aca2..73ef3d8 100644
--- a/src/cyclictest/rt_numa.h
+++ b/src/cyclictest/rt_numa.h
@@ -40,7 +40,7 @@ threadfree(void *ptr, size_t size, int node)
free(ptr);
else
numa_free(ptr, size);
-}
+}
static void rt_numa_set_numa_run_on_node(int node, int cpu)
{
@@ -73,29 +73,29 @@ static int rt_numa_numa_node_of_cpu(int cpu)
static int rt_numa_numa_node_of_cpu(int cpu)
{
unsigned char cpumask[16];
- int node, idx, bit;
+ int node, idx, bit;
int max_node, max_cpus;
max_node = numa_max_node();
max_cpus = sysconf(_SC_NPROCESSORS_CONF);
- if (cpu > max_cpus) {
- errno = EINVAL;
- return -1;
- }
+ if (cpu > max_cpus) {
+ errno = EINVAL;
+ return -1;
+ }
/* calculate bitmask index and relative bit position of cpu */
idx = cpu / 8;
bit = cpu % 8;
- for (node = 0; node <= max_node; node++) {
+ for (node = 0; node <= max_node; node++) {
if (numa_node_to_cpus(node, (void *) cpumask, sizeof(cpumask)))
return -1;
if (cpumask[idx] & (1<<bit))
return node;
- }
- errno = EINVAL;
+ }
+ errno = EINVAL;
return -1;
}
@@ -114,10 +114,10 @@ static void *rt_numa_numa_alloc_onnode(size_t size, int node, int cpu)
#else
static inline void *threadalloc(size_t size, int n) { return malloc(size); }
-static inline void threadfree(void *ptr, size_t s, int n) { free(ptr); }
+static inline void threadfree(void *ptr, size_t s, int n) { free(ptr); }
static inline void rt_numa_set_numa_run_on_node(int n, int c) { }
static inline void numa_on_and_available() { };
-static inline int rt_numa_numa_node_of_cpu(int cpu) { return -1;}
+static inline int rt_numa_numa_node_of_cpu(int cpu) { return -1; }
static void *rt_numa_numa_alloc_onnode(size_t s, int n, int c) { return NULL; }
#endif /* NUMA */
--
1.6.6
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 5/5] rt-tests: Automatically generate dependencies.
2010-01-27 20:24 [PATCH 0/5] rt-tests: rt_numa.h clean-ups, and dependency files John Kacur
` (3 preceding siblings ...)
2010-01-27 20:24 ` [PATCH 4/5] rt-tests: Fix some style problems, such as spaces instead of tabs John Kacur
@ 2010-01-27 20:24 ` John Kacur
4 siblings, 0 replies; 6+ messages in thread
From: John Kacur @ 2010-01-27 20:24 UTC (permalink / raw)
To: Clark Williams
Cc: Thomas Gleixner, lkml, Ingo Molnar, Carsten Emde, rt-users,
John Kacur
Automatically generate dependencies. This will tell the make file that
cyclictest is dependent on rt_numa.h for example, and that if a change
is made there, then cyclictest needs to be remade.
Signed-off-by: John Kacur <jkacur@redhat.com>
---
Makefile | 20 ++++++++++++++++----
1 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index 6156c03..4be0838 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,10 @@
VERSION_STRING = 0.63
-TARGETS = cyclictest signaltest pi_stress \
- rt-migrate-test ptsematest sigwaittest svsematest \
- sendme pip
+sources = cyclictest.c signaltest.c pi_stress.c rt-migrate-test.c \
+ ptsematest.c sigwaittest.c svsematest.c sendme.c pip.c
+
+TARGETS = $(sources:.c=)
+
LIBS = -lrt -lpthread
EXTRA_LIBS ?= -ldl # for get_cpu
DESTDIR ?=
@@ -39,9 +41,19 @@ VPATH += src/lib
%.o: %.c
$(CC) -D VERSION_STRING=$(VERSION_STRING) -c $< $(CFLAGS)
+# Pattern rule to generate dependency files from .c files
+%.d: %.c
+ @set -e; rm -f $@; \
+ $(CC) -MM $(CFLAGS) $< > $@.$$$$; \
+ sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
+ rm -f $@.$$$$
+
.PHONY: all
all: $(TARGETS) hwlatdetect
+# Include dependency files, automatically generate them if needed.
+-include $(sources:.c=.d)
+
cyclictest: cyclictest.o rt-utils.o
$(CC) $(CFLAGS) -o $@ $^ $(LIBS) $(NUMA_LIBS)
@@ -73,7 +85,7 @@ sendme: sendme.o rt-utils.o rt-get_cpu.o
pip: pip.o error.o rt-utils.o
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
-CLEANUP = $(TARGETS) *.o .depend *.*~ *.orig *.rej rt-tests.spec
+CLEANUP = $(TARGETS) *.o .depend *.*~ *.orig *.rej rt-tests.spec *.d
CLEANUP += $(if $(wildcard .git), ChangeLog)
.PHONY: clean
--
1.6.6
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-01-27 20:25 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-27 20:24 [PATCH 0/5] rt-tests: rt_numa.h clean-ups, and dependency files John Kacur
2010-01-27 20:24 ` [PATCH 1/5] rt-tests: Add header including copyright notice to rt_numa.h John Kacur
2010-01-27 20:24 ` [PATCH 2/5] rt-tests: Separate the #ifdef LIBNUMA_API_VERSION functions John Kacur
2010-01-27 20:24 ` [PATCH 3/5] rt-tests: Remove the ret variable, the end label and the goto John Kacur
2010-01-27 20:24 ` [PATCH 4/5] rt-tests: Fix some style problems, such as spaces instead of tabs John Kacur
2010-01-27 20:24 ` [PATCH 5/5] rt-tests: Automatically generate dependencies John Kacur
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).