DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] telemetry: remove static limit on callbacks count
@ 2021-05-06  8:27 David Marchand
  2021-05-06 10:59 ` Power, Ciara
  0 siblings, 1 reply; 3+ messages in thread
From: David Marchand @ 2021-05-06  8:27 UTC (permalink / raw)
  To: dev; +Cc: Ciara Power

This code is not performance sensitive and can be switched to dynamic
allocations.

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 lib/telemetry/rte_telemetry.h |  2 +-
 lib/telemetry/telemetry.c     | 15 +++++++++------
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h
index c08146e142..8776998b54 100644
--- a/lib/telemetry/rte_telemetry.h
+++ b/lib/telemetry/rte_telemetry.h
@@ -283,7 +283,7 @@ typedef void * (*handler)(void *sock_id);
  * @return
  *  -EINVAL for invalid parameters failure.
  *  @return
- *  -ENOENT if max callbacks limit has been reached.
+ *  -ENOMEM for mem allocation failure.
  */
 __rte_experimental
 int
diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c
index f8b0d1157b..6baba57ec2 100644
--- a/lib/telemetry/telemetry.c
+++ b/lib/telemetry/telemetry.c
@@ -27,9 +27,6 @@
 #define MAX_OUTPUT_LEN (1024 * 16)
 #define MAX_CONNECTIONS 10
 
-/** Maximum number of telemetry callbacks. */
-#define TELEMETRY_MAX_CALLBACKS 64
-
 #ifndef RTE_EXEC_ENV_WINDOWS
 static void *
 client_handler(void *socket);
@@ -62,7 +59,7 @@ static uint32_t logtype;
         rte_log_ptr(RTE_LOG_ ## l, logtype, "TELEMETRY: " __VA_ARGS__)
 
 /* list of command callbacks, with one command registered by default */
-static struct cmd_callback callbacks[TELEMETRY_MAX_CALLBACKS];
+static struct cmd_callback *callbacks;
 static int num_callbacks; /* How many commands are registered */
 /* Used when accessing or modifying list of command callbacks */
 static rte_spinlock_t callback_sl = RTE_SPINLOCK_INITIALIZER;
@@ -73,15 +70,21 @@ static uint16_t v2_clients;
 int
 rte_telemetry_register_cmd(const char *cmd, telemetry_cb fn, const char *help)
 {
+	struct cmd_callback *new_callbacks;
 	int i = 0;
 
 	if (strlen(cmd) >= MAX_CMD_LEN || fn == NULL || cmd[0] != '/'
 			|| strlen(help) >= MAX_HELP_LEN)
 		return -EINVAL;
-	if (num_callbacks >= TELEMETRY_MAX_CALLBACKS)
-		return -ENOENT;
 
 	rte_spinlock_lock(&callback_sl);
+	new_callbacks = realloc(callbacks, sizeof(callbacks[0]) * (num_callbacks + 1));
+	if (new_callbacks == NULL) {
+		rte_spinlock_unlock(&callback_sl);
+		return -ENOMEM;
+	}
+	callbacks = new_callbacks;
+
 	while (i < num_callbacks && strcmp(cmd, callbacks[i].cmd) > 0)
 		i++;
 	if (i != num_callbacks)
-- 
2.23.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] telemetry: remove static limit on callbacks count
  2021-05-06  8:27 [dpdk-dev] [PATCH] telemetry: remove static limit on callbacks count David Marchand
@ 2021-05-06 10:59 ` Power, Ciara
  2021-06-03 16:43   ` David Marchand
  0 siblings, 1 reply; 3+ messages in thread
From: Power, Ciara @ 2021-05-06 10:59 UTC (permalink / raw)
  To: David Marchand, dev; +Cc: Richardson, Bruce

Hi David,

>-----Original Message-----
>From: David Marchand <david.marchand@redhat.com>
>Sent: Thursday 6 May 2021 09:28
>To: dev@dpdk.org
>Cc: Power, Ciara <ciara.power@intel.com>
>Subject: [PATCH] telemetry: remove static limit on callbacks count
>
>This code is not performance sensitive and can be switched to dynamic
>allocations.
>
>Signed-off-by: David Marchand <david.marchand@redhat.com>
>---
<snip>

This patch looks good to me - thanks.

Acked-by: Ciara Power <ciara.power@intel.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] telemetry: remove static limit on callbacks count
  2021-05-06 10:59 ` Power, Ciara
@ 2021-06-03 16:43   ` David Marchand
  0 siblings, 0 replies; 3+ messages in thread
From: David Marchand @ 2021-06-03 16:43 UTC (permalink / raw)
  To: David Marchand; +Cc: dev, Richardson, Bruce, Power, Ciara

On Thu, May 6, 2021 at 12:59 PM Power, Ciara <ciara.power@intel.com> wrote:
> >This code is not performance sensitive and can be switched to dynamic
> >allocations.
> >
> >Signed-off-by: David Marchand <david.marchand@redhat.com>
> Acked-by: Ciara Power <ciara.power@intel.com>

Applied.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-06-03 16:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-06  8:27 [dpdk-dev] [PATCH] telemetry: remove static limit on callbacks count David Marchand
2021-05-06 10:59 ` Power, Ciara
2021-06-03 16:43   ` David Marchand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).