linux-generic: move default cpumask functions to separate file

Message ID 1439199761-25463-1-git-send-email-maxim.uvarov@linaro.org
State New
Headers show

Commit Message

Maxim Uvarov Aug. 10, 2015, 9:42 a.m.
Keep functions which iterates with bit mask and more likely will not
be accelerated by hw in odp_cpumask.c. And put functions for default
cpu mask to odp_cpumask_def.c, which is more platform specific. That
patch should simplify portability to other platforms when odp_cpumask.c
will be inherit from linux generic.

Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
---
 platform/linux-generic/Makefile.am       |  1 +
 platform/linux-generic/odp_cpumask.c     | 38 -----------------------
 platform/linux-generic/odp_cpumask_def.c | 52 ++++++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+), 38 deletions(-)
 create mode 100644 platform/linux-generic/odp_cpumask_def.c

Comments

Mike Holmes Aug. 10, 2015, 2:02 p.m. | #1
On 10 August 2015 at 05:42, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:

> Keep functions which iterates with bit mask and more likely will not
> be accelerated by hw in odp_cpumask.c. And put functions for default
> cpu mask to odp_cpumask_def.c, which is more platform specific. That
> patch should simplify portability to other platforms when odp_cpumask.c
> will be inherit from linux generic.
>

I find def confusing might be definition as in #ifdef which is a common use
for def - maybe just spell it out as default ?
I know this is an api name but now it is also a file name so it is
proliferating.

Comment in line


>
> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
> ---
>  platform/linux-generic/Makefile.am       |  1 +
>  platform/linux-generic/odp_cpumask.c     | 38 -----------------------
>  platform/linux-generic/odp_cpumask_def.c | 52
> ++++++++++++++++++++++++++++++++
>  3 files changed, 53 insertions(+), 38 deletions(-)
>  create mode 100644 platform/linux-generic/odp_cpumask_def.c
>
> diff --git a/platform/linux-generic/Makefile.am
> b/platform/linux-generic/Makefile.am
> index ed4add5..bc750ff 100644
> --- a/platform/linux-generic/Makefile.am
> +++ b/platform/linux-generic/Makefile.am
> @@ -134,6 +134,7 @@ __LIB__libodp_la_SOURCES = \
>                            odp_buffer.c \
>                            odp_classification.c \
>                            odp_cpumask.c \
> +                          odp_cpumask_def.c \
>                            odp_crypto.c \
>                            odp_errno.c \
>                            odp_event.c \
> diff --git a/platform/linux-generic/odp_cpumask.c
> b/platform/linux-generic/odp_cpumask.c
> index c28153b..b31e1ca 100644
> --- a/platform/linux-generic/odp_cpumask.c
> +++ b/platform/linux-generic/odp_cpumask.c
> @@ -205,41 +205,3 @@ int odp_cpumask_next(const odp_cpumask_t *mask, int
> cpu)
>                         return cpu;
>         return -1;
>  }
> -
> -int odp_cpumask_def_worker(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;
> -}
> -
> -int odp_cpumask_def_control(odp_cpumask_t *mask, int num ODP_UNUSED)
> -{
> -       odp_cpumask_zero(mask);
> -       /* By default all control threads on CPU 0 */
> -       odp_cpumask_set(mask, 0);
> -       return 1;
> -}
> diff --git a/platform/linux-generic/odp_cpumask_def.c
> b/platform/linux-generic/odp_cpumask_def.c
> new file mode 100644
> index 0000000..a96218c
> --- /dev/null
> +++ b/platform/linux-generic/odp_cpumask_def.c
> @@ -0,0 +1,52 @@
> +/* Copyright (c) 2013, Linaro Limited
>

2015


> + * All rights reserved.
> + *
> + * SPDX-License-Identifier:     BSD-3-Clause
> + */
> +
> +#ifndef _GNU_SOURCE
> +#define _GNU_SOURCE
> +#endif
> +#include <sched.h>
> +#include <pthread.h>
> +
> +#include <odp/cpumask.h>
> +#include <odp_debug_internal.h>
> +
> +int odp_cpumask_def_worker(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;
> +}
> +
> +int odp_cpumask_def_control(odp_cpumask_t *mask, int num ODP_UNUSED)
> +{
> +       odp_cpumask_zero(mask);
> +       /* By default all control threads on CPU 0 */
> +       odp_cpumask_set(mask, 0);
> +       return 1;
> +}
> --
> 1.9.1
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
>
Bill Fischofer Aug. 10, 2015, 2:21 p.m. | #2
I agree that overly short abbreviations can be a problem and also think the
meaning of "def" is not obvious here. However as I understand it this patch
is simply moving an existing API to a different source file.  An API rename
would be an API-NEXT item and a separate patch.

On Mon, Aug 10, 2015 at 9:02 AM, Mike Holmes <mike.holmes@linaro.org> wrote:

>
>
> On 10 August 2015 at 05:42, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:
>
>> Keep functions which iterates with bit mask and more likely will not
>> be accelerated by hw in odp_cpumask.c. And put functions for default
>> cpu mask to odp_cpumask_def.c, which is more platform specific. That
>> patch should simplify portability to other platforms when odp_cpumask.c
>> will be inherit from linux generic.
>>
>
> I find def confusing might be definition as in #ifdef which is a common
> use for def - maybe just spell it out as default ?
> I know this is an api name but now it is also a file name so it is
> proliferating.
>
> Comment in line
>
>
>>
>> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
>> ---
>>  platform/linux-generic/Makefile.am       |  1 +
>>  platform/linux-generic/odp_cpumask.c     | 38 -----------------------
>>  platform/linux-generic/odp_cpumask_def.c | 52
>> ++++++++++++++++++++++++++++++++
>>  3 files changed, 53 insertions(+), 38 deletions(-)
>>  create mode 100644 platform/linux-generic/odp_cpumask_def.c
>>
>> diff --git a/platform/linux-generic/Makefile.am
>> b/platform/linux-generic/Makefile.am
>> index ed4add5..bc750ff 100644
>> --- a/platform/linux-generic/Makefile.am
>> +++ b/platform/linux-generic/Makefile.am
>> @@ -134,6 +134,7 @@ __LIB__libodp_la_SOURCES = \
>>                            odp_buffer.c \
>>                            odp_classification.c \
>>                            odp_cpumask.c \
>> +                          odp_cpumask_def.c \
>>                            odp_crypto.c \
>>                            odp_errno.c \
>>                            odp_event.c \
>> diff --git a/platform/linux-generic/odp_cpumask.c
>> b/platform/linux-generic/odp_cpumask.c
>> index c28153b..b31e1ca 100644
>> --- a/platform/linux-generic/odp_cpumask.c
>> +++ b/platform/linux-generic/odp_cpumask.c
>> @@ -205,41 +205,3 @@ int odp_cpumask_next(const odp_cpumask_t *mask, int
>> cpu)
>>                         return cpu;
>>         return -1;
>>  }
>> -
>> -int odp_cpumask_def_worker(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;
>> -}
>> -
>> -int odp_cpumask_def_control(odp_cpumask_t *mask, int num ODP_UNUSED)
>> -{
>> -       odp_cpumask_zero(mask);
>> -       /* By default all control threads on CPU 0 */
>> -       odp_cpumask_set(mask, 0);
>> -       return 1;
>> -}
>> diff --git a/platform/linux-generic/odp_cpumask_def.c
>> b/platform/linux-generic/odp_cpumask_def.c
>> new file mode 100644
>> index 0000000..a96218c
>> --- /dev/null
>> +++ b/platform/linux-generic/odp_cpumask_def.c
>> @@ -0,0 +1,52 @@
>> +/* Copyright (c) 2013, Linaro Limited
>>
>
> 2015
>
>
>> + * All rights reserved.
>> + *
>> + * SPDX-License-Identifier:     BSD-3-Clause
>> + */
>> +
>> +#ifndef _GNU_SOURCE
>> +#define _GNU_SOURCE
>> +#endif
>> +#include <sched.h>
>> +#include <pthread.h>
>> +
>> +#include <odp/cpumask.h>
>> +#include <odp_debug_internal.h>
>> +
>> +int odp_cpumask_def_worker(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;
>> +}
>> +
>> +int odp_cpumask_def_control(odp_cpumask_t *mask, int num ODP_UNUSED)
>> +{
>> +       odp_cpumask_zero(mask);
>> +       /* By default all control threads on CPU 0 */
>> +       odp_cpumask_set(mask, 0);
>> +       return 1;
>> +}
>> --
>> 1.9.1
>>
>> _______________________________________________
>> lng-odp mailing list
>> lng-odp@lists.linaro.org
>> https://lists.linaro.org/mailman/listinfo/lng-odp
>>
>
>
>
> --
> Mike Holmes
> Technical Manager - Linaro Networking Group
> Linaro.org <http://www.linaro.org/> *│ *Open source software for ARM SoCs
>
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
>
>
Maxim Uvarov Aug. 10, 2015, 8:32 p.m. | #3
On 08/10/15 17:21, Bill Fischofer wrote:
> I agree that overly short abbreviations can be a problem and also 
> think the meaning of "def" is not obvious here. However as I 
> understand it this patch is simply moving an existing API to a 
> different source file.  An API rename would be an API-NEXT item and a 
> separate patch.
>
it splits existing implementation on 2 files. API not touched.

About that naming that is why in first patch odp_cpumask_common.c and 
odp_cpumask.c was better. Due to odp_cpumask_common.c will be the same 
for all platforms.

So for final version:

odp_cpumask.c and odp_cpumask_tasks.c will be good? (Today on meeting we 
agreed that control thread and worker thread we can name tasks.)

Maxim.



> On Mon, Aug 10, 2015 at 9:02 AM, Mike Holmes <mike.holmes@linaro.org 
> <mailto:mike.holmes@linaro.org>> wrote:
>
>
>
>     On 10 August 2015 at 05:42, Maxim Uvarov <maxim.uvarov@linaro.org
>     <mailto:maxim.uvarov@linaro.org>> wrote:
>
>         Keep functions which iterates with bit mask and more likely
>         will not
>         be accelerated by hw in odp_cpumask.c. And put functions for
>         default
>         cpu mask to odp_cpumask_def.c, which is more platform
>         specific. That
>         patch should simplify portability to other platforms when
>         odp_cpumask.c
>         will be inherit from linux generic.
>
>
>     I find def confusing might be definition as in #ifdef which is a
>     common use for def - maybe just spell it out as default ?
>     I know this is an api name but now it is also a file name so it is
>     proliferating.
>
>     Comment in line
>
>
>         Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org
>         <mailto:maxim.uvarov@linaro.org>>
>         ---
>          platform/linux-generic/Makefile.am       |  1 +
>          platform/linux-generic/odp_cpumask.c     | 38
>         -----------------------
>          platform/linux-generic/odp_cpumask_def.c | 52
>         ++++++++++++++++++++++++++++++++
>          3 files changed, 53 insertions(+), 38 deletions(-)
>          create mode 100644 platform/linux-generic/odp_cpumask_def.c
>
>         diff --git a/platform/linux-generic/Makefile.am
>         b/platform/linux-generic/Makefile.am
>         index ed4add5..bc750ff 100644
>         --- a/platform/linux-generic/Makefile.am
>         +++ b/platform/linux-generic/Makefile.am
>         @@ -134,6 +134,7 @@ __LIB__libodp_la_SOURCES = \
>                                    odp_buffer.c \
>                                    odp_classification.c \
>                                    odp_cpumask.c \
>         +                          odp_cpumask_def.c \
>                                    odp_crypto.c \
>                                    odp_errno.c \
>                                    odp_event.c \
>         diff --git a/platform/linux-generic/odp_cpumask.c
>         b/platform/linux-generic/odp_cpumask.c
>         index c28153b..b31e1ca 100644
>         --- a/platform/linux-generic/odp_cpumask.c
>         +++ b/platform/linux-generic/odp_cpumask.c
>         @@ -205,41 +205,3 @@ int odp_cpumask_next(const odp_cpumask_t
>         *mask, int cpu)
>                                 return cpu;
>                 return -1;
>          }
>         -
>         -int odp_cpumask_def_worker(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;
>         -}
>         -
>         -int odp_cpumask_def_control(odp_cpumask_t *mask, int num
>         ODP_UNUSED)
>         -{
>         -       odp_cpumask_zero(mask);
>         -       /* By default all control threads on CPU 0 */
>         -       odp_cpumask_set(mask, 0);
>         -       return 1;
>         -}
>         diff --git a/platform/linux-generic/odp_cpumask_def.c
>         b/platform/linux-generic/odp_cpumask_def.c
>         new file mode 100644
>         index 0000000..a96218c
>         --- /dev/null
>         +++ b/platform/linux-generic/odp_cpumask_def.c
>         @@ -0,0 +1,52 @@
>         +/* Copyright (c) 2013, Linaro Limited
>
>
>     2015
>
>         + * All rights reserved.
>         + *
>         + * SPDX-License-Identifier:     BSD-3-Clause
>         + */
>         +
>         +#ifndef _GNU_SOURCE
>         +#define _GNU_SOURCE
>         +#endif
>         +#include <sched.h>
>         +#include <pthread.h>
>         +
>         +#include <odp/cpumask.h>
>         +#include <odp_debug_internal.h>
>         +
>         +int odp_cpumask_def_worker(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;
>         +}
>         +
>         +int odp_cpumask_def_control(odp_cpumask_t *mask, int num
>         ODP_UNUSED)
>         +{
>         +       odp_cpumask_zero(mask);
>         +       /* By default all control threads on CPU 0 */
>         +       odp_cpumask_set(mask, 0);
>         +       return 1;
>         +}
>         --
>         1.9.1
>
>         _______________________________________________
>         lng-odp mailing list
>         lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>         https://lists.linaro.org/mailman/listinfo/lng-odp
>
>
>
>
>     -- 
>     Mike Holmes
>     Technical Manager - Linaro Networking Group
>     Linaro.org <http://www.linaro.org/>***│ *Open source software for
>     ARM SoCs
>
>
>     _______________________________________________
>     lng-odp mailing list
>     lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>     https://lists.linaro.org/mailman/listinfo/lng-odp
>
>
Mike Holmes Aug. 10, 2015, 8:45 p.m. | #4
On 10 August 2015 at 16:32, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:
> On 08/10/15 17:21, Bill Fischofer wrote:
>>
>> I agree that overly short abbreviations can be a problem and also think
>> the meaning of "def" is not obvious here. However as I understand it this
>> patch is simply moving an existing API to a different source file.  An API
>> rename would be an API-NEXT item and a separate patch.
>>
> it splits existing implementation on 2 files. API not touched.
>
> About that naming that is why in first patch odp_cpumask_common.c and
> odp_cpumask.c was better. Due to odp_cpumask_common.c will be the same for
> all platforms.
>
> So for final version:
>
> odp_cpumask.c and odp_cpumask_tasks.c will be good? (Today on meeting we
> agreed that control thread and worker thread we can name tasks.)

task works for me.

Created https://bugs.linaro.org/show_bug.cgi?id=1745 to track the
rename of the API brought up in this thread.

>
> Maxim.
>
>
>
>> On Mon, Aug 10, 2015 at 9:02 AM, Mike Holmes <mike.holmes@linaro.org
>> <mailto:mike.holmes@linaro.org>> wrote:
>>
>>
>>
>>     On 10 August 2015 at 05:42, Maxim Uvarov <maxim.uvarov@linaro.org
>>     <mailto:maxim.uvarov@linaro.org>> wrote:
>>
>>         Keep functions which iterates with bit mask and more likely
>>         will not
>>         be accelerated by hw in odp_cpumask.c. And put functions for
>>         default
>>         cpu mask to odp_cpumask_def.c, which is more platform
>>         specific. That
>>         patch should simplify portability to other platforms when
>>         odp_cpumask.c
>>         will be inherit from linux generic.
>>
>>
>>     I find def confusing might be definition as in #ifdef which is a
>>     common use for def - maybe just spell it out as default ?
>>     I know this is an api name but now it is also a file name so it is
>>     proliferating.
>>
>>     Comment in line
>>
>>
>>         Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org
>>         <mailto:maxim.uvarov@linaro.org>>
>>
>>         ---
>>          platform/linux-generic/Makefile.am       |  1 +
>>          platform/linux-generic/odp_cpumask.c     | 38
>>         -----------------------
>>          platform/linux-generic/odp_cpumask_def.c | 52
>>         ++++++++++++++++++++++++++++++++
>>          3 files changed, 53 insertions(+), 38 deletions(-)
>>          create mode 100644 platform/linux-generic/odp_cpumask_def.c
>>
>>         diff --git a/platform/linux-generic/Makefile.am
>>         b/platform/linux-generic/Makefile.am
>>         index ed4add5..bc750ff 100644
>>         --- a/platform/linux-generic/Makefile.am
>>         +++ b/platform/linux-generic/Makefile.am
>>         @@ -134,6 +134,7 @@ __LIB__libodp_la_SOURCES = \
>>                                    odp_buffer.c \
>>                                    odp_classification.c \
>>                                    odp_cpumask.c \
>>         +                          odp_cpumask_def.c \
>>                                    odp_crypto.c \
>>                                    odp_errno.c \
>>                                    odp_event.c \
>>         diff --git a/platform/linux-generic/odp_cpumask.c
>>         b/platform/linux-generic/odp_cpumask.c
>>         index c28153b..b31e1ca 100644
>>         --- a/platform/linux-generic/odp_cpumask.c
>>         +++ b/platform/linux-generic/odp_cpumask.c
>>         @@ -205,41 +205,3 @@ int odp_cpumask_next(const odp_cpumask_t
>>         *mask, int cpu)
>>                                 return cpu;
>>                 return -1;
>>          }
>>         -
>>         -int odp_cpumask_def_worker(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;
>>         -}
>>         -
>>         -int odp_cpumask_def_control(odp_cpumask_t *mask, int num
>>         ODP_UNUSED)
>>         -{
>>         -       odp_cpumask_zero(mask);
>>         -       /* By default all control threads on CPU 0 */
>>         -       odp_cpumask_set(mask, 0);
>>         -       return 1;
>>         -}
>>         diff --git a/platform/linux-generic/odp_cpumask_def.c
>>         b/platform/linux-generic/odp_cpumask_def.c
>>         new file mode 100644
>>         index 0000000..a96218c
>>         --- /dev/null
>>         +++ b/platform/linux-generic/odp_cpumask_def.c
>>         @@ -0,0 +1,52 @@
>>         +/* Copyright (c) 2013, Linaro Limited
>>
>>
>>     2015
>>
>>         + * All rights reserved.
>>         + *
>>         + * SPDX-License-Identifier:     BSD-3-Clause
>>         + */
>>         +
>>         +#ifndef _GNU_SOURCE
>>         +#define _GNU_SOURCE
>>         +#endif
>>         +#include <sched.h>
>>         +#include <pthread.h>
>>         +
>>         +#include <odp/cpumask.h>
>>         +#include <odp_debug_internal.h>
>>         +
>>         +int odp_cpumask_def_worker(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;
>>         +}
>>         +
>>         +int odp_cpumask_def_control(odp_cpumask_t *mask, int num
>>         ODP_UNUSED)
>>         +{
>>         +       odp_cpumask_zero(mask);
>>         +       /* By default all control threads on CPU 0 */
>>         +       odp_cpumask_set(mask, 0);
>>         +       return 1;
>>         +}
>>         --
>>         1.9.1
>>
>>         _______________________________________________
>>         lng-odp mailing list
>>         lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>>         https://lists.linaro.org/mailman/listinfo/lng-odp
>>
>>
>>
>>
>>     --     Mike Holmes
>>     Technical Manager - Linaro Networking Group
>>     Linaro.org <http://www.linaro.org/>***│ *Open source software for
>>     ARM SoCs
>>
>>
>>     _______________________________________________
>>     lng-odp mailing list
>>     lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>>     https://lists.linaro.org/mailman/listinfo/lng-odp
>>
>>
>

Patch

diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am
index ed4add5..bc750ff 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -134,6 +134,7 @@  __LIB__libodp_la_SOURCES = \
 			   odp_buffer.c \
 			   odp_classification.c \
 			   odp_cpumask.c \
+			   odp_cpumask_def.c \
 			   odp_crypto.c \
 			   odp_errno.c \
 			   odp_event.c \
diff --git a/platform/linux-generic/odp_cpumask.c b/platform/linux-generic/odp_cpumask.c
index c28153b..b31e1ca 100644
--- a/platform/linux-generic/odp_cpumask.c
+++ b/platform/linux-generic/odp_cpumask.c
@@ -205,41 +205,3 @@  int odp_cpumask_next(const odp_cpumask_t *mask, int cpu)
 			return cpu;
 	return -1;
 }
-
-int odp_cpumask_def_worker(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;
-}
-
-int odp_cpumask_def_control(odp_cpumask_t *mask, int num ODP_UNUSED)
-{
-	odp_cpumask_zero(mask);
-	/* By default all control threads on CPU 0 */
-	odp_cpumask_set(mask, 0);
-	return 1;
-}
diff --git a/platform/linux-generic/odp_cpumask_def.c b/platform/linux-generic/odp_cpumask_def.c
new file mode 100644
index 0000000..a96218c
--- /dev/null
+++ b/platform/linux-generic/odp_cpumask_def.c
@@ -0,0 +1,52 @@ 
+/* Copyright (c) 2013, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#include <sched.h>
+#include <pthread.h>
+
+#include <odp/cpumask.h>
+#include <odp_debug_internal.h>
+
+int odp_cpumask_def_worker(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;
+}
+
+int odp_cpumask_def_control(odp_cpumask_t *mask, int num ODP_UNUSED)
+{
+	odp_cpumask_zero(mask);
+	/* By default all control threads on CPU 0 */
+	odp_cpumask_set(mask, 0);
+	return 1;
+}