Linux-rt-users archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] rt-tests: cyclictest: Just use LIBNUMA_API_VERSION
@ 2019-09-24 17:43 John Kacur
  0 siblings, 0 replies; only message in thread
From: John Kacur @ 2019-09-24 17:43 UTC (permalink / raw)
  To: rt-users; +Cc: Clark Williams, John Kacur, Sebastian Siewior

This removes support for LIBNUMA_API_VERSION 1.

You can still build without numa support by doing
make NUMA=0

You can also build with numa and run on machines without numa support.

Suggested-by: Sebastian Siewior <bigeasy@linutronix.de>
Signed-off-by: John Kacur <jkacur@redhat.com>
---
 src/cyclictest/rt_numa.h | 98 +---------------------------------------
 1 file changed, 1 insertion(+), 97 deletions(-)

diff --git a/src/cyclictest/rt_numa.h b/src/cyclictest/rt_numa.h
index 7adeb3c01324..983502d34c94 100644
--- a/src/cyclictest/rt_numa.h
+++ b/src/cyclictest/rt_numa.h
@@ -1,16 +1,7 @@
 /*
  * 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.
- *
- * The difference in behavior hinges on whether LIBNUMA_API_VERSION >= 2,
- * in which case we will employ the bitmask affinity behavior -or-
- * either LIBNUMA_API_VERSION < 2 or NUMA support is missing altogether,
- * in which case we retain the older affinity behavior which can either
- * specify a single CPU core or else use all cores.
+ * compiled with numa support or not.
  *
  * (C) 2010 John Kacur <jkacur@redhat.com>
  * (C) 2010 Clark Williams <williams@redhat.com>
@@ -28,10 +19,6 @@ static int numa = 0;
 #ifdef NUMA
 #include <numa.h>
 
-#ifndef LIBNUMA_API_VERSION
-#define LIBNUMA_API_VERSION 2
-#endif
-
 static void *
 threadalloc(size_t size, int node)
 {
@@ -69,8 +56,6 @@ static void *rt_numa_numa_alloc_onnode(size_t size, int node, int cpu)
 	return stack;
 }
 
-#if LIBNUMA_API_VERSION >= 2
-
 /*
  * Use new bit mask CPU affinity behavior
  */
@@ -110,87 +95,6 @@ static inline void rt_bitmask_free(struct bitmask *mask)
 	numa_bitmask_free(mask);
 }
 
-#else	/* LIBNUMA_API_VERSION == 1 */
-
-struct bitmask {
-	unsigned long size; /* number of bits in the map */
-	unsigned long *maskp;
-};
-#define BITS_PER_LONG	(8*sizeof(long))
-
-/*
- * Map legacy CPU affinity behavior onto bit mask infrastructure
- */
-static int rt_numa_numa_node_of_cpu(int cpu)
-{
-	unsigned char cpumask[256];
-	int node, idx, bit;
-	int max_node, max_cpus;
-
-	max_node = numa_max_node();
-	max_cpus = sysconf(_SC_NPROCESSORS_ONLN);
-
-	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++) {
-		if (numa_node_to_cpus(node, (void *) cpumask, sizeof(cpumask)))
-			return -1;
-
-		if (cpumask[idx] & (1<<bit))
-			return node;
-	}
-	errno = EINVAL;
-	return -1;
-}
-
-static inline unsigned int rt_numa_bitmask_isbitset( const struct bitmask *mask,
-	unsigned long i)
-{
-	long bit = mask->maskp[i/BITS_PER_LONG] & (1<<(i % BITS_PER_LONG));
-	return (bit != 0);
-}
-
-static inline struct bitmask* rt_numa_parse_cpustring(const char* s,
-	int max_cpus)
-{
-	int cpu;
-	struct bitmask *mask = NULL;
-	cpu = atoi(s);
-	if (0 <= cpu && cpu < max_cpus) {
-		mask = malloc(sizeof(*mask));
-		if (mask) {
-			/* Round up to integral number of longs to contain
-			 * max_cpus bits */
-			int nlongs = (max_cpus+BITS_PER_LONG-1)/BITS_PER_LONG;
-
-			mask->maskp = calloc(nlongs, sizeof(long));
-			if (mask->maskp) {
-				mask->maskp[cpu/BITS_PER_LONG] |=
-					(1UL << (cpu % BITS_PER_LONG));
-				mask->size = max_cpus;
-			} else {
-				free(mask);
-				mask = NULL;
-			}
-		}
-	}
-	return mask;
-}
-
-static inline void rt_bitmask_free(struct bitmask *mask)
-{
-	free(mask->maskp);
-	free(mask);
-}
-
-#endif	/* LIBNUMA_API_VERSION */
 
 #else /* ! NUMA */
 
-- 
2.20.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-24 17:43 [PATCH] rt-tests: cyclictest: Just use LIBNUMA_API_VERSION John Kacur

Linux-rt-users archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-rt-users/0 linux-rt-users/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-rt-users linux-rt-users/ https://lore.kernel.org/linux-rt-users \
		linux-rt-users@vger.kernel.org
	public-inbox-index linux-rt-users

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-rt-users


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git