@@ -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);
@@ -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);
@@ -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);
@@ -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);
@@ -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);
@@ -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.
@@ -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;
@@ -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);
@@ -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);
@@ -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);
@@ -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);
@@ -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);
@@ -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;
@@ -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);
@@ -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);