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

Signed-off-by: Petri Savolainen <petri.savolai...@nokia.com>
---
 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 --git a/example/classifier/odp_classifier.c 
b/example/classifier/odp_classifier.c
index 3d18ea2..eeffb9f 100644
--- a/example/classifier/odp_classifier.c
+++ b/example/classifier/odp_classifier.c
@@ -419,11 +419,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 81d7c35..4bf1746 100644
--- a/example/generator/odp_generator.c
+++ b/example/generator/odp_generator.c
@@ -640,11 +640,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 99ccd6b..aea82cf 100644
--- a/example/ipsec/odp_ipsec.c
+++ b/example/ipsec/odp_ipsec.c
@@ -1203,11 +1203,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 a281d69..d1c017f 100644
--- a/example/packet/odp_pktio.c
+++ b/example/packet/odp_pktio.c
@@ -367,11 +367,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 5e4306e..4b5870b 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 be1ea13..da403ab 100644
--- a/helper/linux.c
+++ b/helper/linux.c
@@ -24,37 +24,6 @@
 #include <odp_debug_internal.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)
-               ODP_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 3483549..627eda1 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 04c6b1e..bd01f24 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 36c3571..6670b46 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 a6e86a4..8533bc7 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 99f0f9b..b4e5f5a 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 eac2d81..481ea3d 100644
--- a/test/validation/common/odp_cunit_common.c
+++ b/test/validation/common/odp_cunit_common.c
@@ -23,7 +23,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);
 
-- 
2.4.2

_______________________________________________
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to