DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 1/2] eventdev: add bulk type event ring operations
@ 2023-04-03 13:13 Mattias Rönnblom
  2023-04-03 13:13 ` [PATCH 2/2] event/dsw: replace burst with bulk enqueue Mattias Rönnblom
  2023-04-04  7:03 ` [PATCH 1/2] eventdev: add bulk type event ring operations Jerin Jacob
  0 siblings, 2 replies; 4+ messages in thread
From: Mattias Rönnblom @ 2023-04-03 13:13 UTC (permalink / raw)
  To: Jerin Jacob; +Cc: dev, Peter Nilsson J, Mattias Rönnblom

Introduce bulk enqueue and dequeue operations into the
<rte_event_ring.h> API, to supplement the already-existing burst
calls.

Signed-off-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>
---
 lib/eventdev/rte_event_ring.h | 74 +++++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)

diff --git a/lib/eventdev/rte_event_ring.h b/lib/eventdev/rte_event_ring.h
index 7efa64444b..f9cf19ae16 100644
--- a/lib/eventdev/rte_event_ring.h
+++ b/lib/eventdev/rte_event_ring.h
@@ -67,6 +67,80 @@ rte_event_ring_free_count(const struct rte_event_ring *r)
 	return rte_ring_free_count(&r->r);
 }
 
+
+/**
+ * Enqueue several objects on a ring.
+ *
+ * This function calls the multi-producer or the single-producer
+ * version depending on the default behavior that was specified at
+ * ring creation time (see flags).
+ *
+ * @param r
+ *   pointer to the event ring
+ * @param events
+ *   pointer to an array of struct rte_event objects
+ * @param n
+ *   The number of events in the array to enqueue
+ * @param free_space
+ *   if non-NULL, returns the amount of space in the ring after the
+ *   enqueue operation has completed
+ * @return
+ *   the number of objects enqueued, either 0 or n
+ */
+static __rte_always_inline unsigned int
+rte_event_ring_enqueue_bulk(struct rte_event_ring *r,
+			    const struct rte_event *events,
+			    unsigned int n, uint16_t *free_space)
+{
+	unsigned int num;
+	uint32_t space;
+
+	num = rte_ring_enqueue_bulk_elem(&r->r, events,
+					 sizeof(struct rte_event), n,
+					 &space);
+
+	if (free_space != NULL)
+		*free_space = space;
+
+	return num;
+}
+
+/**
+ * Dequeue a set of events from a ring
+ *
+ * Note: this API does not work with pointers to events, rather it copies
+ * the events themselves to the destination ``events`` buffer.
+ *
+ * @param r
+ *   pointer to the event ring
+ * @param events
+ *   pointer to an array to hold the struct rte_event objects
+ * @param n
+ *   number of events that can be held in the ``events`` array
+ * @param available
+ *   if non-null, is updated to indicate the number of events remaining in
+ *   the ring once the dequeue has completed
+ * @return
+ *   the number of objects dequeued, either 0 or n
+ */
+static __rte_always_inline unsigned int
+rte_event_ring_dequeue_bulk(struct rte_event_ring *r,
+			     struct rte_event *events,
+			     unsigned int n, uint16_t *available)
+{
+	unsigned int num;
+	uint32_t remaining;
+
+	num = rte_ring_dequeue_bulk_elem(&r->r, events,
+					 sizeof(struct rte_event), n,
+					 &remaining);
+
+	if (available != NULL)
+		*available = remaining;
+
+	return num;
+}
+
 /**
  * Enqueue a set of events onto a ring
  *
-- 
2.34.1


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

* [PATCH 2/2] event/dsw: replace burst with bulk enqueue
  2023-04-03 13:13 [PATCH 1/2] eventdev: add bulk type event ring operations Mattias Rönnblom
@ 2023-04-03 13:13 ` Mattias Rönnblom
  2023-04-04  7:03 ` [PATCH 1/2] eventdev: add bulk type event ring operations Jerin Jacob
  1 sibling, 0 replies; 4+ messages in thread
From: Mattias Rönnblom @ 2023-04-03 13:13 UTC (permalink / raw)
  To: Jerin Jacob; +Cc: dev, Peter Nilsson J, Mattias Rönnblom

An enqueue operation to a DSW port's input ring is guaranteed to
succeed, an thus a bulk type enqueue (instead of a burst enqueue) may
be used. There is also need not check the return code of such calls.

This change shaves off a handful of CPU cycles worth of latency per
enqueued event.

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

diff --git a/drivers/event/dsw/dsw_event.c b/drivers/event/dsw/dsw_event.c
index 9932caf2ee..90d298a255 100644
--- a/drivers/event/dsw/dsw_event.c
+++ b/drivers/event/dsw/dsw_event.c
@@ -590,7 +590,6 @@ dsw_port_transmit_buffered(struct dsw_evdev *dsw, struct dsw_port *source_port,
 	struct dsw_port *dest_port = &(dsw->ports[dest_port_id]);
 	uint16_t *buffer_len = &source_port->out_buffer_len[dest_port_id];
 	struct rte_event *buffer = source_port->out_buffer[dest_port_id];
-	uint16_t enqueued = 0;
 
 	if (*buffer_len == 0)
 		return;
@@ -598,13 +597,8 @@ dsw_port_transmit_buffered(struct dsw_evdev *dsw, struct dsw_port *source_port,
 	/* The rings are dimensioned to fit all in-flight events (even
 	 * on a single ring), so looping will work.
 	 */
-	do {
-		enqueued +=
-			rte_event_ring_enqueue_burst(dest_port->in_ring,
-						     buffer+enqueued,
-						     *buffer_len-enqueued,
-						     NULL);
-	} while (unlikely(enqueued != *buffer_len));
+	rte_event_ring_enqueue_bulk(dest_port->in_ring, buffer, *buffer_len,
+				    NULL);
 
 	(*buffer_len) = 0;
 }
-- 
2.34.1


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

* Re: [PATCH 1/2] eventdev: add bulk type event ring operations
  2023-04-03 13:13 [PATCH 1/2] eventdev: add bulk type event ring operations Mattias Rönnblom
  2023-04-03 13:13 ` [PATCH 2/2] event/dsw: replace burst with bulk enqueue Mattias Rönnblom
@ 2023-04-04  7:03 ` Jerin Jacob
  2023-05-02 10:32   ` Jerin Jacob
  1 sibling, 1 reply; 4+ messages in thread
From: Jerin Jacob @ 2023-04-04  7:03 UTC (permalink / raw)
  To: Mattias Rönnblom, Richardson, Bruce
  Cc: Jerin Jacob, dev, Peter Nilsson J

On Mon, Apr 3, 2023 at 6:49 PM Mattias Rönnblom
<mattias.ronnblom@ericsson.com> wrote:
>
> Introduce bulk enqueue and dequeue operations into the
> <rte_event_ring.h> API, to supplement the already-existing burst
> calls.
>
> Signed-off-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>

Looks good to me.
As the original author adding @Richardson, Bruce  for review.


> ---
>  lib/eventdev/rte_event_ring.h | 74 +++++++++++++++++++++++++++++++++++
>  1 file changed, 74 insertions(+)
>
> diff --git a/lib/eventdev/rte_event_ring.h b/lib/eventdev/rte_event_ring.h
> index 7efa64444b..f9cf19ae16 100644
> --- a/lib/eventdev/rte_event_ring.h
> +++ b/lib/eventdev/rte_event_ring.h
> @@ -67,6 +67,80 @@ rte_event_ring_free_count(const struct rte_event_ring *r)
>         return rte_ring_free_count(&r->r);
>  }
>
> +
> +/**
> + * Enqueue several objects on a ring.
> + *
> + * This function calls the multi-producer or the single-producer
> + * version depending on the default behavior that was specified at
> + * ring creation time (see flags).
> + *
> + * @param r
> + *   pointer to the event ring
> + * @param events
> + *   pointer to an array of struct rte_event objects
> + * @param n
> + *   The number of events in the array to enqueue
> + * @param free_space
> + *   if non-NULL, returns the amount of space in the ring after the
> + *   enqueue operation has completed
> + * @return
> + *   the number of objects enqueued, either 0 or n
> + */
> +static __rte_always_inline unsigned int
> +rte_event_ring_enqueue_bulk(struct rte_event_ring *r,
> +                           const struct rte_event *events,
> +                           unsigned int n, uint16_t *free_space)
> +{
> +       unsigned int num;
> +       uint32_t space;
> +
> +       num = rte_ring_enqueue_bulk_elem(&r->r, events,
> +                                        sizeof(struct rte_event), n,
> +                                        &space);
> +
> +       if (free_space != NULL)
> +               *free_space = space;
> +
> +       return num;
> +}
> +
> +/**
> + * Dequeue a set of events from a ring
> + *
> + * Note: this API does not work with pointers to events, rather it copies
> + * the events themselves to the destination ``events`` buffer.
> + *
> + * @param r
> + *   pointer to the event ring
> + * @param events
> + *   pointer to an array to hold the struct rte_event objects
> + * @param n
> + *   number of events that can be held in the ``events`` array
> + * @param available
> + *   if non-null, is updated to indicate the number of events remaining in
> + *   the ring once the dequeue has completed
> + * @return
> + *   the number of objects dequeued, either 0 or n
> + */
> +static __rte_always_inline unsigned int
> +rte_event_ring_dequeue_bulk(struct rte_event_ring *r,
> +                            struct rte_event *events,
> +                            unsigned int n, uint16_t *available)
> +{
> +       unsigned int num;
> +       uint32_t remaining;
> +
> +       num = rte_ring_dequeue_bulk_elem(&r->r, events,
> +                                        sizeof(struct rte_event), n,
> +                                        &remaining);
> +
> +       if (available != NULL)
> +               *available = remaining;
> +
> +       return num;
> +}
> +
>  /**
>   * Enqueue a set of events onto a ring
>   *
> --
> 2.34.1
>

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

* Re: [PATCH 1/2] eventdev: add bulk type event ring operations
  2023-04-04  7:03 ` [PATCH 1/2] eventdev: add bulk type event ring operations Jerin Jacob
@ 2023-05-02 10:32   ` Jerin Jacob
  0 siblings, 0 replies; 4+ messages in thread
From: Jerin Jacob @ 2023-05-02 10:32 UTC (permalink / raw)
  To: Mattias Rönnblom, Richardson, Bruce
  Cc: Jerin Jacob, dev, Peter Nilsson J

On Tue, Apr 4, 2023 at 12:33 PM Jerin Jacob <jerinjacobk@gmail.com> wrote:
>
> On Mon, Apr 3, 2023 at 6:49 PM Mattias Rönnblom
> <mattias.ronnblom@ericsson.com> wrote:
> >
> > Introduce bulk enqueue and dequeue operations into the
> > <rte_event_ring.h> API, to supplement the already-existing burst
> > calls.
> >
> > Signed-off-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>
>
> Looks good to me.
> As the original author adding @Richardson, Bruce  for review.


Acked-by: Jerin Jacob <jerinj@marvell.com>

Series applied to dpdk-next-net-eventdev/for-main. Thanks


>
>
> > ---
> >  lib/eventdev/rte_event_ring.h | 74 +++++++++++++++++++++++++++++++++++
> >  1 file changed, 74 insertions(+)
> >
> > diff --git a/lib/eventdev/rte_event_ring.h b/lib/eventdev/rte_event_ring.h
> > index 7efa64444b..f9cf19ae16 100644
> > --- a/lib/eventdev/rte_event_ring.h
> > +++ b/lib/eventdev/rte_event_ring.h
> > @@ -67,6 +67,80 @@ rte_event_ring_free_count(const struct rte_event_ring *r)
> >         return rte_ring_free_count(&r->r);
> >  }
> >
> > +
> > +/**
> > + * Enqueue several objects on a ring.
> > + *
> > + * This function calls the multi-producer or the single-producer
> > + * version depending on the default behavior that was specified at
> > + * ring creation time (see flags).
> > + *
> > + * @param r
> > + *   pointer to the event ring
> > + * @param events
> > + *   pointer to an array of struct rte_event objects
> > + * @param n
> > + *   The number of events in the array to enqueue
> > + * @param free_space
> > + *   if non-NULL, returns the amount of space in the ring after the
> > + *   enqueue operation has completed
> > + * @return
> > + *   the number of objects enqueued, either 0 or n
> > + */
> > +static __rte_always_inline unsigned int
> > +rte_event_ring_enqueue_bulk(struct rte_event_ring *r,
> > +                           const struct rte_event *events,
> > +                           unsigned int n, uint16_t *free_space)
> > +{
> > +       unsigned int num;
> > +       uint32_t space;
> > +
> > +       num = rte_ring_enqueue_bulk_elem(&r->r, events,
> > +                                        sizeof(struct rte_event), n,
> > +                                        &space);
> > +
> > +       if (free_space != NULL)
> > +               *free_space = space;
> > +
> > +       return num;
> > +}
> > +
> > +/**
> > + * Dequeue a set of events from a ring
> > + *
> > + * Note: this API does not work with pointers to events, rather it copies
> > + * the events themselves to the destination ``events`` buffer.
> > + *
> > + * @param r
> > + *   pointer to the event ring
> > + * @param events
> > + *   pointer to an array to hold the struct rte_event objects
> > + * @param n
> > + *   number of events that can be held in the ``events`` array
> > + * @param available
> > + *   if non-null, is updated to indicate the number of events remaining in
> > + *   the ring once the dequeue has completed
> > + * @return
> > + *   the number of objects dequeued, either 0 or n
> > + */
> > +static __rte_always_inline unsigned int
> > +rte_event_ring_dequeue_bulk(struct rte_event_ring *r,
> > +                            struct rte_event *events,
> > +                            unsigned int n, uint16_t *available)
> > +{
> > +       unsigned int num;
> > +       uint32_t remaining;
> > +
> > +       num = rte_ring_dequeue_bulk_elem(&r->r, events,
> > +                                        sizeof(struct rte_event), n,
> > +                                        &remaining);
> > +
> > +       if (available != NULL)
> > +               *available = remaining;
> > +
> > +       return num;
> > +}
> > +
> >  /**
> >   * Enqueue a set of events onto a ring
> >   *
> > --
> > 2.34.1
> >

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

end of thread, other threads:[~2023-05-02 10:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-03 13:13 [PATCH 1/2] eventdev: add bulk type event ring operations Mattias Rönnblom
2023-04-03 13:13 ` [PATCH 2/2] event/dsw: replace burst with bulk enqueue Mattias Rönnblom
2023-04-04  7:03 ` [PATCH 1/2] eventdev: add bulk type event ring operations Jerin Jacob
2023-05-02 10:32   ` Jerin Jacob

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