diff mbox

linux-gen: using ODP instantiation pid as odp instance

Message ID 1474300617-19849-1-git-send-email-christophe.milard@linaro.org
State Accepted
Commit 09abf90268a0a5a2daf7c7e0ae37a2d7c35e87c5
Headers show

Commit Message

Christophe Milard Sept. 19, 2016, 3:56 p.m. UTC
Rather than using INSTANCE_ID (constant 0xdeadbeef), the ODP main
instantiation process ID is used as instance ID in the linux-generic
implementation. This is a simple way to guarantee instance uniqueness
on linux systems.

Signed-off-by: Christophe Milard <christophe.milard@linaro.org>

---
 platform/linux-generic/include/odp_internal.h | 1 -
 platform/linux-generic/odp_init.c             | 7 +++----
 platform/linux-generic/odp_traffic_mngr.c     | 3 ++-
 3 files changed, 5 insertions(+), 6 deletions(-)

-- 
2.7.4

Comments

Bill Fischofer Sept. 20, 2016, 2:34 a.m. UTC | #1
On Mon, Sep 19, 2016 at 10:56 AM, Christophe Milard <
christophe.milard@linaro.org> wrote:

> Rather than using INSTANCE_ID (constant 0xdeadbeef), the ODP main

> instantiation process ID is used as instance ID in the linux-generic

> implementation. This is a simple way to guarantee instance uniqueness

> on linux systems.

>

> Signed-off-by: Christophe Milard <christophe.milard@linaro.org>

>


Reviewed-and-tested-by: Bill Fischofer <bill.fischofer@linaro.org>


> ---

>  platform/linux-generic/include/odp_internal.h | 1 -

>  platform/linux-generic/odp_init.c             | 7 +++----

>  platform/linux-generic/odp_traffic_mngr.c     | 3 ++-

>  3 files changed, 5 insertions(+), 6 deletions(-)

>

> diff --git a/platform/linux-generic/include/odp_internal.h

> b/platform/linux-generic/include/odp_internal.h

> index 8bad450..3429781 100644

> --- a/platform/linux-generic/include/odp_internal.h

> +++ b/platform/linux-generic/include/odp_internal.h

> @@ -25,7 +25,6 @@ extern "C" {

>

>  extern __thread int __odp_errno;

>

> -#define INSTANCE_ID    0xdeadbeef

>  #define MAX_CPU_NUMBER 128

>

>  typedef struct {

> diff --git a/platform/linux-generic/odp_init.c

> b/platform/linux-generic/odp_init.c

> index f534759..77f4f8a 100644

> --- a/platform/linux-generic/odp_init.c

> +++ b/platform/linux-generic/odp_init.c

> @@ -116,8 +116,7 @@ int odp_init_global(odp_instance_t *instance,

>                 goto init_failed;

>         }

>

> -       /* Dummy support for single instance */

> -       *instance = INSTANCE_ID;

> +       *instance = (odp_instance_t)odp_global_data.main_pid;

>

>         return 0;

>

> @@ -128,7 +127,7 @@ init_failed:

>

>  int odp_term_global(odp_instance_t instance)

>  {

> -       if (instance != INSTANCE_ID) {

> +       if (instance != (odp_instance_t)odp_global_data.main_pid) {

>                 ODP_ERR("Bad instance.\n");

>                 return -1;

>         }

> @@ -250,7 +249,7 @@ int odp_init_local(odp_instance_t instance,

> odp_thread_type_t thr_type)

>  {

>         enum init_stage stage = NO_INIT;

>

> -       if (instance != INSTANCE_ID) {

> +       if (instance != (odp_instance_t)odp_global_data.main_pid) {

>                 ODP_ERR("Bad instance.\n");

>                 goto init_fail;

>         }

> diff --git a/platform/linux-generic/odp_traffic_mngr.c

> b/platform/linux-generic/odp_traffic_mngr.c

> index 4fe07ef..85228cd 100644

> --- a/platform/linux-generic/odp_traffic_mngr.c

> +++ b/platform/linux-generic/odp_traffic_mngr.c

> @@ -2317,7 +2317,8 @@ static void *tm_system_thread(void *arg)

>         uint32_t destroying, work_queue_cnt, timer_cnt;

>         int rc;

>

> -       rc = odp_init_local(INSTANCE_ID, ODP_THREAD_WORKER);

> +       rc = odp_init_local((odp_instance_t)odp_global_data.main_pid,

> +                           ODP_THREAD_WORKER);

>         ODP_ASSERT(rc == 0);

>         tm_group = arg;

>

> --

> 2.7.4

>

>
Christophe Milard Oct. 4, 2016, 1:35 p.m. UTC | #2
Ping.
This has been reviewed and agreed at ARCH call. Any reason not to merge?
Christophe

On 20 September 2016 at 04:34, Bill Fischofer <bill.fischofer@linaro.org> wrote:
>

>

> On Mon, Sep 19, 2016 at 10:56 AM, Christophe Milard

> <christophe.milard@linaro.org> wrote:

>>

>> Rather than using INSTANCE_ID (constant 0xdeadbeef), the ODP main

>> instantiation process ID is used as instance ID in the linux-generic

>> implementation. This is a simple way to guarantee instance uniqueness

>> on linux systems.

>>

>> Signed-off-by: Christophe Milard <christophe.milard@linaro.org>

>

>

> Reviewed-and-tested-by: Bill Fischofer <bill.fischofer@linaro.org>

>

>>

>> ---

>>  platform/linux-generic/include/odp_internal.h | 1 -

>>  platform/linux-generic/odp_init.c             | 7 +++----

>>  platform/linux-generic/odp_traffic_mngr.c     | 3 ++-

>>  3 files changed, 5 insertions(+), 6 deletions(-)

>>

>> diff --git a/platform/linux-generic/include/odp_internal.h

>> b/platform/linux-generic/include/odp_internal.h

>> index 8bad450..3429781 100644

>> --- a/platform/linux-generic/include/odp_internal.h

>> +++ b/platform/linux-generic/include/odp_internal.h

>> @@ -25,7 +25,6 @@ extern "C" {

>>

>>  extern __thread int __odp_errno;

>>

>> -#define INSTANCE_ID    0xdeadbeef

>>  #define MAX_CPU_NUMBER 128

>>

>>  typedef struct {

>> diff --git a/platform/linux-generic/odp_init.c

>> b/platform/linux-generic/odp_init.c

>> index f534759..77f4f8a 100644

>> --- a/platform/linux-generic/odp_init.c

>> +++ b/platform/linux-generic/odp_init.c

>> @@ -116,8 +116,7 @@ int odp_init_global(odp_instance_t *instance,

>>                 goto init_failed;

>>         }

>>

>> -       /* Dummy support for single instance */

>> -       *instance = INSTANCE_ID;

>> +       *instance = (odp_instance_t)odp_global_data.main_pid;

>>

>>         return 0;

>>

>> @@ -128,7 +127,7 @@ init_failed:

>>

>>  int odp_term_global(odp_instance_t instance)

>>  {

>> -       if (instance != INSTANCE_ID) {

>> +       if (instance != (odp_instance_t)odp_global_data.main_pid) {

>>                 ODP_ERR("Bad instance.\n");

>>                 return -1;

>>         }

>> @@ -250,7 +249,7 @@ int odp_init_local(odp_instance_t instance,

>> odp_thread_type_t thr_type)

>>  {

>>         enum init_stage stage = NO_INIT;

>>

>> -       if (instance != INSTANCE_ID) {

>> +       if (instance != (odp_instance_t)odp_global_data.main_pid) {

>>                 ODP_ERR("Bad instance.\n");

>>                 goto init_fail;

>>         }

>> diff --git a/platform/linux-generic/odp_traffic_mngr.c

>> b/platform/linux-generic/odp_traffic_mngr.c

>> index 4fe07ef..85228cd 100644

>> --- a/platform/linux-generic/odp_traffic_mngr.c

>> +++ b/platform/linux-generic/odp_traffic_mngr.c

>> @@ -2317,7 +2317,8 @@ static void *tm_system_thread(void *arg)

>>         uint32_t destroying, work_queue_cnt, timer_cnt;

>>         int rc;

>>

>> -       rc = odp_init_local(INSTANCE_ID, ODP_THREAD_WORKER);

>> +       rc = odp_init_local((odp_instance_t)odp_global_data.main_pid,

>> +                           ODP_THREAD_WORKER);

>>         ODP_ASSERT(rc == 0);

>>         tm_group = arg;

>>

>> --

>> 2.7.4

>>

>
Maxim Uvarov Oct. 4, 2016, 3:55 p.m. UTC | #3
Merged.
Maxim.

On 10/04/16 16:35, Christophe Milard wrote:
> Ping.

> This has been reviewed and agreed at ARCH call. Any reason not to merge?

> Christophe

>

> On 20 September 2016 at 04:34, Bill Fischofer <bill.fischofer@linaro.org> wrote:

>>

>> On Mon, Sep 19, 2016 at 10:56 AM, Christophe Milard

>> <christophe.milard@linaro.org> wrote:

>>> Rather than using INSTANCE_ID (constant 0xdeadbeef), the ODP main

>>> instantiation process ID is used as instance ID in the linux-generic

>>> implementation. This is a simple way to guarantee instance uniqueness

>>> on linux systems.

>>>

>>> Signed-off-by: Christophe Milard <christophe.milard@linaro.org>

>>

>> Reviewed-and-tested-by: Bill Fischofer <bill.fischofer@linaro.org>

>>

>>> ---

>>>   platform/linux-generic/include/odp_internal.h | 1 -

>>>   platform/linux-generic/odp_init.c             | 7 +++----

>>>   platform/linux-generic/odp_traffic_mngr.c     | 3 ++-

>>>   3 files changed, 5 insertions(+), 6 deletions(-)

>>>

>>> diff --git a/platform/linux-generic/include/odp_internal.h

>>> b/platform/linux-generic/include/odp_internal.h

>>> index 8bad450..3429781 100644

>>> --- a/platform/linux-generic/include/odp_internal.h

>>> +++ b/platform/linux-generic/include/odp_internal.h

>>> @@ -25,7 +25,6 @@ extern "C" {

>>>

>>>   extern __thread int __odp_errno;

>>>

>>> -#define INSTANCE_ID    0xdeadbeef

>>>   #define MAX_CPU_NUMBER 128

>>>

>>>   typedef struct {

>>> diff --git a/platform/linux-generic/odp_init.c

>>> b/platform/linux-generic/odp_init.c

>>> index f534759..77f4f8a 100644

>>> --- a/platform/linux-generic/odp_init.c

>>> +++ b/platform/linux-generic/odp_init.c

>>> @@ -116,8 +116,7 @@ int odp_init_global(odp_instance_t *instance,

>>>                  goto init_failed;

>>>          }

>>>

>>> -       /* Dummy support for single instance */

>>> -       *instance = INSTANCE_ID;

>>> +       *instance = (odp_instance_t)odp_global_data.main_pid;

>>>

>>>          return 0;

>>>

>>> @@ -128,7 +127,7 @@ init_failed:

>>>

>>>   int odp_term_global(odp_instance_t instance)

>>>   {

>>> -       if (instance != INSTANCE_ID) {

>>> +       if (instance != (odp_instance_t)odp_global_data.main_pid) {

>>>                  ODP_ERR("Bad instance.\n");

>>>                  return -1;

>>>          }

>>> @@ -250,7 +249,7 @@ int odp_init_local(odp_instance_t instance,

>>> odp_thread_type_t thr_type)

>>>   {

>>>          enum init_stage stage = NO_INIT;

>>>

>>> -       if (instance != INSTANCE_ID) {

>>> +       if (instance != (odp_instance_t)odp_global_data.main_pid) {

>>>                  ODP_ERR("Bad instance.\n");

>>>                  goto init_fail;

>>>          }

>>> diff --git a/platform/linux-generic/odp_traffic_mngr.c

>>> b/platform/linux-generic/odp_traffic_mngr.c

>>> index 4fe07ef..85228cd 100644

>>> --- a/platform/linux-generic/odp_traffic_mngr.c

>>> +++ b/platform/linux-generic/odp_traffic_mngr.c

>>> @@ -2317,7 +2317,8 @@ static void *tm_system_thread(void *arg)

>>>          uint32_t destroying, work_queue_cnt, timer_cnt;

>>>          int rc;

>>>

>>> -       rc = odp_init_local(INSTANCE_ID, ODP_THREAD_WORKER);

>>> +       rc = odp_init_local((odp_instance_t)odp_global_data.main_pid,

>>> +                           ODP_THREAD_WORKER);

>>>          ODP_ASSERT(rc == 0);

>>>          tm_group = arg;

>>>

>>> --

>>> 2.7.4

>>>
diff mbox

Patch

diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h
index 8bad450..3429781 100644
--- a/platform/linux-generic/include/odp_internal.h
+++ b/platform/linux-generic/include/odp_internal.h
@@ -25,7 +25,6 @@  extern "C" {
 
 extern __thread int __odp_errno;
 
-#define INSTANCE_ID    0xdeadbeef
 #define MAX_CPU_NUMBER 128
 
 typedef struct {
diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c
index f534759..77f4f8a 100644
--- a/platform/linux-generic/odp_init.c
+++ b/platform/linux-generic/odp_init.c
@@ -116,8 +116,7 @@  int odp_init_global(odp_instance_t *instance,
 		goto init_failed;
 	}
 
-	/* Dummy support for single instance */
-	*instance = INSTANCE_ID;
+	*instance = (odp_instance_t)odp_global_data.main_pid;
 
 	return 0;
 
@@ -128,7 +127,7 @@  init_failed:
 
 int odp_term_global(odp_instance_t instance)
 {
-	if (instance != INSTANCE_ID) {
+	if (instance != (odp_instance_t)odp_global_data.main_pid) {
 		ODP_ERR("Bad instance.\n");
 		return -1;
 	}
@@ -250,7 +249,7 @@  int odp_init_local(odp_instance_t instance, odp_thread_type_t thr_type)
 {
 	enum init_stage stage = NO_INIT;
 
-	if (instance != INSTANCE_ID) {
+	if (instance != (odp_instance_t)odp_global_data.main_pid) {
 		ODP_ERR("Bad instance.\n");
 		goto init_fail;
 	}
diff --git a/platform/linux-generic/odp_traffic_mngr.c b/platform/linux-generic/odp_traffic_mngr.c
index 4fe07ef..85228cd 100644
--- a/platform/linux-generic/odp_traffic_mngr.c
+++ b/platform/linux-generic/odp_traffic_mngr.c
@@ -2317,7 +2317,8 @@  static void *tm_system_thread(void *arg)
 	uint32_t destroying, work_queue_cnt, timer_cnt;
 	int rc;
 
-	rc = odp_init_local(INSTANCE_ID, ODP_THREAD_WORKER);
+	rc = odp_init_local((odp_instance_t)odp_global_data.main_pid,
+			    ODP_THREAD_WORKER);
 	ODP_ASSERT(rc == 0);
 	tm_group = arg;