@@ -1882,11 +1882,7 @@ int main(int argc, char **argv)
if (status != 0)
fatal("error from pthread_attr_init for thread %d: %s\n", i, strerror(status));
- if (affinity_mask)
- cpu = cpu_for_thread_sp(i, max_cpus, affinity_mask);
- else
- cpu = cpu_for_thread_ua(i, max_cpus);
-
+ cpu = cpu_for_thread(i, max_cpus, affinity_mask);
if (verbose)
printf("Thread %d using cpu %d.\n", i, cpu);
@@ -5,8 +5,7 @@
#include <numa.h>
int get_available_cpus(struct bitmask *cpumask);
-int cpu_for_thread_sp(int thread_num, int max_cpus, struct bitmask *cpumask);
-int cpu_for_thread_ua(int thread_num, int max_cpus);
+int cpu_for_thread(int thread_num, int max_cpus, struct bitmask *cpumask);
int parse_cpumask(char *str, int max_cpus, struct bitmask **cpumask);
@@ -21,7 +21,7 @@ int get_available_cpus(struct bitmask *cpumask)
return numa_num_task_cpus();
}
-int cpu_for_thread_sp(int thread_num, int max_cpus, struct bitmask *cpumask)
+static int cpu_for_thread_sp(int thread_num, int max_cpus, struct bitmask *cpumask)
{
unsigned int m, cpu, i, num_cpus;
@@ -44,8 +44,7 @@ int cpu_for_thread_sp(int thread_num, int max_cpus, struct bitmask *cpumask)
return 0;
}
-/* cpu_for_thread AFFINITY_USEALL */
-int cpu_for_thread_ua(int thread_num, int max_cpus)
+static int cpu_for_thread_ua(int thread_num, int max_cpus)
{
int res, num_cpus, i, m, cpu;
pthread_t thread;
@@ -73,6 +72,14 @@ int cpu_for_thread_ua(int thread_num, int max_cpus)
return 0;
}
+int cpu_for_thread(int thread_num, int max_cpus, struct bitmask *cpumask)
+{
+ if (cpumask)
+ return cpu_for_thread_sp(thread_num, max_cpus, cpumask);
+ else
+ return cpu_for_thread_ua(thread_num, max_cpus);
+}
+
/*
* After this function is called, affinity_mask is the intersection of
* the user supplied affinity mask and the affinity mask from the run
@@ -373,11 +373,7 @@ int main(int argc, char **argv)
par[i].bufmsk = VALBUF_SIZE - 1;
}
- if (affinity_mask)
- cpu = cpu_for_thread_sp(i, max_cpus, affinity_mask);
- else
- cpu = cpu_for_thread_ua(i, max_cpus);
-
+ cpu = cpu_for_thread(i, max_cpus, affinity_mask);
if (verbose)
printf("Thread %d using cpu %d.\n", i, cpu);
Add an simpler wrapper which calls the right implementation depending on if the cpumask is valid or not. Signed-off-by: Daniel Wagner <dwagner@suse.de> --- src/cyclictest/cyclictest.c | 6 +----- src/include/rt-numa.h | 3 +-- src/lib/rt-numa.c | 13 ++++++++++--- src/signaltest/signaltest.c | 6 +----- 4 files changed, 13 insertions(+), 15 deletions(-)