diff mbox

[1/2] api: config: move ODP_SHM_NUM_BLOCKS to config.h

Message ID 1422710467-17851-1-git-send-email-mike.holmes@linaro.org
State New
Headers show

Commit Message

Mike Holmes Jan. 31, 2015, 1:21 p.m. UTC
ODP_SHM_NUM_BLOCKS was defined down in the implementation, move it out
to the config.h

Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
---
 include/odp/api/config.h                   | 6 ++++++
 platform/linux-generic/odp_shared_memory.c | 5 +----
 2 files changed, 7 insertions(+), 4 deletions(-)

Comments

Maxim Uvarov Feb. 2, 2015, 9:31 a.m. UTC | #1
Proper fix for that will be escape from static definition to dynamic 
allocation.

shm is defined in only one place, here:

typedef struct {
     odp_shm_block_t block[ODP_SHM_NUM_BLOCKS];
     odp_spinlock_t  lock;

} odp_shm_table_t;

that can be linked list with malloc allocation for list entries.

Place define to config.h only postpones the problem until we reach this 
limit.

Maxim.

On 01/31/2015 04:21 PM, Mike Holmes wrote:
> ODP_SHM_NUM_BLOCKS was defined down in the implementation, move it out
> to the config.h
>
> Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
> ---
>   include/odp/api/config.h                   | 6 ++++++
>   platform/linux-generic/odp_shared_memory.c | 5 +----
>   2 files changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/include/odp/api/config.h b/include/odp/api/config.h
> index 3529fca..16157b0 100644
> --- a/include/odp/api/config.h
> +++ b/include/odp/api/config.h
> @@ -119,6 +119,12 @@ extern "C" {
>    */
>   #define ODP_CONFIG_PACKET_BUF_LEN_MAX (ODP_CONFIG_PACKET_BUF_LEN_MIN*6)
>   
> +/** Maximum number of shared memory blocks.
> + *
> + * Limits how many blocks are available for calls to odp_shm_reserve()
> + */
> +#define ODP_SHM_NUM_BLOCKS 32
> +
>   /**
>    * @}
>    */
> diff --git a/platform/linux-generic/odp_shared_memory.c b/platform/linux-generic/odp_shared_memory.c
> index 96d10e8..e157871 100644
> --- a/platform/linux-generic/odp_shared_memory.c
> +++ b/platform/linux-generic/odp_shared_memory.c
> @@ -15,6 +15,7 @@
>   #include <odp/debug.h>
>   #include <odp_debug_internal.h>
>   #include <odp_align_internal.h>
> +#include <odp/config.h>
>   
>   #include <unistd.h>
>   #include <sys/mman.h>
> @@ -26,10 +27,6 @@
>   #include <string.h>
>   #include <errno.h>
>   
> -
> -#define ODP_SHM_NUM_BLOCKS 32
> -
> -
>   typedef struct {
>   	char      name[ODP_SHM_NAME_LEN];
>   	uint64_t  size;
Mike Holmes Feb. 3, 2015, 3:19 a.m. UTC | #2
On 2 February 2015 at 04:31, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:

> Proper fix for that will be escape from static definition to dynamic
> allocation.
>
> shm is defined in only one place, here:
>
> typedef struct {
>     odp_shm_block_t block[ODP_SHM_NUM_BLOCKS];
>     odp_spinlock_t  lock;
>
> } odp_shm_table_t;
>
> that can be linked list with malloc allocation for list entries.
>
> Place define to config.h only postpones the problem until we reach this
> limit.


no doubt things can be better, but this allows existing users to modify
things a little more simply until we have more complete solution, or do you
think we need to hold off ?


>
>
> Maxim.
>
>
> On 01/31/2015 04:21 PM, Mike Holmes wrote:
>
>> ODP_SHM_NUM_BLOCKS was defined down in the implementation, move it out
>> to the config.h
>>
>> Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
>> ---
>>   include/odp/api/config.h                   | 6 ++++++
>>   platform/linux-generic/odp_shared_memory.c | 5 +----
>>   2 files changed, 7 insertions(+), 4 deletions(-)
>>
>> diff --git a/include/odp/api/config.h b/include/odp/api/config.h
>> index 3529fca..16157b0 100644
>> --- a/include/odp/api/config.h
>> +++ b/include/odp/api/config.h
>> @@ -119,6 +119,12 @@ extern "C" {
>>    */
>>   #define ODP_CONFIG_PACKET_BUF_LEN_MAX (ODP_CONFIG_PACKET_BUF_LEN_MIN*6)
>>   +/** Maximum number of shared memory blocks.
>> + *
>> + * Limits how many blocks are available for calls to odp_shm_reserve()
>> + */
>> +#define ODP_SHM_NUM_BLOCKS 32
>> +
>>   /**
>>    * @}
>>    */
>> diff --git a/platform/linux-generic/odp_shared_memory.c
>> b/platform/linux-generic/odp_shared_memory.c
>> index 96d10e8..e157871 100644
>> --- a/platform/linux-generic/odp_shared_memory.c
>> +++ b/platform/linux-generic/odp_shared_memory.c
>> @@ -15,6 +15,7 @@
>>   #include <odp/debug.h>
>>   #include <odp_debug_internal.h>
>>   #include <odp_align_internal.h>
>> +#include <odp/config.h>
>>     #include <unistd.h>
>>   #include <sys/mman.h>
>> @@ -26,10 +27,6 @@
>>   #include <string.h>
>>   #include <errno.h>
>>   -
>> -#define ODP_SHM_NUM_BLOCKS 32
>> -
>> -
>>   typedef struct {
>>         char      name[ODP_SHM_NAME_LEN];
>>         uint64_t  size;
>>
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
Maxim Uvarov Feb. 3, 2015, 10:32 a.m. UTC | #3
On 02/03/2015 06:19 AM, Mike Holmes wrote:
>
>
> On 2 February 2015 at 04:31, Maxim Uvarov <maxim.uvarov@linaro.org 
> <mailto:maxim.uvarov@linaro.org>> wrote:
>
>     Proper fix for that will be escape from static definition to
>     dynamic allocation.
>
>     shm is defined in only one place, here:
>
>     typedef struct {
>         odp_shm_block_t block[ODP_SHM_NUM_BLOCKS];
>         odp_spinlock_t  lock;
>
>     } odp_shm_table_t;
>
>     that can be linked list with malloc allocation for list entries.
>
>     Place define to config.h only postpones the problem until we reach
>     this limit.
>
>
> no doubt things can be better, but this allows existing users to 
> modify things a little more simply until we have more complete 
> solution, or do you think we need to hold off ?
Ok, we can create bug for this with low priority and I'm applying that 
patches. Upon request we can increase this number.

Maxim.

>
>
>     Maxim.
>
>
>     On 01/31/2015 04:21 PM, Mike Holmes wrote:
>
>         ODP_SHM_NUM_BLOCKS was defined down in the implementation,
>         move it out
>         to the config.h
>
>         Signed-off-by: Mike Holmes <mike.holmes@linaro.org
>         <mailto:mike.holmes@linaro.org>>
>         ---
>           include/odp/api/config.h                   | 6 ++++++
>           platform/linux-generic/odp_shared_memory.c | 5 +----
>           2 files changed, 7 insertions(+), 4 deletions(-)
>
>         diff --git a/include/odp/api/config.h b/include/odp/api/config.h
>         index 3529fca..16157b0 100644
>         --- a/include/odp/api/config.h
>         +++ b/include/odp/api/config.h
>         @@ -119,6 +119,12 @@ extern "C" {
>            */
>           #define ODP_CONFIG_PACKET_BUF_LEN_MAX
>         (ODP_CONFIG_PACKET_BUF_LEN_MIN*6)
>           +/** Maximum number of shared memory blocks.
>         + *
>         + * Limits how many blocks are available for calls to
>         odp_shm_reserve()
>         + */
>         +#define ODP_SHM_NUM_BLOCKS 32
>         +
>           /**
>            * @}
>            */
>         diff --git a/platform/linux-generic/odp_shared_memory.c
>         b/platform/linux-generic/odp_shared_memory.c
>         index 96d10e8..e157871 100644
>         --- a/platform/linux-generic/odp_shared_memory.c
>         +++ b/platform/linux-generic/odp_shared_memory.c
>         @@ -15,6 +15,7 @@
>           #include <odp/debug.h>
>           #include <odp_debug_internal.h>
>           #include <odp_align_internal.h>
>         +#include <odp/config.h>
>             #include <unistd.h>
>           #include <sys/mman.h>
>         @@ -26,10 +27,6 @@
>           #include <string.h>
>           #include <errno.h>
>           -
>         -#define ODP_SHM_NUM_BLOCKS 32
>         -
>         -
>           typedef struct {
>                 char      name[ODP_SHM_NAME_LEN];
>                 uint64_t  size;
>
>
>
>     _______________________________________________
>     lng-odp mailing list
>     lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>     http://lists.linaro.org/mailman/listinfo/lng-odp
>
>
>
>
> -- 
> *Mike Holmes*
> Linaro  Sr Technical Manager
> LNG - ODP
Maxim Uvarov Feb. 3, 2015, 10:34 a.m. UTC | #4
You still need to rename as Petri suggested.

Maxim.

On 02/03/2015 01:32 PM, Maxim Uvarov wrote:
> On 02/03/2015 06:19 AM, Mike Holmes wrote:
>>
>>
>> On 2 February 2015 at 04:31, Maxim Uvarov <maxim.uvarov@linaro.org 
>> <mailto:maxim.uvarov@linaro.org>> wrote:
>>
>>     Proper fix for that will be escape from static definition to
>>     dynamic allocation.
>>
>>     shm is defined in only one place, here:
>>
>>     typedef struct {
>>         odp_shm_block_t block[ODP_SHM_NUM_BLOCKS];
>>         odp_spinlock_t  lock;
>>
>>     } odp_shm_table_t;
>>
>>     that can be linked list with malloc allocation for list entries.
>>
>>     Place define to config.h only postpones the problem until we reach
>>     this limit.
>>
>>
>> no doubt things can be better, but this allows existing users to 
>> modify things a little more simply until we have more complete 
>> solution, or do you think we need to hold off ?
> Ok, we can create bug for this with low priority and I'm applying that 
> patches. Upon request we can increase this number.
>
> Maxim.
>
>>
>>
>>     Maxim.
>>
>>
>>     On 01/31/2015 04:21 PM, Mike Holmes wrote:
>>
>>         ODP_SHM_NUM_BLOCKS was defined down in the implementation,
>>         move it out
>>         to the config.h
>>
>>         Signed-off-by: Mike Holmes <mike.holmes@linaro.org
>>         <mailto:mike.holmes@linaro.org>>
>>         ---
>>           include/odp/api/config.h                   | 6 ++++++
>>           platform/linux-generic/odp_shared_memory.c | 5 +----
>>           2 files changed, 7 insertions(+), 4 deletions(-)
>>
>>         diff --git a/include/odp/api/config.h b/include/odp/api/config.h
>>         index 3529fca..16157b0 100644
>>         --- a/include/odp/api/config.h
>>         +++ b/include/odp/api/config.h
>>         @@ -119,6 +119,12 @@ extern "C" {
>>            */
>>           #define ODP_CONFIG_PACKET_BUF_LEN_MAX
>>         (ODP_CONFIG_PACKET_BUF_LEN_MIN*6)
>>           +/** Maximum number of shared memory blocks.
>>         + *
>>         + * Limits how many blocks are available for calls to
>>         odp_shm_reserve()
>>         + */
>>         +#define ODP_SHM_NUM_BLOCKS 32
>>         +
>>           /**
>>            * @}
>>            */
>>         diff --git a/platform/linux-generic/odp_shared_memory.c
>>         b/platform/linux-generic/odp_shared_memory.c
>>         index 96d10e8..e157871 100644
>>         --- a/platform/linux-generic/odp_shared_memory.c
>>         +++ b/platform/linux-generic/odp_shared_memory.c
>>         @@ -15,6 +15,7 @@
>>           #include <odp/debug.h>
>>           #include <odp_debug_internal.h>
>>           #include <odp_align_internal.h>
>>         +#include <odp/config.h>
>>             #include <unistd.h>
>>           #include <sys/mman.h>
>>         @@ -26,10 +27,6 @@
>>           #include <string.h>
>>           #include <errno.h>
>>           -
>>         -#define ODP_SHM_NUM_BLOCKS 32
>>         -
>>         -
>>           typedef struct {
>>                 char      name[ODP_SHM_NAME_LEN];
>>                 uint64_t  size;
>>
>>
>>
>>     _______________________________________________
>>     lng-odp mailing list
>>     lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>>     http://lists.linaro.org/mailman/listinfo/lng-odp
>>
>>
>>
>>
>> -- 
>> *Mike Holmes*
>> Linaro  Sr Technical Manager
>> LNG - ODP
>
diff mbox

Patch

diff --git a/include/odp/api/config.h b/include/odp/api/config.h
index 3529fca..16157b0 100644
--- a/include/odp/api/config.h
+++ b/include/odp/api/config.h
@@ -119,6 +119,12 @@  extern "C" {
  */
 #define ODP_CONFIG_PACKET_BUF_LEN_MAX (ODP_CONFIG_PACKET_BUF_LEN_MIN*6)
 
+/** Maximum number of shared memory blocks.
+ *
+ * Limits how many blocks are available for calls to odp_shm_reserve()
+ */
+#define ODP_SHM_NUM_BLOCKS 32
+
 /**
  * @}
  */
diff --git a/platform/linux-generic/odp_shared_memory.c b/platform/linux-generic/odp_shared_memory.c
index 96d10e8..e157871 100644
--- a/platform/linux-generic/odp_shared_memory.c
+++ b/platform/linux-generic/odp_shared_memory.c
@@ -15,6 +15,7 @@ 
 #include <odp/debug.h>
 #include <odp_debug_internal.h>
 #include <odp_align_internal.h>
+#include <odp/config.h>
 
 #include <unistd.h>
 #include <sys/mman.h>
@@ -26,10 +27,6 @@ 
 #include <string.h>
 #include <errno.h>
 
-
-#define ODP_SHM_NUM_BLOCKS 32
-
-
 typedef struct {
 	char      name[ODP_SHM_NAME_LEN];
 	uint64_t  size;