Skip to contentSkip to conversation

eventdev: add device stop flush callback

PATCH Superseded Gage Eads 4 participants 28 messages Mar 5, 2018 – Apr 3, 2018

lore
Share & tools
lore

Gage Eads

author
#0 lore raw

PATCH 1/2 eventdev: add device stop flush callback

When an event device is stopped, it drains all event queues. These events may contain pointers, so to prevent memory leaks eventdev now supports a user-provided flush callback that is called during the queue drain process. This callback is stored in process memory, so the callback must be registered by any process that may call rte_event_dev_stop().

This commit also clarifies the behavior of rte_event_dev_stop().

This follows this mailing list discussion:
http://dpdk.org/ml/archives/dev/2018-January/087484.html

---
 lib/librte_eventdev/rte_eventdev.c           | 20 +++++++++++
 lib/librte_eventdev/rte_eventdev.h           | 53 ++++++++++++++++++++++++++--
 lib/librte_eventdev/rte_eventdev_version.map |  6 ++++
 3 files changed, 77 insertions(+), 2 deletions(-)
lib/librte_eventdev/rte_eventdev.c +20 -0
index 851a119..7de44f9 100644
@@ -1123,6 +1123,26 @@ rte_event_dev_start(uint8_t dev_id)
 	return 0;
 }
 
+int
+rte_event_dev_stop_flush_callback_register(uint8_t dev_id,
+		eventdev_stop_flush_t callback, void *userdata)
+{
+	struct rte_eventdev *dev;
+
+	RTE_EDEV_LOG_DEBUG("Stop flush register dev_id=%" PRIu8, dev_id);
+
+	RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
+	dev = &rte_eventdevs[dev_id];
+
+	if (callback == NULL)
+		return -EINVAL;
+
+	dev->dev_stop_flush = callback;
+	dev->dev_stop_flush_arg = userdata;
+
+	return 0;
+}
+
 void
 rte_event_dev_stop(uint8_t dev_id)
 {
lib/librte_eventdev/rte_eventdev.h +51 -2

80 lines not on this page · raw message

lib/librte_eventdev/rte_eventdev_version.map +6 -0
index 2aef470..4396536 100644
@@ -74,3 +74,9 @@ DPDK_18.02 {
 
 	rte_event_dev_selftest;
 } DPDK_17.11;
+
+DPDK_18.05 {
+	global:
+
+	rte_event_dev_stop_flush_callback_register;
+} DPDK_18.02;
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 2/2 event/sw: support device stop flush callback

This commit also adds a flush callback test to the sw eventdev's selftest suite.

---
 drivers/event/sw/sw_evdev.c          | 25 +++++++++++-
 drivers/event/sw/sw_evdev_selftest.c | 75 +++++++++++++++++++++++++++++++++++-
 2 files changed, 97 insertions(+), 3 deletions(-)
drivers/event/sw/sw_evdev.c +23 -2
index 6672fd8..4b57e5b 100644
@@ -362,8 +362,25 @@ sw_init_qid_iqs(struct sw_evdev *sw)
 }
 
 static void
-sw_clean_qid_iqs(struct sw_evdev *sw)
+sw_flush_iq(struct rte_eventdev *dev, struct sw_iq *iq)
 {
+	struct sw_evdev *sw = sw_pmd_priv(dev);
+
+	while (iq_count(iq) > 0) {
+		struct rte_event event;
+
+		iq_dequeue_burst(sw, iq, &event, 1);
+
+		dev->dev_stop_flush(dev->data->dev_id,
+				    event,
+				    dev->dev_stop_flush_arg);
+	}
+}
+
+static void
+sw_clean_qid_iqs(struct rte_eventdev *dev)
+{
+	struct sw_evdev *sw = sw_pmd_priv(dev);
 	int i, j;
 
 	/* Release the IQ memory of all configured qids */
@@ -373,7 +390,11 @@ sw_clean_qid_iqs(struct sw_evdev *sw)
 		for (j = 0; j < SW_IQS_MAX; j++) {
 			if (!qid->iq[j].head)
 				continue;
+
+			if (dev->dev_stop_flush)
+				sw_flush_iq(dev, &qid->iq[j]);
 			iq_free_chunk_list(sw, qid->iq[j].head);
+
 			qid->iq[j].head = NULL;
 		}
 	}
@@ -702,7 +723,7 @@ static void
 sw_stop(struct rte_eventdev *dev)
 {
 	struct sw_evdev *sw = sw_pmd_priv(dev);
-	sw_clean_qid_iqs(sw);
+	sw_clean_qid_iqs(dev);
 	sw_xstats_uninit(sw);
 	sw->started = 0;
 	rte_smp_wmb();
drivers/event/sw/sw_evdev_selftest.c +74 -1

99 lines not on this page · raw message

Signature · 1 line
2.7.4
author
#2 lore raw

PATCH v2 1/2 eventdev: add device stop flush callback

In reply to Gage Eads

When an event device is stopped, it drains all event queues. These events may contain pointers, so to prevent memory leaks eventdev now supports a user-provided flush callback that is called during the queue drain process. This callback is stored in process memory, so the callback must be registered by any process that may call rte_event_dev_stop().

This commit also clarifies the behavior of rte_event_dev_stop().

This follows this mailing list discussion:
http://dpdk.org/ml/archives/dev/2018-January/087484.html

---
v2: allow a NULL callback pointer to unregister the callback

 lib/librte_eventdev/rte_eventdev.c           | 17 +++++++++
 lib/librte_eventdev/rte_eventdev.h           | 55 +++++++++++++++++++++++++++-
 lib/librte_eventdev/rte_eventdev_version.map |  6 +++
 3 files changed, 76 insertions(+), 2 deletions(-)
lib/librte_eventdev/rte_eventdev.c +17 -0
index 851a119..1aacb7b 100644
@@ -1123,6 +1123,23 @@ rte_event_dev_start(uint8_t dev_id)
 	return 0;
 }
 
+int
+rte_event_dev_stop_flush_callback_register(uint8_t dev_id,
+		eventdev_stop_flush_t callback, void *userdata)
+{
+	struct rte_eventdev *dev;
+
+	RTE_EDEV_LOG_DEBUG("Stop flush register dev_id=%" PRIu8, dev_id);
+
+	RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
+	dev = &rte_eventdevs[dev_id];
+
+	dev->dev_stop_flush = callback;
+	dev->dev_stop_flush_arg = userdata;
+
+	return 0;
+}
+
 void
 rte_event_dev_stop(uint8_t dev_id)
 {
lib/librte_eventdev/rte_eventdev.h +53 -2

82 lines not on this page · raw message

lib/librte_eventdev/rte_eventdev_version.map +6 -0
index 2aef470..4396536 100644
@@ -74,3 +74,9 @@ DPDK_18.02 {
 
 	rte_event_dev_selftest;
 } DPDK_17.11;
+
+DPDK_18.05 {
+	global:
+
+	rte_event_dev_stop_flush_callback_register;
+} DPDK_18.02;
Signature · 1 line
2.7.4
author
#3 lore raw

PATCH v2 2/2 event/sw: support device stop flush callback

This commit also adds a flush callback test to the sw eventdev's selftest suite.

---
 drivers/event/sw/sw_evdev.c          | 25 ++++++++++-
 drivers/event/sw/sw_evdev_selftest.c | 80 +++++++++++++++++++++++++++++++++++-
 2 files changed, 102 insertions(+), 3 deletions(-)
drivers/event/sw/sw_evdev.c +23 -2
index 6672fd8..4b57e5b 100644
@@ -362,8 +362,25 @@ sw_init_qid_iqs(struct sw_evdev *sw)
 }
 
 static void
-sw_clean_qid_iqs(struct sw_evdev *sw)
+sw_flush_iq(struct rte_eventdev *dev, struct sw_iq *iq)
 {
+	struct sw_evdev *sw = sw_pmd_priv(dev);
+
+	while (iq_count(iq) > 0) {
+		struct rte_event event;
+
+		iq_dequeue_burst(sw, iq, &event, 1);
+
+		dev->dev_stop_flush(dev->data->dev_id,
+				    event,
+				    dev->dev_stop_flush_arg);
+	}
+}
+
+static void
+sw_clean_qid_iqs(struct rte_eventdev *dev)
+{
+	struct sw_evdev *sw = sw_pmd_priv(dev);
 	int i, j;
 
 	/* Release the IQ memory of all configured qids */
@@ -373,7 +390,11 @@ sw_clean_qid_iqs(struct sw_evdev *sw)
 		for (j = 0; j < SW_IQS_MAX; j++) {
 			if (!qid->iq[j].head)
 				continue;
+
+			if (dev->dev_stop_flush)
+				sw_flush_iq(dev, &qid->iq[j]);
 			iq_free_chunk_list(sw, qid->iq[j].head);
+
 			qid->iq[j].head = NULL;
 		}
 	}
@@ -702,7 +723,7 @@ static void
 sw_stop(struct rte_eventdev *dev)
 {
 	struct sw_evdev *sw = sw_pmd_priv(dev);
-	sw_clean_qid_iqs(sw);
+	sw_clean_qid_iqs(dev);
 	sw_xstats_uninit(sw);
 	sw->started = 0;
 	rte_smp_wmb();
drivers/event/sw/sw_evdev_selftest.c +79 -1

104 lines not on this page · raw message

Signature · 1 line
2.7.4
#4 lore raw
In reply to Gage Eads

-----Original Message-----

Quoted 38 lines

When an event device is stopped, it drains all event queues. These events may contain pointers, so to prevent memory leaks eventdev now supports a user-provided flush callback that is called during the queue drain process. This callback is stored in process memory, so the callback must be registered by any process that may call rte_event_dev_stop().

This commit also clarifies the behavior of rte_event_dev_stop().

This follows this mailing list discussion:
http://dpdk.org/ml/archives/dev/2018-January/087484.html

---
v2: allow a NULL callback pointer to unregister the callback

 lib/librte_eventdev/rte_eventdev.c           | 17 +++++++++
 lib/librte_eventdev/rte_eventdev.h           | 55 +++++++++++++++++++++++++++-
 lib/librte_eventdev/rte_eventdev_version.map |  6 +++
 3 files changed, 76 insertions(+), 2 deletions(-)
lib/librte_eventdev/rte_eventdev.c +6 -0
index 851a119..1aacb7b 100644
@@ -1123,6 +1123,23 @@ rte_event_dev_start(uint8_t dev_id)
 	return 0;
 }
 
+typedef void (*eventdev_stop_flush_t)(uint8_t dev_id, struct rte_event event,
+		void *arg);
+/**< Callback function called during rte_event_dev_stop(), invoked once per
+ * flushed event.
+ */
+
 #define RTE_EVENTDEV_NAME_MAX_LEN	(64)
 /**< @internal Max length of name of event PMD */
 

lib/librte_eventdev/rte_eventdev.c struct rte_eventdev { · line 1201

Quoted 8 lines
lib/librte_eventdev/rte_eventdev.c +5 -0
@@ -1176,6 +1194,11 @@ struct rte_eventdev {
 	event_dequeue_burst_t dequeue_burst;
 	/**< Pointer to PMD dequeue burst function. */
 
+	eventdev_stop_flush_t dev_stop_flush;
+	/**< Optional, user-provided event flush function */
+	void *dev_stop_flush_arg;
+	/**< User-provided argument for event flush function */
+

I think, we can move this additions to the internal rte_eventdev_data structure. Reasons are
1) Changes to "struct rte_eventdev" would call for ABI change
2) We can keep "struct rte_eventdev" only for fast path functions,
slow path functions can have additional redirection.

Quoted 25 lines
lib/librte_eventdev/rte_eventdev.c +18 -0
 	struct rte_eventdev_data *data;
 	/**< Pointer to device data */
 	const struct rte_eventdev_ops *dev_ops;
@@ -1822,6 +1845,34 @@ rte_event_dev_xstats_reset(uint8_t dev_id,
  */
 int rte_event_dev_selftest(uint8_t dev_id);
 
+/**
+ * Registers a callback function to be invoked during rte_event_dev_stop() for
+ * each flushed event. This function can be used to properly dispose of queued
+ * events, for example events containing memory pointers.
+ *
+ * The callback function is only registered for the calling process. The
+ * callback function must be registered in every process that can call
+ * rte_event_dev_stop().
+ *
+ * To unregister a callback, call this function with a NULL callback pointer.
+ *
+ * @param dev_id
+ *   The identifier of the device.
+ * @param callback
+ *   Callback function invoked once per flushed event.
+ * @param userdata
+ *   Argument supplied to callback.
+ *

lib/librte_eventdev/rte_eventdev.c rte_event_dev_xstats_reset(uint8_t dev_id, · line 1875

Quoted 10 lines
lib/librte_eventdev/rte_eventdev.c +10 -0
+ * @return
+ *  - 0 on success.
+ *  - -EINVAL if *dev_id* is invalid
+ *
+ * @see rte_event_dev_stop()
+ */
+int
+rte_event_dev_stop_flush_callback_register(uint8_t dev_id,
+		eventdev_stop_flush_t callback, void *userdata);
+

IMO, It would be better if we place this function near to rte_event_dev_stop().

Other than above minor changes, It looks good to me.

author
#5 lore raw
Quoted 57 lines

-----Original Message-----
From: Jerin Jacob [mailto:[email protected]]
Sent: Monday, March 12, 2018 1:25 AM
To: Eads, Gage <[email protected]>
Cc: [email protected]; Van Haaren, Harry <[email protected]>; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v2 1/2] eventdev: add device stop flush callback

-----Original Message-----

Quoted 3 lines

When an event device is stopped, it drains all event queues. These events may contain pointers, so to prevent memory leaks eventdev now supports a user-provided flush callback that is called during the queue drain

process.

Quoted 8 lines

This callback is stored in process memory, so the callback must be registered by any process that may call rte_event_dev_stop().

This commit also clarifies the behavior of rte_event_dev_stop().

This follows this mailing list discussion:
http://dpdk.org/ml/archives/dev/2018-January/087484.html

Quoted 6 lines

---
v2: allow a NULL callback pointer to unregister the callback

 lib/librte_eventdev/rte_eventdev.c           | 17 +++++++++
 lib/librte_eventdev/rte_eventdev.h           | 55

+++++++++++++++++++++++++++-

Quoted 26 lines
 lib/librte_eventdev/rte_eventdev_version.map |  6 +++
 3 files changed, 76 insertions(+), 2 deletions(-)
lib/librte_eventdev/rte_eventdev.c +7 -0
index 851a119..1aacb7b 100644
@@ -1123,6 +1123,23 @@ rte_event_dev_start(uint8_t dev_id)
 	return 0;
 }
 
+typedef void (*eventdev_stop_flush_t)(uint8_t dev_id, struct rte_event event,
+		void *arg);
+/**< Callback function called during rte_event_dev_stop(), invoked
+once per
+ * flushed event.
+ */
+
 #define RTE_EVENTDEV_NAME_MAX_LEN	(64)
 /**< @internal Max length of name of event PMD */
 
@@ -1176,6 +1194,11 @@ struct rte_eventdev {
 	event_dequeue_burst_t dequeue_burst;
 	/**< Pointer to PMD dequeue burst function. */
 
Quoted 12 lines

lib/librte_eventdev/rte_eventdev.c struct rte_eventdev { · line 1201

Quoted 5 lines
lib/librte_eventdev/rte_eventdev.c +5 -0
+	eventdev_stop_flush_t dev_stop_flush;
+	/**< Optional, user-provided event flush function */
+	void *dev_stop_flush_arg;
+	/**< User-provided argument for event flush function */
+

I think, we can move this additions to the internal rte_eventdev_data structure. Reasons are
1) Changes to "struct rte_eventdev" would call for ABI change
2) We can keep "struct rte_eventdev" only for fast path functions, slow path functions can have additional redirection.

Good points -- I hadn't considered the ABI impact of modifying rte_eventdev. rte_eventdev_data is in shared memory, though, so it's not multi-process friendly for function pointers. How about putting it in rte_eventdev_ops?

Quoted 41 lines
Quoted 29 lines
lib/librte_eventdev/rte_eventdev.c +0 -0
 	struct rte_eventdev_data *data;
 	/**< Pointer to device data */
 	const struct rte_eventdev_ops *dev_ops; @@ -1822,6 +1845,34 @@

rte_event_dev_xstats_reset(uint8_t dev_id,
*/
int rte_event_dev_selftest(uint8_t dev_id);

lib/librte_eventdev/rte_eventdev.c +22 -0
+/**
+ * Registers a callback function to be invoked during
+rte_event_dev_stop() for
+ * each flushed event. This function can be used to properly dispose
+of queued
+ * events, for example events containing memory pointers.
+ *
+ * The callback function is only registered for the calling process.
+The
+ * callback function must be registered in every process that can
+call
+ * rte_event_dev_stop().
+ *
+ * To unregister a callback, call this function with a NULL callback pointer.
+ *
+ * @param dev_id
+ *   The identifier of the device.
+ * @param callback
+ *   Callback function invoked once per flushed event.
+ * @param userdata
+ *   Argument supplied to callback.
+ *

lib/librte_eventdev/rte_eventdev.c

Quoted 10 lines
lib/librte_eventdev/rte_eventdev.c +10 -0
+ * @return
+ *  - 0 on success.
+ *  - -EINVAL if *dev_id* is invalid
+ *
+ * @see rte_event_dev_stop()
+ */
+int
+rte_event_dev_stop_flush_callback_register(uint8_t dev_id,
+		eventdev_stop_flush_t callback, void *userdata);
+

IMO, It would be better if we place this function near to rte_event_dev_stop().

Quoted 1 line

Other than above minor changes, It looks good to me.

Ok, will address in v3.

Thanks,
Gage

#6 lore raw

-----Original Message-----

Quoted 81 lines

Date: Mon, 12 Mar 2018 14:30:49 +0000
From: "Eads, Gage" <[email protected]>
To: Jerin Jacob <[email protected]>
CC: "[email protected]" <[email protected]>, "Van Haaren, Harry"
<[email protected]>, "[email protected]" <[email protected]>, "Richardson, Bruce" <[email protected]>, "[email protected]" <[email protected]>, "[email protected]" <[email protected]>
Subject: RE: [PATCH v2 1/2] eventdev: add device stop flush callback

Quoted 55 lines

-----Original Message-----
From: Jerin Jacob [mailto:[email protected]]
Sent: Monday, March 12, 2018 1:25 AM
To: Eads, Gage <[email protected]>
Cc: [email protected]; Van Haaren, Harry <[email protected]>; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v2 1/2] eventdev: add device stop flush callback

-----Original Message-----

Quoted 3 lines

When an event device is stopped, it drains all event queues. These events may contain pointers, so to prevent memory leaks eventdev now supports a user-provided flush callback that is called during the queue drain

process.

Quoted 8 lines

This callback is stored in process memory, so the callback must be registered by any process that may call rte_event_dev_stop().

This commit also clarifies the behavior of rte_event_dev_stop().

This follows this mailing list discussion:
http://dpdk.org/ml/archives/dev/2018-January/087484.html

Quoted 6 lines

---
v2: allow a NULL callback pointer to unregister the callback

 lib/librte_eventdev/rte_eventdev.c           | 17 +++++++++
 lib/librte_eventdev/rte_eventdev.h           | 55

+++++++++++++++++++++++++++-

Quoted 26 lines
 lib/librte_eventdev/rte_eventdev_version.map |  6 +++
 3 files changed, 76 insertions(+), 2 deletions(-)
lib/librte_eventdev/rte_eventdev.c +7 -0
index 851a119..1aacb7b 100644
@@ -1123,6 +1123,23 @@ rte_event_dev_start(uint8_t dev_id)
 	return 0;
 }
 
+typedef void (*eventdev_stop_flush_t)(uint8_t dev_id, struct rte_event event,
+		void *arg);
+/**< Callback function called during rte_event_dev_stop(), invoked
+once per
+ * flushed event.
+ */
+
 #define RTE_EVENTDEV_NAME_MAX_LEN	(64)
 /**< @internal Max length of name of event PMD */
 
@@ -1176,6 +1194,11 @@ struct rte_eventdev {
 	event_dequeue_burst_t dequeue_burst;
 	/**< Pointer to PMD dequeue burst function. */
 
Quoted 12 lines

lib/librte_eventdev/rte_eventdev.c struct rte_eventdev { · line 1201

Quoted 5 lines
lib/librte_eventdev/rte_eventdev.c +5 -0
+	eventdev_stop_flush_t dev_stop_flush;
+	/**< Optional, user-provided event flush function */
+	void *dev_stop_flush_arg;
+	/**< User-provided argument for event flush function */
+

I think, we can move this additions to the internal rte_eventdev_data structure. Reasons are
1) Changes to "struct rte_eventdev" would call for ABI change
2) We can keep "struct rte_eventdev" only for fast path functions, slow path functions can have additional redirection.

Quoted 1 line

Good points -- I hadn't considered the ABI impact of modifying rte_eventdev. rte_eventdev_data is in shared memory, though, so it's not multi-process friendly for function pointers. How about putting it in rte_eventdev_ops?

Yes. Make sense to move to rte_eventdev_ops. But need to take care updating the those function pointers in secondary process.

author
#7 lore raw

PATCH v3 1/2 eventdev: add device stop flush callback

In reply to Gage Eads

When an event device is stopped, it drains all event queues. These events may contain pointers, so to prevent memory leaks eventdev now supports a user-provided flush callback that is called during the queue drain process. This callback is stored in process memory, so the callback must be registered by any process that may call rte_event_dev_stop().

This commit also clarifies the behavior of rte_event_dev_stop().

This follows this mailing list discussion:
http://dpdk.org/ml/archives/dev/2018-January/087484.html

---
v2: allow a NULL callback pointer to unregister the callback
v3: move the callback pointer to struct rte_eventdev_ops and
the user argument to struct rte_eventdev_data.

 drivers/event/dpaa/dpaa_eventdev.c           |  3 +-
 drivers/event/dpaa2/dpaa2_eventdev.c         |  3 +-
 drivers/event/octeontx/ssovf_evdev.c         |  6 ++-
 drivers/event/opdl/opdl_evdev.c              |  4 +-
 drivers/event/skeleton/skeleton_eventdev.c   |  5 ++-
 drivers/event/sw/sw_evdev.c                  |  4 +-
 lib/librte_eventdev/rte_eventdev.c           | 17 +++++++++
 lib/librte_eventdev/rte_eventdev.h           | 55 ++++++++++++++++++++++++++--
 lib/librte_eventdev/rte_eventdev_pmd.h       |  3 ++
 lib/librte_eventdev/rte_eventdev_version.map |  6 +++
 10 files changed, 95 insertions(+), 11 deletions(-)
drivers/event/dpaa/dpaa_eventdev.c +2 -1
index 0006801..4bf1918 100644
@@ -571,7 +571,7 @@ dpaa_event_eth_rx_adapter_stop(const struct rte_eventdev *dev,
 	return 0;
 }
 
-static const struct rte_eventdev_ops dpaa_eventdev_ops = {
+static struct rte_eventdev_ops dpaa_eventdev_ops = {
 	.dev_infos_get    = dpaa_event_dev_info_get,
 	.dev_configure    = dpaa_event_dev_configure,
 	.dev_start        = dpaa_event_dev_start,
@@ -591,6 +591,7 @@ static const struct rte_eventdev_ops dpaa_eventdev_ops = {
 	.eth_rx_adapter_queue_del = dpaa_event_eth_rx_adapter_queue_del,
 	.eth_rx_adapter_start = dpaa_event_eth_rx_adapter_start,
 	.eth_rx_adapter_stop = dpaa_event_eth_rx_adapter_stop,
+	.dev_stop_flush   = NULL,
 };
 
 static int
drivers/event/dpaa2/dpaa2_eventdev.c +2 -1
index c3e6fbf..363837a 100644
@@ -693,7 +693,7 @@ dpaa2_eventdev_eth_stop(const struct rte_eventdev *dev,
 	return 0;
 }
 
-static const struct rte_eventdev_ops dpaa2_eventdev_ops = {
+static struct rte_eventdev_ops dpaa2_eventdev_ops = {
 	.dev_infos_get    = dpaa2_eventdev_info_get,
 	.dev_configure    = dpaa2_eventdev_configure,
 	.dev_start        = dpaa2_eventdev_start,
@@ -714,6 +714,7 @@ static const struct rte_eventdev_ops dpaa2_eventdev_ops = {
 	.eth_rx_adapter_queue_del = dpaa2_eventdev_eth_queue_del,
 	.eth_rx_adapter_start = dpaa2_eventdev_eth_start,
 	.eth_rx_adapter_stop = dpaa2_eventdev_eth_stop,
+	.dev_stop_flush   = NULL,
 };
 
 static int
drivers/event/octeontx/ssovf_evdev.c +4 -2
index a108607..713983b 100644
@@ -591,7 +591,7 @@ ssovf_selftest(const char *key __rte_unused, const char *value,
 }
 
 /* Initialize and register event driver with DPDK Application */
-static const struct rte_eventdev_ops ssovf_ops = {
+static struct rte_eventdev_ops ssovf_ops = {
 	.dev_infos_get    = ssovf_info_get,
 	.dev_configure    = ssovf_configure,
 	.queue_def_conf   = ssovf_queue_def_conf,
@@ -615,7 +615,9 @@ static const struct rte_eventdev_ops ssovf_ops = {
 	.dump             = ssovf_dump,
 	.dev_start        = ssovf_start,
 	.dev_stop         = ssovf_stop,
-	.dev_close        = ssovf_close
+	.dev_close        = ssovf_close,
+
+	.dev_stop_flush   = NULL
 };
 
 static int
drivers/event/opdl/opdl_evdev.c +3 -1
index 7708369..477e102 100644
@@ -607,7 +607,7 @@ set_do_test(const char *key __rte_unused, const char *value, void *opaque)
 static int
 opdl_probe(struct rte_vdev_device *vdev)
 {
-	static const struct rte_eventdev_ops evdev_opdl_ops = {
+	static struct rte_eventdev_ops evdev_opdl_ops = {
 		.dev_configure = opdl_dev_configure,
 		.dev_infos_get = opdl_info_get,
 		.dev_close = opdl_close,
@@ -629,6 +629,8 @@ opdl_probe(struct rte_vdev_device *vdev)
 		.xstats_get_names = opdl_xstats_get_names,
 		.xstats_get_by_name = opdl_xstats_get_by_name,
 		.xstats_reset = opdl_xstats_reset,
+
+		.dev_stop_flush = NULL,
 	};
 
 	static const char *const args[] = {
drivers/event/skeleton/skeleton_eventdev.c +3 -2
index 7f46756..c627f01 100644
@@ -319,7 +319,7 @@ skeleton_eventdev_dump(struct rte_eventdev *dev, FILE *f)
 
 
 /* Initialize and register event driver with DPDK Application */
-static const struct rte_eventdev_ops skeleton_eventdev_ops = {
+static struct rte_eventdev_ops skeleton_eventdev_ops = {
 	.dev_infos_get    = skeleton_eventdev_info_get,
 	.dev_configure    = skeleton_eventdev_configure,
 	.dev_start        = skeleton_eventdev_start,
@@ -334,7 +334,8 @@ static const struct rte_eventdev_ops skeleton_eventdev_ops = {
 	.port_link        = skeleton_eventdev_port_link,
 	.port_unlink      = skeleton_eventdev_port_unlink,
 	.timeout_ticks    = skeleton_eventdev_timeout_ticks,
-	.dump             = skeleton_eventdev_dump
+	.dump             = skeleton_eventdev_dump,
+	.dev_stop_flush   = NULL
 };
 
 static int
drivers/event/sw/sw_evdev.c +3 -1
index 6672fd8..bda2e21 100644
@@ -772,7 +772,7 @@ static int32_t sw_sched_service_func(void *args)
 static int
 sw_probe(struct rte_vdev_device *vdev)
 {
-	static const struct rte_eventdev_ops evdev_sw_ops = {
+	static struct rte_eventdev_ops evdev_sw_ops = {
 			.dev_configure = sw_dev_configure,
 			.dev_infos_get = sw_info_get,
 			.dev_close = sw_close,
@@ -797,6 +797,8 @@ sw_probe(struct rte_vdev_device *vdev)
 			.xstats_reset = sw_xstats_reset,
 
 			.dev_selftest = test_sw_eventdev,
+
+			.dev_stop_flush = NULL,
 	};
 
 	static const char *const args[] = {
lib/librte_eventdev/rte_eventdev.c +17 -0
index 851a119..2de8d9a 100644
@@ -1123,6 +1123,23 @@ rte_event_dev_start(uint8_t dev_id)
 	return 0;
 }
 
+int
+rte_event_dev_stop_flush_callback_register(uint8_t dev_id,
+		eventdev_stop_flush_t callback, void *userdata)
+{
+	struct rte_eventdev *dev;
+
+	RTE_EDEV_LOG_DEBUG("Stop flush register dev_id=%" PRIu8, dev_id);
+
+	RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
+	dev = &rte_eventdevs[dev_id];
+
+	dev->dev_ops->dev_stop_flush = callback;
+	dev->data->dev_stop_flush_arg = userdata;
+
+	return 0;
+}
+
 void
 rte_event_dev_stop(uint8_t dev_id)
 {
lib/librte_eventdev/rte_eventdev.h +52 -3

86 lines not on this page · raw message

lib/librte_eventdev/rte_eventdev_pmd.h +3 -0
index 31343b5..3a8ddd7 100644
@@ -642,6 +642,9 @@ struct rte_eventdev_ops {
 
 	eventdev_selftest dev_selftest;
 	/**< Start eventdev Selftest */
+
+	eventdev_stop_flush_t dev_stop_flush;
+	/**< User-provided event flush function */
 };
 
 /**
lib/librte_eventdev/rte_eventdev_version.map +6 -0
index 2aef470..4396536 100644
@@ -74,3 +74,9 @@ DPDK_18.02 {
 
 	rte_event_dev_selftest;
 } DPDK_17.11;
+
+DPDK_18.05 {
+	global:
+
+	rte_event_dev_stop_flush_callback_register;
+} DPDK_18.02;
Signature · 1 line
2.7.4
author
#8 lore raw

PATCH v3 2/2 event/sw: support device stop flush callback

This commit also adds a flush callback test to the sw eventdev's selftest suite.

---
 drivers/event/sw/sw_evdev.c          | 25 ++++++++++-
 drivers/event/sw/sw_evdev_selftest.c | 80 +++++++++++++++++++++++++++++++++++-
 2 files changed, 102 insertions(+), 3 deletions(-)
drivers/event/sw/sw_evdev.c +23 -2
index bda2e21..8d7fe8a 100644
@@ -362,8 +362,25 @@ sw_init_qid_iqs(struct sw_evdev *sw)
 }
 
 static void
-sw_clean_qid_iqs(struct sw_evdev *sw)
+sw_flush_iq(struct rte_eventdev *dev, struct sw_iq *iq)
 {
+	struct sw_evdev *sw = sw_pmd_priv(dev);
+
+	while (iq_count(iq) > 0) {
+		struct rte_event event;
+
+		iq_dequeue_burst(sw, iq, &event, 1);
+
+		dev->dev_ops->dev_stop_flush(dev->data->dev_id,
+					     event,
+					     dev->data->dev_stop_flush_arg);
+	}
+}
+
+static void
+sw_clean_qid_iqs(struct rte_eventdev *dev)
+{
+	struct sw_evdev *sw = sw_pmd_priv(dev);
 	int i, j;
 
 	/* Release the IQ memory of all configured qids */
@@ -373,7 +390,11 @@ sw_clean_qid_iqs(struct sw_evdev *sw)
 		for (j = 0; j < SW_IQS_MAX; j++) {
 			if (!qid->iq[j].head)
 				continue;
+
+			if (dev->dev_ops->dev_stop_flush)
+				sw_flush_iq(dev, &qid->iq[j]);
 			iq_free_chunk_list(sw, qid->iq[j].head);
+
 			qid->iq[j].head = NULL;
 		}
 	}
@@ -702,7 +723,7 @@ static void
 sw_stop(struct rte_eventdev *dev)
 {
 	struct sw_evdev *sw = sw_pmd_priv(dev);
-	sw_clean_qid_iqs(sw);
+	sw_clean_qid_iqs(dev);
 	sw_xstats_uninit(sw);
 	sw->started = 0;
 	rte_smp_wmb();
drivers/event/sw/sw_evdev_selftest.c +79 -1

104 lines not on this page · raw message

Signature · 1 line
2.7.4
#9 lore raw
In reply to Gage Eads

-----Original Message-----

Quoted 52 lines

Date: Wed, 14 Mar 2018 23:12:09 -0500
From: Gage Eads <[email protected]>
To: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected], [email protected], [email protected]
Subject: [PATCH v3 1/2] eventdev: add device stop flush callback
X-Mailer: git-send-email 2.7.4

When an event device is stopped, it drains all event queues. These events may contain pointers, so to prevent memory leaks eventdev now supports a user-provided flush callback that is called during the queue drain process. This callback is stored in process memory, so the callback must be registered by any process that may call rte_event_dev_stop().

This commit also clarifies the behavior of rte_event_dev_stop().

This follows this mailing list discussion:
http://dpdk.org/ml/archives/dev/2018-January/087484.html

---
v2: allow a NULL callback pointer to unregister the callback
v3: move the callback pointer to struct rte_eventdev_ops and
the user argument to struct rte_eventdev_data.

 drivers/event/dpaa/dpaa_eventdev.c           |  3 +-
 drivers/event/dpaa2/dpaa2_eventdev.c         |  3 +-
 drivers/event/octeontx/ssovf_evdev.c         |  6 ++-
 drivers/event/opdl/opdl_evdev.c              |  4 +-
 drivers/event/skeleton/skeleton_eventdev.c   |  5 ++-
 drivers/event/sw/sw_evdev.c                  |  4 +-
 lib/librte_eventdev/rte_eventdev.c           | 17 +++++++++
 lib/librte_eventdev/rte_eventdev.h           | 55 ++++++++++++++++++++++++++--
 lib/librte_eventdev/rte_eventdev_pmd.h       |  3 ++
 lib/librte_eventdev/rte_eventdev_version.map |  6 +++
 10 files changed, 95 insertions(+), 11 deletions(-)
drivers/event/dpaa/dpaa_eventdev.c +1 -1
index 0006801..4bf1918 100644
@@ -571,7 +571,7 @@ dpaa_event_eth_rx_adapter_stop(const struct rte_eventdev *dev,
 	return 0;
 }
 
-static const struct rte_eventdev_ops dpaa_eventdev_ops = {
+static struct rte_eventdev_ops dpaa_eventdev_ops = {
 	.dev_infos_get    = dpaa_event_dev_info_get,
 	.dev_configure    = dpaa_event_dev_configure,
 	.dev_start        = dpaa_event_dev_start,

drivers/event/dpaa/dpaa_eventdev.c static const struct rte_eventdev_ops dpaa_eventdev_ops = { · line 594

Quoted 4 lines
drivers/event/dpaa/dpaa_eventdev.c +1 -0
@@ -591,6 +591,7 @@ static const struct rte_eventdev_ops dpaa_eventdev_ops = {
 	.eth_rx_adapter_queue_del = dpaa_event_eth_rx_adapter_queue_del,
 	.eth_rx_adapter_start = dpaa_event_eth_rx_adapter_start,
 	.eth_rx_adapter_stop = dpaa_event_eth_rx_adapter_stop,
+	.dev_stop_flush   = NULL,

Do we need explicit NULL assignment here. It will be NULL by default.

Quoted 17 lines
drivers/event/dpaa/dpaa_eventdev.c +0 -0
 };
 
 static int
drivers/event/dpaa2/dpaa2_eventdev.c +1 -1
index c3e6fbf..363837a 100644
@@ -693,7 +693,7 @@ dpaa2_eventdev_eth_stop(const struct rte_eventdev *dev,
 	return 0;
 }
 
-static const struct rte_eventdev_ops dpaa2_eventdev_ops = {
+static struct rte_eventdev_ops dpaa2_eventdev_ops = {
 	.dev_infos_get    = dpaa2_eventdev_info_get,
 	.dev_configure    = dpaa2_eventdev_configure,
 	.dev_start        = dpaa2_eventdev_start,

drivers/event/dpaa2/dpaa2_eventdev.c static const struct rte_eventdev_ops dpaa2_eventdev_ops = { · line 717

Quoted 4 lines
drivers/event/dpaa2/dpaa2_eventdev.c +1 -0
@@ -714,6 +714,7 @@ static const struct rte_eventdev_ops dpaa2_eventdev_ops = {
 	.eth_rx_adapter_queue_del = dpaa2_eventdev_eth_queue_del,
 	.eth_rx_adapter_start = dpaa2_eventdev_eth_start,
 	.eth_rx_adapter_stop = dpaa2_eventdev_eth_stop,
+	.dev_stop_flush   = NULL,

Same as above comment.

Quoted 17 lines
drivers/event/dpaa2/dpaa2_eventdev.c +0 -0
 };
 
 static int
drivers/event/octeontx/ssovf_evdev.c +1 -1
index a108607..713983b 100644
@@ -591,7 +591,7 @@ ssovf_selftest(const char *key __rte_unused, const char *value,
 }
 
 /* Initialize and register event driver with DPDK Application */
-static const struct rte_eventdev_ops ssovf_ops = {
+static struct rte_eventdev_ops ssovf_ops = {
 	.dev_infos_get    = ssovf_info_get,
 	.dev_configure    = ssovf_configure,
 	.queue_def_conf   = ssovf_queue_def_conf,

drivers/event/octeontx/ssovf_evdev.c static const struct rte_eventdev_ops ssovf_ops = { · line 620

Quoted 7 lines
drivers/event/octeontx/ssovf_evdev.c +3 -1
@@ -615,7 +615,9 @@ static const struct rte_eventdev_ops ssovf_ops = {
 	.dump             = ssovf_dump,
 	.dev_start        = ssovf_start,
 	.dev_stop         = ssovf_stop,
-	.dev_close        = ssovf_close
+	.dev_close        = ssovf_close,
+
+	.dev_stop_flush   = NULL

Same as above comment.

Quoted 17 lines
drivers/event/octeontx/ssovf_evdev.c +0 -0
 };
 
 static int
drivers/event/opdl/opdl_evdev.c +1 -1
index 7708369..477e102 100644
@@ -607,7 +607,7 @@ set_do_test(const char *key __rte_unused, const char *value, void *opaque)
 static int
 opdl_probe(struct rte_vdev_device *vdev)
 {
-	static const struct rte_eventdev_ops evdev_opdl_ops = {
+	static struct rte_eventdev_ops evdev_opdl_ops = {
 		.dev_configure = opdl_dev_configure,
 		.dev_infos_get = opdl_info_get,
 		.dev_close = opdl_close,

drivers/event/opdl/opdl_evdev.c opdl_probe(struct rte_vdev_device *vdev) · line 633

Quoted 5 lines
drivers/event/opdl/opdl_evdev.c +2 -0
@@ -629,6 +629,8 @@ opdl_probe(struct rte_vdev_device *vdev)
 		.xstats_get_names = opdl_xstats_get_names,
 		.xstats_get_by_name = opdl_xstats_get_by_name,
 		.xstats_reset = opdl_xstats_reset,
+
+		.dev_stop_flush = NULL,

Same as above comment.

Quoted 17 lines
drivers/event/opdl/opdl_evdev.c +0 -0
 	};
 
 	static const char *const args[] = {
drivers/event/skeleton/skeleton_eventdev.c +1 -1
index 7f46756..c627f01 100644
@@ -319,7 +319,7 @@ skeleton_eventdev_dump(struct rte_eventdev *dev, FILE *f)
 
 
 /* Initialize and register event driver with DPDK Application */
-static const struct rte_eventdev_ops skeleton_eventdev_ops = {
+static struct rte_eventdev_ops skeleton_eventdev_ops = {
 	.dev_infos_get    = skeleton_eventdev_info_get,
 	.dev_configure    = skeleton_eventdev_configure,
 	.dev_start        = skeleton_eventdev_start,

drivers/event/skeleton/skeleton_eventdev.c static const struct rte_eventdev_ops skeleton_eventdev_ops = { · line 338

Quoted 6 lines
drivers/event/skeleton/skeleton_eventdev.c +2 -1
@@ -334,7 +334,8 @@ static const struct rte_eventdev_ops skeleton_eventdev_ops = {
 	.port_link        = skeleton_eventdev_port_link,
 	.port_unlink      = skeleton_eventdev_port_unlink,
 	.timeout_ticks    = skeleton_eventdev_timeout_ticks,
-	.dump             = skeleton_eventdev_dump
+	.dump             = skeleton_eventdev_dump,
+	.dev_stop_flush   = NULL

Same as above comment.

Quoted 17 lines
drivers/event/skeleton/skeleton_eventdev.c +0 -0
 };
 
 static int
drivers/event/sw/sw_evdev.c +1 -1
index 6672fd8..bda2e21 100644
@@ -772,7 +772,7 @@ static int32_t sw_sched_service_func(void *args)
 static int
 sw_probe(struct rte_vdev_device *vdev)
 {
-	static const struct rte_eventdev_ops evdev_sw_ops = {
+	static struct rte_eventdev_ops evdev_sw_ops = {
 			.dev_configure = sw_dev_configure,
 			.dev_infos_get = sw_info_get,
 			.dev_close = sw_close,

drivers/event/sw/sw_evdev.c sw_probe(struct rte_vdev_device *vdev) · line 801

Quoted 5 lines
drivers/event/sw/sw_evdev.c +2 -0
@@ -797,6 +797,8 @@ sw_probe(struct rte_vdev_device *vdev)
 			.xstats_reset = sw_xstats_reset,
 
 			.dev_selftest = test_sw_eventdev,
+
+			.dev_stop_flush = NULL,

Same as above comment.

Quoted 17 lines
drivers/event/sw/sw_evdev.c +0 -0
 	};
 
 	static const char *const args[] = {
lib/librte_eventdev/rte_eventdev.c +6 -0
index 851a119..2de8d9a 100644
@@ -1123,6 +1123,23 @@ rte_event_dev_start(uint8_t dev_id)
 	return 0;
 }
 
+int
+rte_event_dev_stop_flush_callback_register(uint8_t dev_id,
+		eventdev_stop_flush_t callback, void *userdata)
+{
+	struct rte_eventdev *dev;
+

lib/librte_eventdev/rte_eventdev.c rte_event_dev_start(uint8_t dev_id) · line 1141

Quoted 10 lines
lib/librte_eventdev/rte_eventdev.c +10 -0
+	RTE_EDEV_LOG_DEBUG("Stop flush register dev_id=%" PRIu8, dev_id);
+
+	RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
+	dev = &rte_eventdevs[dev_id];
+
+	dev->dev_ops->dev_stop_flush = callback;
+	dev->data->dev_stop_flush_arg = userdata;
+
+	return 0;
+}

Other than above minor comments, everything else looks good to me.

author
#10 lore raw
Quoted 69 lines

-----Original Message-----
From: Jerin Jacob [mailto:[email protected]]
Sent: Tuesday, March 20, 2018 2:44 AM
To: Eads, Gage <[email protected]>
Cc: [email protected]; Van Haaren, Harry <[email protected]>; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v3 1/2] eventdev: add device stop flush callback

-----Original Message-----

Quoted 9 lines

Date: Wed, 14 Mar 2018 23:12:09 -0500
From: Gage Eads <[email protected]>
To: [email protected]
CC: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: [PATCH v3 1/2] eventdev: add device stop flush callback
X-Mailer: git-send-email 2.7.4

Quoted 3 lines

When an event device is stopped, it drains all event queues. These events may contain pointers, so to prevent memory leaks eventdev now supports a user-provided flush callback that is called during the queue drain

process.

Quoted 14 lines

This callback is stored in process memory, so the callback must be registered by any process that may call rte_event_dev_stop().

This commit also clarifies the behavior of rte_event_dev_stop().

This follows this mailing list discussion:
http://dpdk.org/ml/archives/dev/2018-January/087484.html

---
v2: allow a NULL callback pointer to unregister the callback
v3: move the callback pointer to struct rte_eventdev_ops and
the user argument to struct rte_eventdev_data.

Quoted 8 lines
 drivers/event/dpaa/dpaa_eventdev.c           |  3 +-
 drivers/event/dpaa2/dpaa2_eventdev.c         |  3 +-
 drivers/event/octeontx/ssovf_evdev.c         |  6 ++-
 drivers/event/opdl/opdl_evdev.c              |  4 +-
 drivers/event/skeleton/skeleton_eventdev.c   |  5 ++-
 drivers/event/sw/sw_evdev.c                  |  4 +-
 lib/librte_eventdev/rte_eventdev.c           | 17 +++++++++
 lib/librte_eventdev/rte_eventdev.h           | 55

++++++++++++++++++++++++++--

drivers/event/dpaa/dpaa_eventdev.c dpaa_event_eth_rx_adapter_stop(const struct

Quoted 10 lines
 lib/librte_eventdev/rte_eventdev_pmd.h       |  3 ++
 lib/librte_eventdev/rte_eventdev_version.map |  6 +++
 10 files changed, 95 insertions(+), 11 deletions(-)
drivers/event/dpaa/dpaa_eventdev.c +0 -0
index 0006801..4bf1918 100644
@@ -571,7 +571,7 @@ dpaa_event_eth_rx_adapter_stop(const struct

rte_eventdev *dev,

drivers/event/dpaa/dpaa_eventdev.c static const struct rte_eventdev_ops

Quoted 9 lines
drivers/event/dpaa/dpaa_eventdev.c +1 -1
 	return 0;
 }
 
-static const struct rte_eventdev_ops dpaa_eventdev_ops = {
+static struct rte_eventdev_ops dpaa_eventdev_ops = {
 	.dev_infos_get    = dpaa_event_dev_info_get,
 	.dev_configure    = dpaa_event_dev_configure,
 	.dev_start        = dpaa_event_dev_start,
@@ -591,6 +591,7 @@ static const struct rte_eventdev_ops

dpaa_eventdev_ops = {

Quoted 7 lines

drivers/event/dpaa/dpaa_eventdev.c static const struct rte_eventdev_ops dpaa_eventdev_ops = { · line 594

Quoted 4 lines
drivers/event/dpaa/dpaa_eventdev.c +1 -0
 	.eth_rx_adapter_queue_del = dpaa_event_eth_rx_adapter_queue_del,
 	.eth_rx_adapter_start = dpaa_event_eth_rx_adapter_start,
 	.eth_rx_adapter_stop = dpaa_event_eth_rx_adapter_stop,
+	.dev_stop_flush   = NULL,

Do we need explicit NULL assignment here. It will be NULL by default.

Good point. I will fix and resubmit a v4.

author
#11 lore raw

PATCH v4 1/2 eventdev: add device stop flush callback

In reply to Gage Eads

When an event device is stopped, it drains all event queues. These events may contain pointers, so to prevent memory leaks eventdev now supports a user-provided flush callback that is called during the queue drain process. This callback is stored in process memory, so the callback must be registered by any process that may call rte_event_dev_stop().

This commit also clarifies the behavior of rte_event_dev_stop().

This follows this mailing list discussion:
http://dpdk.org/ml/archives/dev/2018-January/087484.html

---
v2: allow a NULL callback pointer to unregister the callback
v3: move the callback pointer to struct rte_eventdev_ops and
the user argument to struct rte_eventdev_data
v4: remove redundant callback NULL initialization

 drivers/event/dpaa/dpaa_eventdev.c           |  2 +-
 drivers/event/dpaa2/dpaa2_eventdev.c         |  2 +-
 drivers/event/octeontx/ssovf_evdev.c         |  2 +-
 drivers/event/opdl/opdl_evdev.c              |  2 +-
 drivers/event/skeleton/skeleton_eventdev.c   |  2 +-
 drivers/event/sw/sw_evdev.c                  |  2 +-
 lib/librte_eventdev/rte_eventdev.c           | 17 +++++++++
 lib/librte_eventdev/rte_eventdev.h           | 55 ++++++++++++++++++++++++++--
 lib/librte_eventdev/rte_eventdev_pmd.h       |  3 ++
 lib/librte_eventdev/rte_eventdev_version.map |  6 +++
 10 files changed, 84 insertions(+), 9 deletions(-)
drivers/event/dpaa/dpaa_eventdev.c +1 -1
index 0006801..fcb648d 100644
@@ -571,7 +571,7 @@ dpaa_event_eth_rx_adapter_stop(const struct rte_eventdev *dev,
 	return 0;
 }
 
-static const struct rte_eventdev_ops dpaa_eventdev_ops = {
+static struct rte_eventdev_ops dpaa_eventdev_ops = {
 	.dev_infos_get    = dpaa_event_dev_info_get,
 	.dev_configure    = dpaa_event_dev_configure,
 	.dev_start        = dpaa_event_dev_start,
drivers/event/dpaa2/dpaa2_eventdev.c +1 -1
index c3e6fbf..5270dc0 100644
@@ -693,7 +693,7 @@ dpaa2_eventdev_eth_stop(const struct rte_eventdev *dev,
 	return 0;
 }
 
-static const struct rte_eventdev_ops dpaa2_eventdev_ops = {
+static struct rte_eventdev_ops dpaa2_eventdev_ops = {
 	.dev_infos_get    = dpaa2_eventdev_info_get,
 	.dev_configure    = dpaa2_eventdev_configure,
 	.dev_start        = dpaa2_eventdev_start,
drivers/event/octeontx/ssovf_evdev.c +1 -1
index a108607..bc1f05f 100644
@@ -591,7 +591,7 @@ ssovf_selftest(const char *key __rte_unused, const char *value,
 }
 
 /* Initialize and register event driver with DPDK Application */
-static const struct rte_eventdev_ops ssovf_ops = {
+static struct rte_eventdev_ops ssovf_ops = {
 	.dev_infos_get    = ssovf_info_get,
 	.dev_configure    = ssovf_configure,
 	.queue_def_conf   = ssovf_queue_def_conf,
drivers/event/opdl/opdl_evdev.c +1 -1
index 7708369..ef9fb30 100644
@@ -607,7 +607,7 @@ set_do_test(const char *key __rte_unused, const char *value, void *opaque)
 static int
 opdl_probe(struct rte_vdev_device *vdev)
 {
-	static const struct rte_eventdev_ops evdev_opdl_ops = {
+	static struct rte_eventdev_ops evdev_opdl_ops = {
 		.dev_configure = opdl_dev_configure,
 		.dev_infos_get = opdl_info_get,
 		.dev_close = opdl_close,
drivers/event/skeleton/skeleton_eventdev.c +1 -1
index 7f46756..c889220 100644
@@ -319,7 +319,7 @@ skeleton_eventdev_dump(struct rte_eventdev *dev, FILE *f)
 
 
 /* Initialize and register event driver with DPDK Application */
-static const struct rte_eventdev_ops skeleton_eventdev_ops = {
+static struct rte_eventdev_ops skeleton_eventdev_ops = {
 	.dev_infos_get    = skeleton_eventdev_info_get,
 	.dev_configure    = skeleton_eventdev_configure,
 	.dev_start        = skeleton_eventdev_start,
drivers/event/sw/sw_evdev.c +1 -1
index 6672fd8..0e89f11 100644
@@ -772,7 +772,7 @@ static int32_t sw_sched_service_func(void *args)
 static int
 sw_probe(struct rte_vdev_device *vdev)
 {
-	static const struct rte_eventdev_ops evdev_sw_ops = {
+	static struct rte_eventdev_ops evdev_sw_ops = {
 			.dev_configure = sw_dev_configure,
 			.dev_infos_get = sw_info_get,
 			.dev_close = sw_close,
lib/librte_eventdev/rte_eventdev.c +17 -0
index 851a119..2de8d9a 100644
@@ -1123,6 +1123,23 @@ rte_event_dev_start(uint8_t dev_id)
 	return 0;
 }
 
+int
+rte_event_dev_stop_flush_callback_register(uint8_t dev_id,
+		eventdev_stop_flush_t callback, void *userdata)
+{
+	struct rte_eventdev *dev;
+
+	RTE_EDEV_LOG_DEBUG("Stop flush register dev_id=%" PRIu8, dev_id);
+
+	RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
+	dev = &rte_eventdevs[dev_id];
+
+	dev->dev_ops->dev_stop_flush = callback;
+	dev->data->dev_stop_flush_arg = userdata;
+
+	return 0;
+}
+
 void
 rte_event_dev_stop(uint8_t dev_id)
 {
lib/librte_eventdev/rte_eventdev.h +52 -3

86 lines not on this page · raw message

lib/librte_eventdev/rte_eventdev_pmd.h +3 -0
index 31343b5..3a8ddd7 100644
@@ -642,6 +642,9 @@ struct rte_eventdev_ops {
 
 	eventdev_selftest dev_selftest;
 	/**< Start eventdev Selftest */
+
+	eventdev_stop_flush_t dev_stop_flush;
+	/**< User-provided event flush function */
 };
 
 /**
lib/librte_eventdev/rte_eventdev_version.map +6 -0
index 2aef470..4396536 100644
@@ -74,3 +74,9 @@ DPDK_18.02 {
 
 	rte_event_dev_selftest;
 } DPDK_17.11;
+
+DPDK_18.05 {
+	global:
+
+	rte_event_dev_stop_flush_callback_register;
+} DPDK_18.02;
Signature · 1 line
2.7.4
author
#12 lore raw

PATCH v4 2/2 event/sw: support device stop flush callback

This commit also adds a flush callback test to the sw eventdev's selftest suite.

---
 drivers/event/sw/sw_evdev.c          | 25 ++++++++++-
 drivers/event/sw/sw_evdev_selftest.c | 80 +++++++++++++++++++++++++++++++++++-
 2 files changed, 102 insertions(+), 3 deletions(-)
drivers/event/sw/sw_evdev.c +23 -2
index 0e89f11..11f394f 100644
@@ -362,8 +362,25 @@ sw_init_qid_iqs(struct sw_evdev *sw)
 }
 
 static void
-sw_clean_qid_iqs(struct sw_evdev *sw)
+sw_flush_iq(struct rte_eventdev *dev, struct sw_iq *iq)
 {
+	struct sw_evdev *sw = sw_pmd_priv(dev);
+
+	while (iq_count(iq) > 0) {
+		struct rte_event event;
+
+		iq_dequeue_burst(sw, iq, &event, 1);
+
+		dev->dev_ops->dev_stop_flush(dev->data->dev_id,
+					     event,
+					     dev->data->dev_stop_flush_arg);
+	}
+}
+
+static void
+sw_clean_qid_iqs(struct rte_eventdev *dev)
+{
+	struct sw_evdev *sw = sw_pmd_priv(dev);
 	int i, j;
 
 	/* Release the IQ memory of all configured qids */
@@ -373,7 +390,11 @@ sw_clean_qid_iqs(struct sw_evdev *sw)
 		for (j = 0; j < SW_IQS_MAX; j++) {
 			if (!qid->iq[j].head)
 				continue;
+
+			if (dev->dev_ops->dev_stop_flush)
+				sw_flush_iq(dev, &qid->iq[j]);
 			iq_free_chunk_list(sw, qid->iq[j].head);
+
 			qid->iq[j].head = NULL;
 		}
 	}
@@ -702,7 +723,7 @@ static void
 sw_stop(struct rte_eventdev *dev)
 {
 	struct sw_evdev *sw = sw_pmd_priv(dev);
-	sw_clean_qid_iqs(sw);
+	sw_clean_qid_iqs(dev);
 	sw_xstats_uninit(sw);
 	sw->started = 0;
 	rte_smp_wmb();
drivers/event/sw/sw_evdev_selftest.c +79 -1

104 lines not on this page · raw message

Signature · 1 line
2.7.4
#18 lore raw
In reply to Gage Eads
Quoted 15 lines

From: Eads, Gage
Sent: Tuesday, March 20, 2018 2:13 PM
To: [email protected]
Cc: [email protected]; Van Haaren, Harry <[email protected]>; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]
Subject: [PATCH v4 1/2] eventdev: add device stop flush callback

When an event device is stopped, it drains all event queues. These events may contain pointers, so to prevent memory leaks eventdev now supports a user-provided flush callback that is called during the queue drain process. This callback is stored in process memory, so the callback must be registered by any process that may call rte_event_dev_stop().

Quoted 6 lines

This commit also clarifies the behavior of rte_event_dev_stop().

This follows this mailing list discussion:
http://dpdk.org/ml/archives/dev/2018-January/087484.html

<snip most of the code - looks good!>

Quoted 5 lines

/**
- * Stop an event device. The device can be restarted with a call to
- * rte_event_dev_start()
+ * Stop an event device.
+ *

Quoted 8 lines

+ * This function causes all queued events to be drained. While draining events
+ * out of the device, this function calls the user-provided flush callback
+ * (if one was registered) once per event.
+ *
+ * This function does not drain events from event ports; the application is
+ * responsible for flushing events from all ports before stopping the device.

Question about how an application is expected to correctly cleanup all the events here. Note in particular the last part: "application is responsible for flushing events from all ports **BEFORE** stopping the device".

Given the event device is still running, how can the application be sure it has flushed all the events (from the dequeue side in particular)?

In order to drain all events from the ports, I was expecting the following:

// stop scheduling new events to worker cores
rte_event_dev_stop()
---> callback gets called for each event

// to dequeue events from each port, and app cleans them up? FOR_EACH_PORT( rte_event_dev_dequeue(..., port_id, ...) )

I'd like to avoid the dequeue-each-port() approach in application, as it adds extra burden to clean up correctly...

What if we say that dequeue() returns zero after stop() (leaving events possibly in the port-dequeue side SW buffers), and these events which were about to be dequeued by the worker core are also passed to the dev_stop_flush callback?

#13 lore raw

Re: [PATCH v4 2/2] event/sw: support device stop flush callback

In reply to Gage Eads
Quoted 30 lines

From: Eads, Gage
Sent: Tuesday, March 20, 2018 2:13 PM
To: [email protected]
Cc: [email protected]; Van Haaren, Harry <[email protected]>; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]
Subject: [PATCH v4 2/2] event/sw: support device stop flush callback

This commit also adds a flush callback test to the sw eventdev's selftest suite.

---
 drivers/event/sw/sw_evdev.c          | 25 ++++++++++-
 drivers/event/sw/sw_evdev_selftest.c | 80
+++++++++++++++++++++++++++++++++++-
 2 files changed, 102 insertions(+), 3 deletions(-)
drivers/event/sw/sw_evdev.c +1 -1
index 0e89f11..11f394f 100644
@@ -362,8 +362,25 @@ sw_init_qid_iqs(struct sw_evdev *sw)
 }
 
 static void
-sw_clean_qid_iqs(struct sw_evdev *sw)
+sw_flush_iq(struct rte_eventdev *dev, struct sw_iq *iq)
 {

drivers/event/sw/sw_evdev.c sw_init_qid_iqs(struct sw_evdev *sw) · line 376

Quoted 10 lines
drivers/event/sw/sw_evdev.c +10 -0
+	struct sw_evdev *sw = sw_pmd_priv(dev);
+
+	while (iq_count(iq) > 0) {
+		struct rte_event event;
+
+		iq_dequeue_burst(sw, iq, &event, 1);
+
+		dev->dev_ops->dev_stop_flush(dev->data->dev_id,
+					     event,
+					     dev->data->dev_stop_flush_arg);

Adding check that dev_stop_flush() is non-NULL?

[Update: Ah I see you do this below already. Still, better check twice I think, the data path isn't running here anyway in case future me decides to call sw_flush_iq() without performing the check]

if(dev->dev_ops->dev_stop_flush)
dev->dev_ops->dev_stop_flush(...);

drivers/event/sw/sw_evdev.c static void · line 726

Quoted 6 lines
drivers/event/sw/sw_evdev.c +1 -1
@@ -702,7 +723,7 @@ static void
 sw_stop(struct rte_eventdev *dev)
 {
 	struct sw_evdev *sw = sw_pmd_priv(dev);
-	sw_clean_qid_iqs(sw);
+	sw_clean_qid_iqs(dev);

Based on the port buffers comment on 1/2, we probably need a sw_clean_port_buffers(sw); here to return any events in the port owned SW buffers?

Rest looks good to me!

author
#19 lore raw
In reply to Van Haaren, Harry
Quoted 54 lines

-----Original Message-----
From: Van Haaren, Harry
Sent: Friday, March 23, 2018 11:57 AM
To: Eads, Gage <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]
Subject: RE: [PATCH v4 1/2] eventdev: add device stop flush callback

Quoted 9 lines

From: Eads, Gage
Sent: Tuesday, March 20, 2018 2:13 PM
To: [email protected]
Cc: [email protected]; Van Haaren, Harry <[email protected]>; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]
Subject: [PATCH v4 1/2] eventdev: add device stop flush callback

Quoted 3 lines

When an event device is stopped, it drains all event queues. These events may contain pointers, so to prevent memory leaks eventdev now supports a user-provided flush callback that is called during the queue drain

process.

Quoted 9 lines

This callback is stored in process memory, so the callback must be registered by any process that may call rte_event_dev_stop().

This commit also clarifies the behavior of rte_event_dev_stop().

This follows this mailing list discussion:
http://dpdk.org/ml/archives/dev/2018-January/087484.html

<snip most of the code - looks good!>

Quoted 8 lines

/**
- * Stop an event device. The device can be restarted with a call to
- * rte_event_dev_start()
+ * Stop an event device.
+ *
+ * This function causes all queued events to be drained. While
+ draining
events

Quoted 8 lines

+ * out of the device, this function calls the user-provided flush
+ callback
+ * (if one was registered) once per event.
+ *
+ * This function does not drain events from event ports; the
+ application is
+ * responsible for flushing events from all ports before stopping the device.

Quoted 7 lines

Question about how an application is expected to correctly cleanup all the events here. Note in particular the last part: "application is responsible for flushing events from all ports **BEFORE** stopping the device".

Given the event device is still running, how can the application be sure it has flushed all the events (from the dequeue side in particular)?

Appreciate the feedback -- good points all around.

I was expecting that the application would unlink queues from the ports, and then dequeue until each port has no events. However, there are PMDs for which runtime port link/unlink is not supported, so I see that this is not a viable approach. Plus, this adds the application burden that you describe below.

Quoted 7 lines

In order to drain all events from the ports, I was expecting the following:

// stop scheduling new events to worker cores
rte_event_dev_stop()
---> callback gets called for each event

Quoted 6 lines

// to dequeue events from each port, and app cleans them up? FOR_EACH_PORT( rte_event_dev_dequeue(..., port_id, ...) )

I'd like to avoid the dequeue-each-port() approach in application, as it adds extra burden to clean up correctly...

Agreed, but for a different reason: that approach means we'd have to change the documented eventdev behavior. rte_eventdev.h states that the "schedule, enqueue and dequeue functions should not be invoked when the device is stopped," and this patch reiterates that in the rte_event_dev_stop() documentation ("Threads that continue to enqueue/dequeue while the device is stopped, or being stopped, will result in undefined behavior"). Since a PMD's stop cleanup code could just be repeated calls to a PMD's dequeue code, allowing applications to dequeue simultaneously could be troublesome.

Quoted 4 lines

What if we say that dequeue() returns zero after stop() (leaving events possibly in the port-dequeue side SW buffers), and these events which were about to be dequeued by the worker core are also passed to the dev_stop_flush callback?

I'd prefer to have dequeue-while-stopped be unsupported, so we don't need an additional check or synchronization in the datapath, but passing the events in a port to the callback should work (for the sw PMD, at least). How does that sound?

Thanks,
Gage

author
#14 lore raw

Re: [PATCH v4 2/2] event/sw: support device stop flush callback

In reply to Van Haaren, Harry
Quoted 54 lines

-----Original Message-----
From: Van Haaren, Harry
Sent: Friday, March 23, 2018 12:06 PM
To: Eads, Gage <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]
Subject: RE: [PATCH v4 2/2] event/sw: support device stop flush callback

Quoted 29 lines

From: Eads, Gage
Sent: Tuesday, March 20, 2018 2:13 PM
To: [email protected]
Cc: [email protected]; Van Haaren, Harry <[email protected]>; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]
Subject: [PATCH v4 2/2] event/sw: support device stop flush callback

This commit also adds a flush callback test to the sw eventdev's selftest suite.

---
 drivers/event/sw/sw_evdev.c          | 25 ++++++++++-
 drivers/event/sw/sw_evdev_selftest.c | 80
+++++++++++++++++++++++++++++++++++-
 2 files changed, 102 insertions(+), 3 deletions(-)
drivers/event/sw/sw_evdev.c +1 -1
index 0e89f11..11f394f 100644
@@ -362,8 +362,25 @@ sw_init_qid_iqs(struct sw_evdev *sw)  }
 
 static void
-sw_clean_qid_iqs(struct sw_evdev *sw)
+sw_flush_iq(struct rte_eventdev *dev, struct sw_iq *iq)
 {

drivers/event/sw/sw_evdev.c sw_init_qid_iqs(struct sw_evdev *sw) } · line 375

Quoted 10 lines
drivers/event/sw/sw_evdev.c +10 -0
+	struct sw_evdev *sw = sw_pmd_priv(dev);
+
+	while (iq_count(iq) > 0) {
+		struct rte_event event;
+
+		iq_dequeue_burst(sw, iq, &event, 1);
+
+		dev->dev_ops->dev_stop_flush(dev->data->dev_id,
+					     event,
+					     dev->data->dev_stop_flush_arg);

Adding check that dev_stop_flush() is non-NULL?

Quoted 3 lines

[Update: Ah I see you do this below already. Still, better check twice I think, the data path isn't running here anyway in case future me decides to call sw_flush_iq() without performing the check]

Agreed, will fix in v5.

Quoted 7 lines

if(dev->dev_ops->dev_stop_flush)
dev->dev_ops->dev_stop_flush(...);

Quoted 11 lines

drivers/event/sw/sw_evdev.c static void · line 726

Quoted 6 lines
drivers/event/sw/sw_evdev.c +1 -1
@@ -702,7 +723,7 @@ static void
 sw_stop(struct rte_eventdev *dev)
 {
 	struct sw_evdev *sw = sw_pmd_priv(dev);
-	sw_clean_qid_iqs(sw);
+	sw_clean_qid_iqs(dev);

Based on the port buffers comment on 1/2, we probably need a sw_clean_port_buffers(sw); here to return any events in the port owned SW buffers?

Agreed, if there is buy-in on the approach discussed in patch #1.

#20 lore raw
In reply to Eads, Gage
Quoted 73 lines

From: Eads, Gage
Sent: Monday, March 26, 2018 10:59 PM
To: Van Haaren, Harry <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]
Subject: RE: [PATCH v4 1/2] eventdev: add device stop flush callback

Quoted 21 lines

-----Original Message-----
From: Van Haaren, Harry
Sent: Friday, March 23, 2018 11:57 AM
To: Eads, Gage <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]
Subject: RE: [PATCH v4 1/2] eventdev: add device stop flush callback

Quoted 12 lines

From: Eads, Gage
Sent: Tuesday, March 20, 2018 2:13 PM
To: [email protected]
Cc: [email protected]; Van Haaren, Harry <[email protected]>; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]
Subject: [PATCH v4 1/2] eventdev: add device stop flush callback

When an event device is stopped, it drains all event queues. These events may contain pointers, so to prevent memory leaks eventdev now supports a user-provided flush callback that is called during the queue

drain

Quoted 31 lines

process.

Quoted 9 lines

This callback is stored in process memory, so the callback must be registered by any process that may call rte_event_dev_stop().

This commit also clarifies the behavior of rte_event_dev_stop().

This follows this mailing list discussion:
http://dpdk.org/ml/archives/dev/2018-January/087484.html

<snip most of the code - looks good!>

Quoted 8 lines

/**
- * Stop an event device. The device can be restarted with a call to
- * rte_event_dev_start()
+ * Stop an event device.
+ *
+ * This function causes all queued events to be drained. While
+ draining
events

Quoted 8 lines

+ * out of the device, this function calls the user-provided flush
+ callback
+ * (if one was registered) once per event.
+ *
+ * This function does not drain events from event ports; the
+ application is
+ * responsible for flushing events from all ports before stopping the device.

Quoted 2 lines

Question about how an application is expected to correctly cleanup all the events here. Note in particular the last part: "application is responsible

for

Quoted 3 lines

flushing events from all ports **BEFORE** stopping the device".

Given the event device is still running, how can the application be sure it

has

Quoted 2 lines

flushed all the events (from the dequeue side in particular)?

Quoted 6 lines

Appreciate the feedback -- good points all around.

I was expecting that the application would unlink queues from the ports, and then dequeue until each port has no events. However, there are PMDs for which runtime port link/unlink is not supported, so I see that this is not a viable approach. Plus, this adds the application burden that you describe below.

+1.

Quoted 15 lines
Quoted 7 lines

In order to drain all events from the ports, I was expecting the following:

// stop scheduling new events to worker cores
rte_event_dev_stop()
---> callback gets called for each event

Quoted 5 lines

// to dequeue events from each port, and app cleans them up? FOR_EACH_PORT( rte_event_dev_dequeue(..., port_id, ...) )

I'd like to avoid the dequeue-each-port() approach in application, as it

adds extra

Quoted 1 line

burden to clean up correctly...

Quoted 8 lines

Agreed, but for a different reason: that approach means we'd have to change the documented eventdev behavior. rte_eventdev.h states that the "schedule, enqueue and dequeue functions should not be invoked when the device is stopped," and this patch reiterates that in the rte_event_dev_stop() documentation ("Threads that continue to enqueue/dequeue while the device is stopped, or being stopped, will result in undefined behavior"). Since a PMD's stop cleanup code could just be repeated calls to a PMD's dequeue code, allowing applications to dequeue simultaneously could be troublesome.

All +1 too, good point about the header stating it is undefined behavior.

Quoted 10 lines
Quoted 1 line

What if we say that dequeue() returns zero after stop() (leaving events

possibly

Quoted 1 line

in the port-dequeue side SW buffers), and these events which were about to

be

Quoted 1 line

dequeued by the worker core are also passed to the dev_stop_flush callback?

I'd prefer to have dequeue-while-stopped be unsupported, so we don't need an additional check or synchronization in the datapath, but passing the events in a port to the callback should work (for the sw PMD, at least). How does that sound?

That's fine with me, both from design point of view, and SW PMD.

@HW PMD maintainers, would the above approach work for you?

#21 lore raw

(+Liang Ma for OPDL maintainer)

Ping to maintainers, is the below suggestion acceptable for your PMDs?

Summary of suggestion:
- After event_dev_stop() dequeue() is no longer allowed on any thread
- All events in the system (queues, ports, intermediary buffers) will be passed to a user-supplied callback for cleaning up events.

Quoted 155 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Van Haaren, Harry
Sent: Tuesday, March 27, 2018 9:20 AM
To: Eads, Gage <[email protected]>; [email protected]; [email protected]
Cc: Richardson, Bruce <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v4 1/2] eventdev: add device stop flush callback

Quoted 4 lines

From: Eads, Gage
Sent: Monday, March 26, 2018 10:59 PM
To: Van Haaren, Harry <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Richardson,

Bruce

Quoted 27 lines

<[email protected]>; [email protected]; [email protected]
Subject: RE: [PATCH v4 1/2] eventdev: add device stop flush callback

Quoted 21 lines

-----Original Message-----
From: Van Haaren, Harry
Sent: Friday, March 23, 2018 11:57 AM
To: Eads, Gage <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]
Subject: RE: [PATCH v4 1/2] eventdev: add device stop flush callback

Quoted 12 lines

From: Eads, Gage
Sent: Tuesday, March 20, 2018 2:13 PM
To: [email protected]
Cc: [email protected]; Van Haaren, Harry <[email protected]>; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]
Subject: [PATCH v4 1/2] eventdev: add device stop flush callback

When an event device is stopped, it drains all event queues. These events may contain pointers, so to prevent memory leaks eventdev now supports a user-provided flush callback that is called during the

queue

Quoted 33 lines

drain

Quoted 32 lines

process.

Quoted 9 lines

This callback is stored in process memory, so the callback must be registered by any process that may call rte_event_dev_stop().

This commit also clarifies the behavior of rte_event_dev_stop().

This follows this mailing list discussion:
http://dpdk.org/ml/archives/dev/2018-January/087484.html

<snip most of the code - looks good!>

Quoted 8 lines

/**
- * Stop an event device. The device can be restarted with a call to
- * rte_event_dev_start()
+ * Stop an event device.
+ *
+ * This function causes all queued events to be drained. While
+ draining
events

Quoted 8 lines

+ * out of the device, this function calls the user-provided flush
+ callback
+ * (if one was registered) once per event.
+ *
+ * This function does not drain events from event ports; the
+ application is
+ * responsible for flushing events from all ports before stopping the device.

Question about how an application is expected to correctly cleanup all

the

Quoted 1 line
Quoted 1 line

events here. Note in particular the last part: "application is

responsible

Quoted 4 lines

for

Quoted 3 lines

flushing events from all ports **BEFORE** stopping the device".

Given the event device is still running, how can the application be sure

it

Quoted 7 lines

has

Quoted 2 lines

flushed all the events (from the dequeue side in particular)?

Appreciate the feedback -- good points all around.

I was expecting that the application would unlink queues from the ports,

and

Quoted 1 line

then dequeue until each port has no events. However, there are PMDs for

which

Quoted 1 line

runtime port link/unlink is not supported, so I see that this is not a

viable

Quoted 1 line

approach. Plus, this adds the application burden that you describe below.

+1.

Quoted 2 lines
Quoted 2 lines

In order to drain all events from the ports, I was expecting the

following:

Quoted 9 lines
Quoted 9 lines

// stop scheduling new events to worker cores
rte_event_dev_stop()
---> callback gets called for each event

// to dequeue events from each port, and app cleans them up? FOR_EACH_PORT( rte_event_dev_dequeue(..., port_id, ...) )

Quoted 5 lines
Quoted 1 line

I'd like to avoid the dequeue-each-port() approach in application, as it

adds extra

Quoted 1 line

burden to clean up correctly...

Agreed, but for a different reason: that approach means we'd have to

change

Quoted 1 line

the documented eventdev behavior. rte_eventdev.h states that the

"schedule,

Quoted 3 lines

enqueue and dequeue functions should not be invoked when the device is stopped," and this patch reiterates that in the rte_event_dev_stop() documentation ("Threads that continue to enqueue/dequeue while the device

is

Quoted 1 line

stopped, or being stopped, will result in undefined behavior"). Since a

PMD's

Quoted 2 lines

stop cleanup code could just be repeated calls to a PMD's dequeue code, allowing applications to dequeue simultaneously could be troublesome.

All +1 too, good point about the header stating it is undefined behavior.

Quoted 3 lines
Quoted 1 line

What if we say that dequeue() returns zero after stop() (leaving events

possibly

Quoted 1 line

in the port-dequeue side SW buffers), and these events which were about

to

Quoted 2 lines

be

Quoted 1 line

dequeued by the worker core are also passed to the dev_stop_flush

callback?

Quoted 2 lines

I'd prefer to have dequeue-while-stopped be unsupported, so we don't need

an

Quoted 1 line

additional check or synchronization in the datapath, but passing the

events in

Quoted 1 line

a port to the callback should work (for the sw PMD, at least). How does

that

Quoted 1 line

sound?

That's fine with me, both from design point of view, and SW PMD.

@HW PMD maintainers, would the above approach work for you?

#22 lore raw

-----Original Message-----

Quoted 12 lines

Date: Thu, 29 Mar 2018 11:02:55 +0000
From: "Van Haaren, Harry" <[email protected]>
To: "[email protected]" <[email protected]>,
"[email protected]" <[email protected]>, "Ma, Liang J" <[email protected]>
CC: "Eads, Gage" <[email protected]>, "Richardson, Bruce"
<[email protected]>, "[email protected]" <[email protected]>, "[email protected]" <[email protected]>, "[email protected]" <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v4 1/2] eventdev: add device stop flush
callback

Quoted 7 lines

(+Liang Ma for OPDL maintainer)

Ping to maintainers, is the below suggestion acceptable for your PMDs?

Summary of suggestion:
- After event_dev_stop() dequeue() is no longer allowed on any thread
- All events in the system (queues, ports, intermediary buffers) will be passed to a user-supplied callback for cleaning up events.

+1. That's works for octeontx eventdev PMD.

#23 lore raw
In reply to Van Haaren, Harry
Quoted 7 lines · Harry

(+Liang Ma for OPDL maintainer)

Ping to maintainers, is the below suggestion acceptable for your PMDs?

Summary of suggestion:
- After event_dev_stop() dequeue() is no longer allowed on any thread
- All events in the system (queues, ports, intermediary buffers) will be passed to a user-supplied callback for cleaning up events.

+1, this should work for OPDL

Quoted 159 lines
Quoted 158 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Van Haaren, Harry
Sent: Tuesday, March 27, 2018 9:20 AM
To: Eads, Gage <[email protected]>; [email protected]; [email protected]
Cc: Richardson, Bruce <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v4 1/2] eventdev: add device stop flush callback

Quoted 4 lines

From: Eads, Gage
Sent: Monday, March 26, 2018 10:59 PM
To: Van Haaren, Harry <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Richardson,

Bruce

Quoted 27 lines

<[email protected]>; [email protected]; [email protected]
Subject: RE: [PATCH v4 1/2] eventdev: add device stop flush callback

Quoted 21 lines

-----Original Message-----
From: Van Haaren, Harry
Sent: Friday, March 23, 2018 11:57 AM
To: Eads, Gage <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]
Subject: RE: [PATCH v4 1/2] eventdev: add device stop flush callback

Quoted 12 lines

From: Eads, Gage
Sent: Tuesday, March 20, 2018 2:13 PM
To: [email protected]
Cc: [email protected]; Van Haaren, Harry <[email protected]>; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]
Subject: [PATCH v4 1/2] eventdev: add device stop flush callback

When an event device is stopped, it drains all event queues. These events may contain pointers, so to prevent memory leaks eventdev now supports a user-provided flush callback that is called during the

queue

Quoted 33 lines

drain

Quoted 32 lines

process.

Quoted 9 lines

This callback is stored in process memory, so the callback must be registered by any process that may call rte_event_dev_stop().

This commit also clarifies the behavior of rte_event_dev_stop().

This follows this mailing list discussion:
http://dpdk.org/ml/archives/dev/2018-January/087484.html

<snip most of the code - looks good!>

Quoted 8 lines

/**
- * Stop an event device. The device can be restarted with a call to
- * rte_event_dev_start()
+ * Stop an event device.
+ *
+ * This function causes all queued events to be drained. While
+ draining
events

Quoted 8 lines

+ * out of the device, this function calls the user-provided flush
+ callback
+ * (if one was registered) once per event.
+ *
+ * This function does not drain events from event ports; the
+ application is
+ * responsible for flushing events from all ports before stopping the device.

Question about how an application is expected to correctly cleanup all

the

Quoted 1 line
Quoted 1 line

events here. Note in particular the last part: "application is

responsible

Quoted 4 lines

for

Quoted 3 lines

flushing events from all ports **BEFORE** stopping the device".

Given the event device is still running, how can the application be sure

it

Quoted 7 lines

has

Quoted 2 lines

flushed all the events (from the dequeue side in particular)?

Appreciate the feedback -- good points all around.

I was expecting that the application would unlink queues from the ports,

and

Quoted 1 line

then dequeue until each port has no events. However, there are PMDs for

which

Quoted 1 line

runtime port link/unlink is not supported, so I see that this is not a

viable

Quoted 1 line

approach. Plus, this adds the application burden that you describe below.

+1.

Quoted 2 lines
Quoted 2 lines

In order to drain all events from the ports, I was expecting the

following:

Quoted 9 lines
Quoted 9 lines

// stop scheduling new events to worker cores
rte_event_dev_stop()
---> callback gets called for each event

// to dequeue events from each port, and app cleans them up? FOR_EACH_PORT( rte_event_dev_dequeue(..., port_id, ...) )

Quoted 5 lines
Quoted 1 line

I'd like to avoid the dequeue-each-port() approach in application, as it

adds extra

Quoted 1 line

burden to clean up correctly...

Agreed, but for a different reason: that approach means we'd have to

change

Quoted 1 line

the documented eventdev behavior. rte_eventdev.h states that the

"schedule,

Quoted 3 lines

enqueue and dequeue functions should not be invoked when the device is stopped," and this patch reiterates that in the rte_event_dev_stop() documentation ("Threads that continue to enqueue/dequeue while the device

is

Quoted 1 line

stopped, or being stopped, will result in undefined behavior"). Since a

PMD's

Quoted 2 lines

stop cleanup code could just be repeated calls to a PMD's dequeue code, allowing applications to dequeue simultaneously could be troublesome.

All +1 too, good point about the header stating it is undefined behavior.

Quoted 3 lines
Quoted 1 line

What if we say that dequeue() returns zero after stop() (leaving events

possibly

Quoted 1 line

in the port-dequeue side SW buffers), and these events which were about

to

Quoted 2 lines

be

Quoted 1 line

dequeued by the worker core are also passed to the dev_stop_flush

callback?

Quoted 2 lines

I'd prefer to have dequeue-while-stopped be unsupported, so we don't need

an

Quoted 1 line

additional check or synchronization in the datapath, but passing the

events in

Quoted 1 line

a port to the callback should work (for the sw PMD, at least). How does

that

Quoted 1 line

sound?

That's fine with me, both from design point of view, and SW PMD.

@HW PMD maintainers, would the above approach work for you?

Acked-by on v4 1/2
#24 lore raw
In reply to Gage Eads

-----Original Message-----

Quoted 15 lines

Date: Tue, 20 Mar 2018 09:13:06 -0500
From: Gage Eads <[email protected]>
To: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected], [email protected], [email protected]
Subject: [PATCH v4 1/2] eventdev: add device stop flush callback
X-Mailer: git-send-email 2.7.4

When an event device is stopped, it drains all event queues. These events may contain pointers, so to prevent memory leaks eventdev now supports a user-provided flush callback that is called during the queue drain process. This callback is stored in process memory, so the callback must be registered by any process that may call rte_event_dev_stop().

Quoted 6 lines

This commit also clarifies the behavior of rte_event_dev_stop().

This follows this mailing list discussion:
http://dpdk.org/ml/archives/dev/2018-January/087484.html

#15 lore raw

Re: [PATCH v4 2/2] event/sw: support device stop flush callback

In reply to Eads, Gage
Quoted 5 lines
Quoted 3 lines

[Update: Ah I see you do this below already. Still, better check twice I think, the data path isn't running here anyway in case future me decides to call sw_flush_iq() without performing the check]

Agreed, will fix in v5.

Gage,

Could please send the v5 so that I can include it in RC1 pull request.

author
#16 lore raw

Re: [PATCH v4 2/2] event/sw: support device stop flush callback

If it's ok with you, I'll resubmit these two patches separately. The sw implementation has some unresolved race conditions with the scheduler service that may take some time to fix, but this shouldn't block the first patch. That patch needs a fix too (v4 includes a now-incorrect comment about stop not draining events from ports), so I'll fix and resubmit that.

Thanks,
Gage

Quoted 20 lines

-----Original Message-----
From: Jerin Jacob [mailto:[email protected]]
Sent: Monday, April 2, 2018 3:03 AM
To: Eads, Gage <[email protected]>
Cc: Van Haaren, Harry <[email protected]>; [email protected]; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v4 2/2] event/sw: support device stop flush callback

Quoted 6 lines
Quoted 4 lines

[Update: Ah I see you do this below already. Still, better check twice I think, the data path isn't running here anyway in case future me decides to call
sw_flush_iq() without performing the check]

Agreed, will fix in v5.

Gage,

Could please send the v5 so that I can include it in RC1 pull request.

#17 lore raw

Re: [PATCH v4 2/2] event/sw: support device stop flush callback

-----Original Message-----

Quoted 11 lines

Date: Mon, 2 Apr 2018 15:50:42 +0000
From: "Eads, Gage" <[email protected]>
To: Jerin Jacob <[email protected]>
CC: "Van Haaren, Harry" <[email protected]>, "[email protected]"
<[email protected]>, "[email protected]" <[email protected]>, "Richardson, Bruce" <[email protected]>, "[email protected]" <[email protected]>, "[email protected]" <[email protected]>
Subject: RE: [PATCH v4 2/2] event/sw: support device stop flush callback

If it's ok with you, I'll resubmit these two patches separately. The sw implementation has some unresolved race conditions with the scheduler service that may take some time to fix, but this shouldn't block the first patch. That patch needs a fix too (v4 includes a now-incorrect comment about stop not draining events from ports), so I'll fix and resubmit that.

OK. So that we can merge this common code and octeontx changes.

How about changing the following comment rte_event_dev_stop()

exiting:

+ * This function does not drain events from event ports; the application is responsible for flushing events from all ports before stopping the device.

proposed:(Just to share the view)
# You can add the fact that, all events across the ports will show up in callback as we concluded.

#Application may invoke stop operation on the event adapter to
avoid event being generated.(or something similar) i.e adapter needs to
stopped before stopping the eventdev to avoid continuous looping on
getting the events(over rte_event_dev_register_callback()) from event source(ethdev Rx adapter).

Quoted 25 lines

Thanks,
Gage

Quoted 20 lines

-----Original Message-----
From: Jerin Jacob [mailto:[email protected]]
Sent: Monday, April 2, 2018 3:03 AM
To: Eads, Gage <[email protected]>
Cc: Van Haaren, Harry <[email protected]>; [email protected]; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v4 2/2] event/sw: support device stop flush callback

Quoted 6 lines
Quoted 4 lines

[Update: Ah I see you do this below already. Still, better check twice I think, the data path isn't running here anyway in case future me decides to call
sw_flush_iq() without performing the check]

Agreed, will fix in v5.

Gage,

Could please send the v5 so that I can include it in RC1 pull request.

author
#25 lore raw

PATCH v5 1/1 eventdev: add device stop flush callback

In reply to Gage Eads

When an event device is stopped, it drains all event queues and ports. These events may contain pointers, so to prevent memory leaks eventdev now supports a user-provided flush callback that is called during the queue drain process. This callback is stored in process memory, so the callback must be registered by any process that may call rte_event_dev_stop().

This commit also clarifies the behavior of rte_event_dev_stop().

This follows this mailing list discussion:
http://dpdk.org/ml/archives/dev/2018-January/087484.html

---
v2: allow a NULL callback pointer to unregister the callback
v3: move the callback pointer to struct rte_eventdev_ops and
the user argument to struct rte_eventdev_data
v4: remove redundant callback NULL initialization
v5: add comments about draining events from ports and stopping
event adapters, and drop the event/sw implementation from the patchset until scheduler race conditions are fixed.

 drivers/event/dpaa/dpaa_eventdev.c           |  2 +-
 drivers/event/dpaa2/dpaa2_eventdev.c         |  2 +-
 drivers/event/octeontx/ssovf_evdev.c         |  2 +-
 drivers/event/opdl/opdl_evdev.c              |  2 +-
 drivers/event/skeleton/skeleton_eventdev.c   |  2 +-
 drivers/event/sw/sw_evdev.c                  |  2 +-
 lib/librte_eventdev/rte_eventdev.c           | 17 +++++++++
 lib/librte_eventdev/rte_eventdev.h           | 54 ++++++++++++++++++++++++++--
 lib/librte_eventdev/rte_eventdev_pmd.h       |  3 ++
 lib/librte_eventdev/rte_eventdev_version.map |  6 ++++
 10 files changed, 83 insertions(+), 9 deletions(-)
drivers/event/dpaa/dpaa_eventdev.c +1 -1
index 0006801..fcb648d 100644
@@ -571,7 +571,7 @@ dpaa_event_eth_rx_adapter_stop(const struct rte_eventdev *dev,
 	return 0;
 }
 
-static const struct rte_eventdev_ops dpaa_eventdev_ops = {
+static struct rte_eventdev_ops dpaa_eventdev_ops = {
 	.dev_infos_get    = dpaa_event_dev_info_get,
 	.dev_configure    = dpaa_event_dev_configure,
 	.dev_start        = dpaa_event_dev_start,
drivers/event/dpaa2/dpaa2_eventdev.c +1 -1
index c3e6fbf..5270dc0 100644
@@ -693,7 +693,7 @@ dpaa2_eventdev_eth_stop(const struct rte_eventdev *dev,
 	return 0;
 }
 
-static const struct rte_eventdev_ops dpaa2_eventdev_ops = {
+static struct rte_eventdev_ops dpaa2_eventdev_ops = {
 	.dev_infos_get    = dpaa2_eventdev_info_get,
 	.dev_configure    = dpaa2_eventdev_configure,
 	.dev_start        = dpaa2_eventdev_start,
drivers/event/octeontx/ssovf_evdev.c +1 -1
index a108607..bc1f05f 100644
@@ -591,7 +591,7 @@ ssovf_selftest(const char *key __rte_unused, const char *value,
 }
 
 /* Initialize and register event driver with DPDK Application */
-static const struct rte_eventdev_ops ssovf_ops = {
+static struct rte_eventdev_ops ssovf_ops = {
 	.dev_infos_get    = ssovf_info_get,
 	.dev_configure    = ssovf_configure,
 	.queue_def_conf   = ssovf_queue_def_conf,
drivers/event/opdl/opdl_evdev.c +1 -1
index 7708369..ef9fb30 100644
@@ -607,7 +607,7 @@ set_do_test(const char *key __rte_unused, const char *value, void *opaque)
 static int
 opdl_probe(struct rte_vdev_device *vdev)
 {
-	static const struct rte_eventdev_ops evdev_opdl_ops = {
+	static struct rte_eventdev_ops evdev_opdl_ops = {
 		.dev_configure = opdl_dev_configure,
 		.dev_infos_get = opdl_info_get,
 		.dev_close = opdl_close,
drivers/event/skeleton/skeleton_eventdev.c +1 -1
index 7f46756..c889220 100644
@@ -319,7 +319,7 @@ skeleton_eventdev_dump(struct rte_eventdev *dev, FILE *f)
 
 
 /* Initialize and register event driver with DPDK Application */
-static const struct rte_eventdev_ops skeleton_eventdev_ops = {
+static struct rte_eventdev_ops skeleton_eventdev_ops = {
 	.dev_infos_get    = skeleton_eventdev_info_get,
 	.dev_configure    = skeleton_eventdev_configure,
 	.dev_start        = skeleton_eventdev_start,
drivers/event/sw/sw_evdev.c +1 -1
index 6672fd8..0e89f11 100644
@@ -772,7 +772,7 @@ static int32_t sw_sched_service_func(void *args)
 static int
 sw_probe(struct rte_vdev_device *vdev)
 {
-	static const struct rte_eventdev_ops evdev_sw_ops = {
+	static struct rte_eventdev_ops evdev_sw_ops = {
 			.dev_configure = sw_dev_configure,
 			.dev_infos_get = sw_info_get,
 			.dev_close = sw_close,
lib/librte_eventdev/rte_eventdev.c +17 -0
index 851a119..2de8d9a 100644
@@ -1123,6 +1123,23 @@ rte_event_dev_start(uint8_t dev_id)
 	return 0;
 }
 
+int
+rte_event_dev_stop_flush_callback_register(uint8_t dev_id,
+		eventdev_stop_flush_t callback, void *userdata)
+{
+	struct rte_eventdev *dev;
+
+	RTE_EDEV_LOG_DEBUG("Stop flush register dev_id=%" PRIu8, dev_id);
+
+	RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
+	dev = &rte_eventdevs[dev_id];
+
+	dev->dev_ops->dev_stop_flush = callback;
+	dev->data->dev_stop_flush_arg = userdata;
+
+	return 0;
+}
+
 void
 rte_event_dev_stop(uint8_t dev_id)
 {
lib/librte_eventdev/rte_eventdev.h +51 -3

85 lines not on this page · raw message

lib/librte_eventdev/rte_eventdev_pmd.h +3 -0
index 31343b5..3a8ddd7 100644
@@ -642,6 +642,9 @@ struct rte_eventdev_ops {
 
 	eventdev_selftest dev_selftest;
 	/**< Start eventdev Selftest */
+
+	eventdev_stop_flush_t dev_stop_flush;
+	/**< User-provided event flush function */
 };
 
 /**
lib/librte_eventdev/rte_eventdev_version.map +6 -0
index 2aef470..4396536 100644
@@ -74,3 +74,9 @@ DPDK_18.02 {
 
 	rte_event_dev_selftest;
 } DPDK_17.11;
+
+DPDK_18.05 {
+	global:
+
+	rte_event_dev_stop_flush_callback_register;
+} DPDK_18.02;
Signature · 1 line
2.7.4
Acked-by on v5 1/1
#26 lore raw

-----Original Message-----

Quoted 16 lines

Date: Mon, 2 Apr 2018 13:03:30 -0500
From: Gage Eads <[email protected]>
To: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected], [email protected], [email protected], [email protected]
Subject: [PATCH v5] eventdev: add device stop flush callback
X-Mailer: git-send-email 2.7.4

When an event device is stopped, it drains all event queues and ports. These events may contain pointers, so to prevent memory leaks eventdev now supports a user-provided flush callback that is called during the queue drain process. This callback is stored in process memory, so the callback must be registered by any process that may call rte_event_dev_stop().

Quoted 6 lines

This commit also clarifies the behavior of rte_event_dev_stop().

This follows this mailing list discussion:
http://dpdk.org/ml/archives/dev/2018-January/087484.html

Applied
#27 lore raw

-----Original Message-----

Quoted 26 lines

Date: Tue, 3 Apr 2018 06:56:49 +0530
From: Jerin Jacob <[email protected]>
To: Gage Eads <[email protected]>
CC: [email protected], [email protected], [email protected],
[email protected], [email protected], [email protected], [email protected]
Subject: Re: [dpdk-dev] [PATCH v5] eventdev: add device stop flush callback
User-Agent: Mutt/1.9.4 (2018-02-28)

-----Original Message-----

Quoted 16 lines

Date: Mon, 2 Apr 2018 13:03:30 -0500
From: Gage Eads <[email protected]>
To: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected], [email protected], [email protected], [email protected]
Subject: [PATCH v5] eventdev: add device stop flush callback
X-Mailer: git-send-email 2.7.4

When an event device is stopped, it drains all event queues and ports. These events may contain pointers, so to prevent memory leaks eventdev now supports a user-provided flush callback that is called during the queue drain process. This callback is stored in process memory, so the callback must be registered by any process that may call rte_event_dev_stop().

Quoted 8 lines
Quoted 6 lines

This commit also clarifies the behavior of rte_event_dev_stop().

This follows this mailing list discussion:
http://dpdk.org/ml/archives/dev/2018-January/087484.html

Applied to dpdk-next-eventdev/master. Thanks.