DPDK-dev Archive on lore.kernel.org
 help / color / Atom feed
* [dpdk-dev] [PATCH] event/dsw: avoid credit leak on oversized enqueue bursts
@ 2020-01-03 11:31 Mattias Rönnblom
  2020-01-14 17:32 ` [dpdk-dev] [EXT] " Jerin Jacob Kollanukkaran
  0 siblings, 1 reply; 4+ messages in thread
From: Mattias Rönnblom @ 2020-01-03 11:31 UTC (permalink / raw)
  To: jerinj; +Cc: dev, Mattias Rönnblom, stable

If an application issues rte_event_enqueue_new_burst() or
rte_event_enqueue_forward_burst() call with a burst of events longer
than the configured max enqueue burst size, DSW allocates credits not
only for events actually enqueued, but for the complete burst. If this
process is repeated, enough credits will have leaked to cause the
event device to backpressure (i.e. disallow) any new enqueue
operations.

In addition, the port-level enqueue xstats will log the wrong number
of events enqueued for oversized enqueues.

This patch makes DSW gracefully handle oversized enqueue bursts.

Fixes: 1c8e3caa3bfb ("event/dsw: add event scheduling and device start/stop")
Cc: stable@dpdk.org

Signed-off-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>
---
 drivers/event/dsw/dsw_event.c | 36 ++++++++++++++++++++++++-----------
 1 file changed, 25 insertions(+), 11 deletions(-)

diff --git a/drivers/event/dsw/dsw_event.c b/drivers/event/dsw/dsw_event.c
index 61a66fabf..b919244c6 100644
--- a/drivers/event/dsw/dsw_event.c
+++ b/drivers/event/dsw/dsw_event.c
@@ -1018,12 +1018,12 @@ dsw_event_enqueue(void *port, const struct rte_event *ev)
 }
 
 static __rte_always_inline uint16_t
-dsw_event_enqueue_burst_generic(void *port, const struct rte_event events[],
+dsw_event_enqueue_burst_generic(struct dsw_port *source_port,
+				const struct rte_event events[],
 				uint16_t events_len, bool op_types_known,
 				uint16_t num_new, uint16_t num_release,
 				uint16_t num_non_release)
 {
-	struct dsw_port *source_port = port;
 	struct dsw_evdev *dsw = source_port->dsw;
 	bool enough_credits;
 	uint16_t i;
@@ -1050,9 +1050,6 @@ dsw_event_enqueue_burst_generic(void *port, const struct rte_event events[],
 		return 0;
 	}
 
-	if (unlikely(events_len > source_port->enqueue_depth))
-		events_len = source_port->enqueue_depth;
-
 	dsw_port_note_op(source_port, events_len);
 
 	if (!op_types_known)
@@ -1108,24 +1105,41 @@ uint16_t
 dsw_event_enqueue_burst(void *port, const struct rte_event events[],
 			uint16_t events_len)
 {
-	return dsw_event_enqueue_burst_generic(port, events, events_len, false,
-					       0, 0, 0);
+	struct dsw_port *source_port = port;
+
+	if (unlikely(events_len > source_port->enqueue_depth))
+		events_len = source_port->enqueue_depth;
+
+	return dsw_event_enqueue_burst_generic(source_port, events,
+					       events_len, false, 0, 0, 0);
 }
 
 uint16_t
 dsw_event_enqueue_new_burst(void *port, const struct rte_event events[],
 			    uint16_t events_len)
 {
-	return dsw_event_enqueue_burst_generic(port, events, events_len, true,
-					       events_len, 0, events_len);
+	struct dsw_port *source_port = port;
+
+	if (unlikely(events_len > source_port->enqueue_depth))
+		events_len = source_port->enqueue_depth;
+
+	return dsw_event_enqueue_burst_generic(source_port, events,
+					       events_len, true, events_len,
+					       0, events_len);
 }
 
 uint16_t
 dsw_event_enqueue_forward_burst(void *port, const struct rte_event events[],
 				uint16_t events_len)
 {
-	return dsw_event_enqueue_burst_generic(port, events, events_len, true,
-					       0, 0, events_len);
+	struct dsw_port *source_port = port;
+
+	if (unlikely(events_len > source_port->enqueue_depth))
+		events_len = source_port->enqueue_depth;
+
+	return dsw_event_enqueue_burst_generic(source_port, events,
+					       events_len, true, 0, 0,
+					       events_len);
 }
 
 uint16_t
-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread
* Re: [dpdk-dev] [PATCH v2] event/dsw: avoid credit leak on oversized enqueue bursts
@ 2020-01-14 19:46 Jerin Jacob Kollanukkaran
  0 siblings, 0 replies; 4+ messages in thread
From: Jerin Jacob Kollanukkaran @ 2020-01-14 19:46 UTC (permalink / raw)
  To: Mattias Rönnblom; +Cc: dev, stable



> -----Original Message-----
> From: Mattias Rönnblom <mattias.ronnblom@ericsson.com>
> Sent: Tuesday, January 14, 2020 11:34 PM
> To: Jerin Jacob Kollanukkaran <jerinj@marvell.com>
> Cc: dev@dpdk.org; Mattias Rönnblom <mattias.ronnblom@ericsson.com>;
> stable@dpdk.org
> Subject: [EXT] [PATCH v2] event/dsw: avoid credit leak on oversized enqueue
> bursts
> 
> If an application issues rte_event_enqueue_new_burst() or
> rte_event_enqueue_forward_burst() call with a burst of events longer than the
> configured max enqueue burst size, DSW allocates credits not only for events
> actually enqueued, but for the complete burst. If this process is repeated,
> enough credits will have leaked to cause the event device to backpressure (i.e.
> disallow) any new enqueue operations.
> 
> In addition, the port-level enqueue xstats will log the wrong number of events
> enqueued for oversized enqueues.
> 
> This patch makes DSW gracefully handle oversized enqueue bursts.
> 
> Fixes: 1c8e3caa3bfb ("event/dsw: add event scheduling and device start/stop")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>

Please add the change log when sending the incremental versions.

v2:

# Fix the following reported compilation error.
http://mails.dpdk.org/archives/dev/2020-January/155161.html

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

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

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-03 11:31 [dpdk-dev] [PATCH] event/dsw: avoid credit leak on oversized enqueue bursts Mattias Rönnblom
2020-01-14 17:32 ` [dpdk-dev] [EXT] " Jerin Jacob Kollanukkaran
2020-01-14 18:03   ` [dpdk-dev] [PATCH v2] " Mattias Rönnblom
2020-01-14 19:46 Jerin Jacob Kollanukkaran

DPDK-dev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/dpdk-dev/0 dpdk-dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dpdk-dev dpdk-dev/ https://lore.kernel.org/dpdk-dev \
		dev@dpdk.org
	public-inbox-index dpdk-dev

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git