[rt-tests v2 02/18] cyclictest: Use numa library helpers in get_available_cpus()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The numa library has support for counting the bits in the affinity
mask and how many CPUs are available and usable by the tasks. Let's
use those helpers.

Signed-off-by: Daniel Wagner <dwagner@xxxxxxx>
---
 src/cyclictest/cyclictest.c | 22 +++-------------------
 1 file changed, 3 insertions(+), 19 deletions(-)

diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 02cb92813fb7..d7477c686435 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -915,26 +915,10 @@ static int clocksources[] = {
  */
 static int get_available_cpus(void)
 {
-	int num_cpus = 0;
-	int res;
-	pthread_t thread;
-	cpu_set_t cpuset;
-
-
-	if (affinity_mask != NULL) {
-		num_cpus = rt_numa_bitmask_count(affinity_mask);
-	} else {
-		CPU_ZERO(&cpuset);
-		thread = pthread_self();
-		res = pthread_getaffinity_np(thread, sizeof(cpu_set_t), &cpuset);
-		if (res != 0) {
-			fatal("pthread_getaffinity_np failed: %s\n", strerror(res));
-		}
-		num_cpus = CPU_COUNT(&cpuset);
-	}
-
-	return num_cpus;
+	if (affinity_mask)
+		return numa_bitmask_weight(affinity_mask);
 
+	return numa_num_task_cpus();
 }
 
 /* cpu_for_thread AFFINITY_SPECIFIED */
-- 
2.28.0




[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux