diff mbox

[API-NEXT] linux-generic: _fdserver: allocating data table dynamicaly

Message ID 1473760066-24969-1-git-send-email-christophe.milard@linaro.org
State Superseded
Headers show

Commit Message

Christophe Milard Sept. 13, 2016, 9:47 a.m. UTC
The table containing the saved file-descriptors<->{context, key} couples is
now dynamically malloc'd in the fd server process, hence avoiding
the memory waste which happened in other process when the table was
staticaly reserved in all processes.

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

---
 platform/linux-generic/_fdserver.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

-- 
2.7.4

Comments

Bill Fischofer Sept. 13, 2016, 11:25 a.m. UTC | #1
On Tue, Sep 13, 2016 at 4:47 AM, Christophe Milard <
christophe.milard@linaro.org> wrote:

> The table containing the saved file-descriptors<->{context, key} couples is

> now dynamically malloc'd in the fd server process, hence avoiding

> the memory waste which happened in other process when the table was

> staticaly reserved in all processes.

>

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

> ---

>  platform/linux-generic/_fdserver.c | 6 +++++-

>  1 file changed, 5 insertions(+), 1 deletion(-)

>

> diff --git a/platform/linux-generic/_fdserver.c b/platform/linux-generic/_

> fdserver.c

> index bf36eb2..6ad9f6e 100644

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

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

> @@ -73,7 +73,7 @@ typedef struct fdentry_s {

>         uint64_t key;

>         int  fd;

>  } fdentry_t;

> -static fdentry_t fd_table[FDSERVER_MAX_ENTRIES];

> +static fdentry_t *fd_table;

>  static int fd_table_nb_entries;

>

>  /*

> @@ -622,6 +622,10 @@ int _odp_fdserver_init_global(void)

>                 /* TODO: pin the server on appropriate service cpu mask */

>                 /* when (if) we can agree on the usage of service mask  */

>

> +               /* allocate the space for the file descriptor<->key table:

> */

> +               fd_table = malloc(FDSERVER_MAX_ENTRIES *

> sizeof(fdentry_t));

>


Since you're changing from static to dynamic allocation, where is the
corresponding free() call?


> +

> +               /* wait for clients requests */

>                 wait_requests(sock); /* Returns when server is stopped  */

>                 close(sock);

>                 exit(0);

> --

> 2.7.4

>

>
Christophe Milard Sept. 13, 2016, 11:28 a.m. UTC | #2
of course... :-)...
It really should be freed at exit only, But I agree, that should be
explicit.
will send a v2!


On 13 September 2016 at 13:25, Bill Fischofer <bill.fischofer@linaro.org>
wrote:

>

>

> On Tue, Sep 13, 2016 at 4:47 AM, Christophe Milard <

> christophe.milard@linaro.org> wrote:

>

>> The table containing the saved file-descriptors<->{context, key} couples

>> is

>> now dynamically malloc'd in the fd server process, hence avoiding

>> the memory waste which happened in other process when the table was

>> staticaly reserved in all processes.

>>

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

>> ---

>>  platform/linux-generic/_fdserver.c | 6 +++++-

>>  1 file changed, 5 insertions(+), 1 deletion(-)

>>

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

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

>> index bf36eb2..6ad9f6e 100644

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

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

>> @@ -73,7 +73,7 @@ typedef struct fdentry_s {

>>         uint64_t key;

>>         int  fd;

>>  } fdentry_t;

>> -static fdentry_t fd_table[FDSERVER_MAX_ENTRIES];

>> +static fdentry_t *fd_table;

>>  static int fd_table_nb_entries;

>>

>>  /*

>> @@ -622,6 +622,10 @@ int _odp_fdserver_init_global(void)

>>                 /* TODO: pin the server on appropriate service cpu mask */

>>                 /* when (if) we can agree on the usage of service mask  */

>>

>> +               /* allocate the space for the file descriptor<->key

>> table: */

>> +               fd_table = malloc(FDSERVER_MAX_ENTRIES *

>> sizeof(fdentry_t));

>>

>

> Since you're changing from static to dynamic allocation, where is the

> corresponding free() call?

>

>

>> +

>> +               /* wait for clients requests */

>>                 wait_requests(sock); /* Returns when server is stopped  */

>>                 close(sock);

>>                 exit(0);

>> --

>> 2.7.4

>>

>>

>
diff mbox

Patch

diff --git a/platform/linux-generic/_fdserver.c b/platform/linux-generic/_fdserver.c
index bf36eb2..6ad9f6e 100644
--- a/platform/linux-generic/_fdserver.c
+++ b/platform/linux-generic/_fdserver.c
@@ -73,7 +73,7 @@  typedef struct fdentry_s {
 	uint64_t key;
 	int  fd;
 } fdentry_t;
-static fdentry_t fd_table[FDSERVER_MAX_ENTRIES];
+static fdentry_t *fd_table;
 static int fd_table_nb_entries;
 
 /*
@@ -622,6 +622,10 @@  int _odp_fdserver_init_global(void)
 		/* TODO: pin the server on appropriate service cpu mask */
 		/* when (if) we can agree on the usage of service mask  */
 
+		/* allocate the space for the file descriptor<->key table: */
+		fd_table = malloc(FDSERVER_MAX_ENTRIES * sizeof(fdentry_t));
+
+		/* wait for clients requests */
 		wait_requests(sock); /* Returns when server is stopped  */
 		close(sock);
 		exit(0);