diff mbox

[06/11] api: helper: deleted odph_linux_cpumask_default

Message ID 1436449585-23252-7-git-send-email-maxim.uvarov@linaro.org
State Accepted
Commit 270af813121dd3ba67ce3ed082b49489c3c2dd35
Headers show

Commit Message

Maxim Uvarov July 9, 2015, 1:46 p.m. UTC
From: Petri Savolainen <petri.savolainen@nokia.com>

The linux specific helper was replaced by default cpumask
calls (odp_cpumask_def_worker()) in the cpumask API.

Signed-off-by: Petri Savolainen <petri.savolainen@nokia.com>
Reviewed-by: Christophe Milard <christophe.milard@linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>

Conflicts:
	helper/linux.c
---
 example/classifier/odp_classifier.c       |  7 ++-----
 example/generator/odp_generator.c         |  7 ++-----
 example/ipsec/odp_ipsec.c                 |  7 ++-----
 example/packet/odp_pktio.c                |  7 ++-----
 example/timer/odp_timer_test.c            |  7 ++-----
 helper/include/odp/helper/linux.h         | 11 -----------
 helper/linux.c                            | 31 -------------------------------
 helper/test/odp_process.c                 |  2 +-
 helper/test/odp_thread.c                  |  2 +-
 test/api_test/odp_common.c                |  2 +-
 test/performance/odp_atomic.c             |  2 +-
 test/performance/odp_l2fwd.c              |  7 ++-----
 test/performance/odp_pktio_perf.c         |  4 ++--
 test/performance/odp_scheduling.c         |  7 ++-----
 test/validation/common/odp_cunit_common.c |  2 +-
 15 files changed, 21 insertions(+), 84 deletions(-)
diff mbox

Patch

diff --git a/example/classifier/odp_classifier.c b/example/classifier/odp_classifier.c
index a716966..7b1a1c4 100644
--- a/example/classifier/odp_classifier.c
+++ b/example/classifier/odp_classifier.c
@@ -417,11 +417,8 @@  int main(int argc, char *argv[])
 	if (args->cpu_count)
 		num_workers = args->cpu_count;
 
-	/*
-	 * By default CPU #0 runs Linux kernel background tasks.
-	 * Start mapping thread from CPU #1
-	 */
-	num_workers = odph_linux_cpumask_default(&cpumask, num_workers);
+	/* Get default worker cpumask */
+	num_workers = odp_cpumask_def_worker(&cpumask, num_workers);
 	(void)odp_cpumask_to_str(&cpumask, cpumaskstr, sizeof(cpumaskstr));
 
 	printf("num worker threads: %i\n", num_workers);
diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c
index 76b6f42..36219a0 100644
--- a/example/generator/odp_generator.c
+++ b/example/generator/odp_generator.c
@@ -636,11 +636,8 @@  int main(int argc, char *argv[])
 	if (args->appl.mode == APPL_MODE_PING)
 		num_workers = 2;
 
-	/*
-	 * By default CPU #0 runs Linux kernel background tasks.
-	 * Start mapping thread from CPU #1
-	 */
-	num_workers = odph_linux_cpumask_default(&cpumask, num_workers);
+	/* Get default worker cpumask */
+	num_workers = odp_cpumask_def_worker(&cpumask, num_workers);
 	(void)odp_cpumask_to_str(&cpumask, cpumaskstr, sizeof(cpumaskstr));
 
 	printf("num worker threads: %i\n", num_workers);
diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
index 471a390..0206d93 100644
--- a/example/ipsec/odp_ipsec.c
+++ b/example/ipsec/odp_ipsec.c
@@ -1273,11 +1273,8 @@  main(int argc, char *argv[])
 	if (args->appl.cpu_count)
 		num_workers = args->appl.cpu_count;
 
-	/*
-	 * By default CPU #0 runs Linux kernel background tasks.
-	 * Start mapping thread from CPU #1
-	 */
-	num_workers = odph_linux_cpumask_default(&cpumask, num_workers);
+	/* Get default worker cpumask */
+	num_workers = odp_cpumask_def_worker(&cpumask, num_workers);
 	(void)odp_cpumask_to_str(&cpumask, cpumaskstr, sizeof(cpumaskstr));
 
 	printf("num worker threads: %i\n", num_workers);
diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c
index a71b5d4..865996c 100644
--- a/example/packet/odp_pktio.c
+++ b/example/packet/odp_pktio.c
@@ -358,11 +358,8 @@  int main(int argc, char *argv[])
 	if (args->appl.cpu_count)
 		num_workers = args->appl.cpu_count;
 
-	/*
-	 * By default CPU #0 runs Linux kernel background tasks.
-	 * Start mapping thread from CPU #1
-	 */
-	num_workers = odph_linux_cpumask_default(&cpumask, num_workers);
+	/* Get default worker cpumask */
+	num_workers = odp_cpumask_def_worker(&cpumask, num_workers);
 	(void)odp_cpumask_to_str(&cpumask, cpumaskstr, sizeof(cpumaskstr));
 
 	printf("num worker threads: %i\n", num_workers);
diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c
index f184eda..f7b1a3f 100644
--- a/example/timer/odp_timer_test.c
+++ b/example/timer/odp_timer_test.c
@@ -395,11 +395,8 @@  int main(int argc, char *argv[])
 	if (gbls->args.cpu_count)
 		num_workers = gbls->args.cpu_count;
 
-	/*
-	 * By default CPU #0 runs Linux kernel background tasks.
-	 * Start mapping thread from CPU #1
-	 */
-	num_workers = odph_linux_cpumask_default(&cpumask, num_workers);
+	/* Get default worker cpumask */
+	num_workers = odp_cpumask_def_worker(&cpumask, num_workers);
 	(void)odp_cpumask_to_str(&cpumask, cpumaskstr, sizeof(cpumaskstr));
 
 	printf("num worker threads: %i\n", num_workers);
diff --git a/helper/include/odp/helper/linux.h b/helper/include/odp/helper/linux.h
index 44ee787..ce61fdf 100644
--- a/helper/include/odp/helper/linux.h
+++ b/helper/include/odp/helper/linux.h
@@ -51,17 +51,6 @@  typedef struct {
 } odph_linux_process_t;
 
 /**
- * Creates default pthread/process cpumask
- *
- * Creates cpumask based on starting count, actual value returned
- *
- * @param mask          CPU mask to initialize
- * @param num           Number of threads to create, zero for all available
- * @return Actual values of CPUs used to create mask
- */
-int odph_linux_cpumask_default(odp_cpumask_t *mask, int num);
-
-/**
  * Creates and launches pthreads
  *
  * Creates, pins and launches threads to separate CPU's based on the cpumask.
diff --git a/helper/linux.c b/helper/linux.c
index a2eacc1..4256f43 100644
--- a/helper/linux.c
+++ b/helper/linux.c
@@ -22,37 +22,6 @@ 
 #include <odp/system_info.h>
 #include "odph_debug.h"
 
-int odph_linux_cpumask_default(odp_cpumask_t *mask, int num)
-{
-	int ret, cpu, i;
-	cpu_set_t cpuset;
-
-	ret = pthread_getaffinity_np(pthread_self(),
-				     sizeof(cpu_set_t), &cpuset);
-	if (ret != 0)
-		ODPH_ABORT("failed to read CPU affinity value\n");
-
-	odp_cpumask_zero(mask);
-
-	/*
-	 * If no user supplied number or it's too large, then attempt
-	 * to use all CPUs
-	 */
-	if (0 == num || CPU_SETSIZE < num)
-		num = CPU_COUNT(&cpuset);
-
-	/* build the mask, allocating down from highest numbered CPU */
-	for (cpu = 0, i = CPU_SETSIZE-1; i >= 0 && cpu < num; --i) {
-		if (CPU_ISSET(i, &cpuset)) {
-			odp_cpumask_set(mask, i);
-			cpu++;
-		}
-	}
-
-	return cpu;
-}
-
-
 static void *odp_run_start_routine(void *arg)
 {
 	odp_start_args_t *start_args = arg;
diff --git a/helper/test/odp_process.c b/helper/test/odp_process.c
index 97f4669..d3a5943 100644
--- a/helper/test/odp_process.c
+++ b/helper/test/odp_process.c
@@ -39,7 +39,7 @@  int main(int argc TEST_UNUSED, char *argv[] TEST_UNUSED)
 	}
 
 	/* discover how many processes this system can support */
-	num_workers = odph_linux_cpumask_default(&cpu_mask, NUMBER_WORKERS);
+	num_workers = odp_cpumask_def_worker(&cpu_mask, NUMBER_WORKERS);
 	if (num_workers < NUMBER_WORKERS) {
 		printf("System can only support %d processes and not the %d requested\n",
 		       num_workers, NUMBER_WORKERS);
diff --git a/helper/test/odp_thread.c b/helper/test/odp_thread.c
index 634be96..1de30ab 100644
--- a/helper/test/odp_thread.c
+++ b/helper/test/odp_thread.c
@@ -40,7 +40,7 @@  int main(int argc TEST_UNUSED, char *argv[] TEST_UNUSED)
 	}
 
 	/* discover how many threads this system can support */
-	num_workers = odph_linux_cpumask_default(&cpu_mask, NUMBER_WORKERS);
+	num_workers = odp_cpumask_def_worker(&cpu_mask, NUMBER_WORKERS);
 	if (num_workers < NUMBER_WORKERS) {
 		printf("System can only support %d threads and not the %d requested\n",
 		       num_workers, NUMBER_WORKERS);
diff --git a/test/api_test/odp_common.c b/test/api_test/odp_common.c
index 0677f9b..0dbefa5 100644
--- a/test/api_test/odp_common.c
+++ b/test/api_test/odp_common.c
@@ -74,7 +74,7 @@  int odp_test_thread_create(void *func_ptr(void *), pthrd_arg *arg)
 	odp_cpumask_t cpumask;
 
 	/* Create and init additional threads */
-	odph_linux_cpumask_default(&cpumask, arg->numthrds);
+	odp_cpumask_def_worker(&cpumask, arg->numthrds);
 	odph_linux_pthread_create(thread_tbl, &cpumask, func_ptr,
 				  (void *)arg);
 
diff --git a/test/performance/odp_atomic.c b/test/performance/odp_atomic.c
index 861ab83..eefce06 100644
--- a/test/performance/odp_atomic.c
+++ b/test/performance/odp_atomic.c
@@ -284,7 +284,7 @@  int odp_test_thread_create(void *func_ptr(void *), pthrd_arg *arg)
 	odp_cpumask_t cpumask;
 
 	/* Create and init additional threads */
-	odph_linux_cpumask_default(&cpumask, arg->numthrds);
+	odp_cpumask_def_worker(&cpumask, arg->numthrds);
 	odph_linux_pthread_create(thread_tbl, &cpumask, func_ptr,
 				  (void *)arg);
 
diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c
index 3184147..f1a5683 100644
--- a/test/performance/odp_l2fwd.c
+++ b/test/performance/odp_l2fwd.c
@@ -394,11 +394,8 @@  int main(int argc, char *argv[])
 	if (gbl_args->appl.cpu_count)
 		num_workers = gbl_args->appl.cpu_count;
 
-	/*
-	 * By default CPU #0 runs Linux kernel background tasks.
-	 * Start mapping thread from CPU #1
-	 */
-	num_workers = odph_linux_cpumask_default(&cpumask, num_workers);
+	/* Get default worker cpumask */
+	num_workers = odp_cpumask_def_worker(&cpumask, num_workers);
 	(void)odp_cpumask_to_str(&cpumask, cpumaskstr, sizeof(cpumaskstr));
 
 	printf("num worker threads: %i\n", num_workers);
diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c
index c3cc54d..77cb88c 100644
--- a/test/performance/odp_pktio_perf.c
+++ b/test/performance/odp_pktio_perf.c
@@ -529,8 +529,8 @@  static int setup_txrx_masks(odp_cpumask_t *thd_mask_tx,
 	int num_workers, num_tx_workers, num_rx_workers;
 	int i, cpu;
 
-	num_workers = odph_linux_cpumask_default(&cpumask,
-						 gbl_args->args.cpu_count);
+	num_workers = odp_cpumask_def_worker(&cpumask,
+					     gbl_args->args.cpu_count);
 	if (num_workers < 2) {
 		LOG_ERR("Need at least two cores\n");
 		return -1;
diff --git a/test/performance/odp_scheduling.c b/test/performance/odp_scheduling.c
index ee1c5da..f3a4f93 100644
--- a/test/performance/odp_scheduling.c
+++ b/test/performance/odp_scheduling.c
@@ -881,11 +881,8 @@  int main(int argc, char *argv[])
 	if (args.cpu_count)
 		num_workers = args.cpu_count;
 
-	/*
-	 * By default CPU #0 runs Linux kernel background tasks.
-	 * Start mapping thread from CPU #1
-	 */
-	num_workers = odph_linux_cpumask_default(&cpumask, num_workers);
+	/* Get default worker cpumask */
+	num_workers = odp_cpumask_def_worker(&cpumask, num_workers);
 	(void)odp_cpumask_to_str(&cpumask, cpumaskstr, sizeof(cpumaskstr));
 
 	printf("num worker threads: %i\n", num_workers);
diff --git a/test/validation/common/odp_cunit_common.c b/test/validation/common/odp_cunit_common.c
index f7b7ea1..caf4ace 100644
--- a/test/validation/common/odp_cunit_common.c
+++ b/test/validation/common/odp_cunit_common.c
@@ -26,7 +26,7 @@  int odp_cunit_thread_create(void *func_ptr(void *), pthrd_arg *arg)
 	odp_cpumask_t cpumask;
 
 	/* Create and init additional threads */
-	odph_linux_cpumask_default(&cpumask, arg->numthrds);
+	odp_cpumask_def_worker(&cpumask, arg->numthrds);
 	odph_linux_pthread_create(thread_tbl, &cpumask, func_ptr,
 				  (void *)arg);