Skip to contentSkip to conversation

common/cnxk: fix flow aging application exit

PATCH In review [email protected] 2 participants 2 messages Jun 17, 2024 – Jun 25, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 common/cnxk: fix flow aging application exit

From: Kiran Kumar K <[email protected]>

If flow aging is enabled application termination may take time equivalent to aging timeout. This is because on termination flow thread uses a sleep call which is uninterruptible.

Fixes 357f5ebc8a24 ("common/cnxk: support flow aging")
---
 drivers/common/cnxk/roc_npc_aging.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/common/cnxk/roc_npc_aging.c +16 -1
index 15f6e61d76..66c953135a 100644
@@ -133,6 +133,21 @@ npc_mcam_get_hit_status(struct npc *npc, uint64_t *mcam_ids, uint16_t start_id,
 	return rc;
 }
 
+static void
+npc_age_wait_until(struct roc_npc_flow_age *flow_age)
+{
+#define NPC_AGE_WAIT_TIMEOUT_MS 1000
+#define NPC_AGE_WAIT_TIMEOUT_US (NPC_AGE_WAIT_TIMEOUT_MS * NPC_AGE_WAIT_TIMEOUT_MS)
+	uint64_t timeout = 0;
+	uint64_t sleep = 10 * NPC_AGE_WAIT_TIMEOUT_MS;
+
+	do {
+		plt_delay_us(sleep);
+		timeout += sleep;
+	} while (!flow_age->aged_flows_get_thread_exit &&
+		 (timeout < (flow_age->aging_poll_freq * NPC_AGE_WAIT_TIMEOUT_US)));
+}
+
 uint32_t
 npc_aged_flows_get(void *args)
 {
@@ -197,7 +212,7 @@ npc_aged_flows_get(void *args)
 		plt_seqcount_write_end(&flow_age->seq_cnt);
 
 lbl_sleep:
-		sleep(flow_age->aging_poll_freq);
+	npc_age_wait_until(flow_age);
 	}
 
 	return 0;
Signature · 1 line
2.39.2
#1 lore raw
Quoted 7 lines · On Mon, Jun 17, 2024 at 4:58 PM <[email protected]> wrote:

From: Kiran Kumar K <[email protected]>

If flow aging is enabled application termination may take time equivalent to aging timeout. This is because on termination flow thread uses a sleep call which is uninterruptible.

Quoted 6 lines
Fixes 357f5ebc8a24 ("common/cnxk: support flow aging")

Updated the git commit as follows and applied to
dpdk-next-net-mrvl/for-main. Thanks

common/cnxk: fix flow aging handling on application exit

If flow aging is enabled application termination may take time equivalent to aging timeout. This is because on termination flow thread uses a sleep call which is uninterruptible.

Fixes 357f5ebc8a24 ("common/cnxk: support flow aging")
Quoted 42 lines
---
 drivers/common/cnxk/roc_npc_aging.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/common/cnxk/roc_npc_aging.c +16 -2
index 15f6e61d76..66c953135a 100644
@@ -133,6 +133,21 @@ npc_mcam_get_hit_status(struct npc *npc, uint64_t *mcam_ids, uint16_t start_id,
        return rc;
 }
 
+static void
+npc_age_wait_until(struct roc_npc_flow_age *flow_age)
+{
+#define NPC_AGE_WAIT_TIMEOUT_MS 1000
+#define NPC_AGE_WAIT_TIMEOUT_US (NPC_AGE_WAIT_TIMEOUT_MS * NPC_AGE_WAIT_TIMEOUT_MS)
+       uint64_t timeout = 0;
+       uint64_t sleep = 10 * NPC_AGE_WAIT_TIMEOUT_MS;
+
+       do {
+               plt_delay_us(sleep);
+               timeout += sleep;
+       } while (!flow_age->aged_flows_get_thread_exit &&
+                (timeout < (flow_age->aging_poll_freq * NPC_AGE_WAIT_TIMEOUT_US)));
+}
+
 uint32_t
 npc_aged_flows_get(void *args)
 {
@@ -197,7 +212,7 @@ npc_aged_flows_get(void *args)
                plt_seqcount_write_end(&flow_age->seq_cnt);
 
 lbl_sleep:
-               sleep(flow_age->aging_poll_freq);
+       npc_age_wait_until(flow_age);
        }
 
        return 0;
--

2.39.2