DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 1/2] eventdev: add device stop flush callback
@ 2018-03-05 23:01 Gage Eads
  2018-03-05 23:01 ` [dpdk-dev] [PATCH 2/2] event/sw: support " Gage Eads
  2018-03-08 23:10 ` [dpdk-dev] [PATCH v2 1/2] eventdev: add " Gage Eads
  0 siblings, 2 replies; 29+ messages in thread
From: Gage Eads @ 2018-03-05 23:01 UTC (permalink / raw)
  To: dev
  Cc: jerin.jacob, hemant.agrawal, harry.van.haaren, bruce.richardson,
	santosh.shukla, nipun.gupta

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

Signed-off-by: Gage Eads <gage.eads@intel.com>
---
 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(-)

diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c
index 851a119..7de44f9 100644
--- a/lib/librte_eventdev/rte_eventdev.c
+++ b/lib/librte_eventdev/rte_eventdev.c
@@ -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)
 {
diff --git a/lib/librte_eventdev/rte_eventdev.h b/lib/librte_eventdev/rte_eventdev.h
index b21c271..ec3497f 100644
--- a/lib/librte_eventdev/rte_eventdev.h
+++ b/lib/librte_eventdev/rte_eventdev.h
@@ -835,11 +835,23 @@ int
 rte_event_dev_start(uint8_t dev_id);
 
 /**
- * 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
+ * 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.
+ *
+ * The device can be restarted with a call to rte_event_dev_start(). Threads
+ * that continue to enqueue/dequeue while the device is stopped, or being
+ * stopped, will result in undefined behavior.
  *
  * @param dev_id
  *   Event device identifier.
+ *
+ * @see rte_event_dev_stop_flush_callback_register()
  */
 void
 rte_event_dev_stop(uint8_t dev_id);
@@ -1115,6 +1127,12 @@ typedef uint16_t (*event_dequeue_burst_t)(void *port, struct rte_event ev[],
 		uint16_t nb_events, uint64_t timeout_ticks);
 /**< @internal Dequeue burst of events from port of a device */
 
+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. */
 
+	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 */
+
 	struct rte_eventdev_data *data;
 	/**< Pointer to device data */
 	const struct rte_eventdev_ops *dev_ops;
@@ -1822,6 +1845,32 @@ 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().
+ *
+ * @param dev_id
+ *   The identifier of the device.
+ * @param callback
+ *   Callback function invoked once per flushed event.
+ * @param userdata
+ *   Argument supplied to callback.
+ *
+ * @return
+ *  - 0 on success.
+ *  - -EINVAL if *dev_id* is invalid or *callback* is NULL
+ *
+ * @see rte_event_dev_stop()
+ */
+int
+rte_event_dev_stop_flush_callback_register(uint8_t dev_id,
+		eventdev_stop_flush_t callback, void *userdata);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_eventdev/rte_eventdev_version.map b/lib/librte_eventdev/rte_eventdev_version.map
index 2aef470..4396536 100644
--- a/lib/librte_eventdev/rte_eventdev_version.map
+++ b/lib/librte_eventdev/rte_eventdev_version.map
@@ -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;
-- 
2.7.4

^ permalink raw reply	[flat|nested] 29+ messages in thread
* [dpdk-dev] [PATCH v2 0/2] Improve service stop support
@ 2018-06-14 13:51 Gage Eads
  2018-06-21 14:23 ` [dpdk-dev] [PATCH v3 " Gage Eads
  0 siblings, 1 reply; 29+ messages in thread
From: Gage Eads @ 2018-06-14 13:51 UTC (permalink / raw)
  To: dev
  Cc: jerin.jacob, harry.van.haaren, bruce.richardson, nikhil.rao,
	erik.g.carrillo, abhinandan.gujjar

Existing service functions allow us to stop a service, but doing so doesn't
guarantee that the service has finished running on a service core. This
patch set introduces a function, rte_service_may_be_active(), to check
whether a stopped service is truly stopped.

This is needed for flows that modify a resource that the service is
using; for example when stopping an eventdev, any event adapters and/or
scheduler service need to be quiesced first.

This patch set also adds support for the event sw PMD's device stop flush
callback, which relies on this new mechanism to ensure that the
scheduler service is no longer active.

v2:
- Move function to DPDK_18.08 block in rte_eal_version.map
- Fix signed vs. unsigned comparison compiler warning

Gage Eads (2):
  service: add mechanism for quiescing a service
  event/sw: support device stop flush callback

 drivers/event/sw/sw_evdev.c                 | 114 +++++++++++++++++++++++++++-
 drivers/event/sw/sw_evdev_selftest.c        |  81 +++++++++++++++++++-
 lib/librte_eal/common/include/rte_service.h |  16 ++++
 lib/librte_eal/common/rte_service.c         |  31 +++++++-
 lib/librte_eal/rte_eal_version.map          |   7 ++
 test/test/test_service_cores.c              |  43 +++++++++++
 6 files changed, 285 insertions(+), 7 deletions(-)

-- 
2.13.6

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

end of thread, other threads:[~2018-06-21 14:23 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-05 23:01 [dpdk-dev] [PATCH 1/2] eventdev: add device stop flush callback Gage Eads
2018-03-05 23:01 ` [dpdk-dev] [PATCH 2/2] event/sw: support " Gage Eads
2018-03-08 23:10 ` [dpdk-dev] [PATCH v2 1/2] eventdev: add " Gage Eads
2018-03-08 23:10   ` [dpdk-dev] [PATCH v2 2/2] event/sw: support " Gage Eads
2018-03-12  6:25   ` [dpdk-dev] [PATCH v2 1/2] eventdev: add " Jerin Jacob
2018-03-12 14:30     ` Eads, Gage
2018-03-12 14:38       ` Jerin Jacob
2018-03-15  4:12   ` [dpdk-dev] [PATCH v3 " Gage Eads
2018-03-15  4:12     ` [dpdk-dev] [PATCH v3 2/2] event/sw: support " Gage Eads
2018-03-20  7:44     ` [dpdk-dev] [PATCH v3 1/2] eventdev: add " Jerin Jacob
2018-03-20 14:11       ` Eads, Gage
2018-03-20 14:13     ` [dpdk-dev] [PATCH v4 " Gage Eads
2018-03-20 14:13       ` [dpdk-dev] [PATCH v4 2/2] event/sw: support " Gage Eads
2018-03-23 17:05         ` Van Haaren, Harry
2018-03-26 22:01           ` Eads, Gage
2018-04-02  8:03             ` Jerin Jacob
2018-04-02 15:50               ` Eads, Gage
2018-04-02 17:08                 ` Jerin Jacob
2018-03-23 16:57       ` [dpdk-dev] [PATCH v4 1/2] eventdev: add " Van Haaren, Harry
2018-03-26 21:59         ` Eads, Gage
2018-03-27  8:20           ` Van Haaren, Harry
2018-03-29 11:02             ` Van Haaren, Harry
2018-03-29 18:34               ` Jerin Jacob
2018-03-30  9:54               ` Liang, Ma
2018-04-02  8:01       ` Jerin Jacob
2018-04-02 18:03       ` [dpdk-dev] [PATCH v5] " Gage Eads
2018-04-03  1:26         ` Jerin Jacob
2018-04-03  1:31           ` Jerin Jacob
2018-06-14 13:51 [dpdk-dev] [PATCH v2 0/2] Improve service stop support Gage Eads
2018-06-21 14:23 ` [dpdk-dev] [PATCH v3 " Gage Eads
2018-06-21 14:23   ` [dpdk-dev] [PATCH v3 2/2] event/sw: support device stop flush callback Gage Eads

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).