From: "Mattias Rönnblom" <mattias.ronnblom@ericsson.com>
To: <dev@dpdk.org>
Cc: hofors@lysator.liu.se, "Morten Brørup" <mb@smartsharesystems.com>,
"Tyler Retzlaff" <roretzla@linux.microsoft.com>,
"Stephen Hemminger" <stephen@networkplumber.org>,
"Harry van Haaren" <harry.van.haaren@intel.com>,
"Mattias Rönnblom" <mattias.ronnblom@ericsson.com>
Subject: [RFC v5 6/6] event/dsw: optimize serving port logic
Date: Sun, 5 May 2024 09:33:13 +0200 [thread overview]
Message-ID: <20240505073313.118515-6-mattias.ronnblom@ericsson.com> (raw)
In-Reply-To: <20240505073313.118515-1-mattias.ronnblom@ericsson.com>
To reduce flow migration overhead, replace the array-based
representation of which set of ports are bound to a particular queue
by a multi-word bitset.
Signed-off-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>
---
drivers/event/dsw/dsw_evdev.c | 19 +++++++------------
drivers/event/dsw/dsw_evdev.h | 3 ++-
drivers/event/dsw/dsw_event.c | 7 ++++---
3 files changed, 13 insertions(+), 16 deletions(-)
diff --git a/drivers/event/dsw/dsw_evdev.c b/drivers/event/dsw/dsw_evdev.c
index ab0420b549..f3ca99e935 100644
--- a/drivers/event/dsw/dsw_evdev.c
+++ b/drivers/event/dsw/dsw_evdev.c
@@ -118,6 +118,7 @@ dsw_queue_setup(struct rte_eventdev *dev, uint8_t queue_id,
queue->schedule_type = conf->schedule_type;
}
+ rte_bitset_init(queue->serving_ports, DSW_MAX_PORTS);
queue->num_serving_ports = 0;
return 0;
@@ -144,20 +145,16 @@ dsw_queue_release(struct rte_eventdev *dev __rte_unused,
static void
queue_add_port(struct dsw_queue *queue, uint16_t port_id)
{
- uint64_t port_mask = UINT64_C(1) << port_id;
-
- queue->serving_ports |= port_mask;
+ rte_bitset_set(queue->serving_ports, port_id);
queue->num_serving_ports++;
}
static bool
queue_remove_port(struct dsw_queue *queue, uint16_t port_id)
{
- uint64_t port_mask = UINT64_C(1) << port_id;
-
- if (queue->serving_ports & port_mask) {
+ if (rte_bitset_test(queue->serving_ports, port_id)) {
queue->num_serving_ports--;
- queue->serving_ports ^= port_mask;
+ rte_bitset_clear(queue->serving_ports, port_id);
return true;
}
@@ -257,14 +254,12 @@ initial_flow_to_port_assignment(struct dsw_evdev *dsw)
struct dsw_queue *queue = &dsw->queues[queue_id];
uint16_t flow_hash;
for (flow_hash = 0; flow_hash < DSW_MAX_FLOWS; flow_hash++) {
- uint8_t skip =
- rte_rand_max(queue->num_serving_ports);
+ uint8_t skip = rte_rand_max(queue->num_serving_ports);
uint8_t port_id;
for (port_id = 0;; port_id++) {
- uint64_t port_mask = UINT64_C(1) << port_id;
-
- if (queue->serving_ports & port_mask) {
+ if (rte_bitset_test(queue->serving_ports,
+ port_id)) {
if (skip == 0)
break;
skip--;
diff --git a/drivers/event/dsw/dsw_evdev.h b/drivers/event/dsw/dsw_evdev.h
index 3a5989f148..0c40c45e46 100644
--- a/drivers/event/dsw/dsw_evdev.h
+++ b/drivers/event/dsw/dsw_evdev.h
@@ -7,6 +7,7 @@
#include <eventdev_pmd.h>
+#include <rte_bitset.h>
#include <rte_event_ring.h>
#include <rte_eventdev.h>
@@ -234,7 +235,7 @@ struct __rte_cache_aligned dsw_port {
struct dsw_queue {
uint8_t schedule_type;
- uint64_t serving_ports;
+ RTE_BITSET_DECLARE(serving_ports, DSW_MAX_PORTS);
uint16_t num_serving_ports;
alignas(RTE_CACHE_LINE_SIZE) uint8_t flow_to_port_map[DSW_MAX_FLOWS];
diff --git a/drivers/event/dsw/dsw_event.c b/drivers/event/dsw/dsw_event.c
index 23488d9030..b855f9ecf1 100644
--- a/drivers/event/dsw/dsw_event.c
+++ b/drivers/event/dsw/dsw_event.c
@@ -447,9 +447,8 @@ static bool
dsw_is_serving_port(struct dsw_evdev *dsw, uint8_t port_id, uint8_t queue_id)
{
struct dsw_queue *queue = &dsw->queues[queue_id];
- uint64_t port_mask = UINT64_C(1) << port_id;
- return queue->serving_ports & port_mask;
+ return rte_bitset_test(queue->serving_ports, port_id);
}
static bool
@@ -571,7 +570,9 @@ dsw_schedule(struct dsw_evdev *dsw, uint8_t queue_id, uint16_t flow_hash)
/* A single-link queue, or atomic/ordered/parallel but
* with just a single serving port.
*/
- port_id = rte_bsf64(queue->serving_ports);
+ port_id = (uint8_t)rte_bitset_find_first_set(
+ queue->serving_ports, DSW_MAX_PORTS
+ );
DSW_LOG_DP(DEBUG, "Event with queue_id %d flow_hash %d is scheduled "
"to port %d.\n", queue_id, flow_hash, port_id);
--
2.34.1
prev parent reply other threads:[~2024-05-05 7:44 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-31 13:13 [RFC v3] eal: add bitset type Mattias Rönnblom
2024-01-31 16:02 ` Stephen Hemminger
2024-01-31 16:28 ` Mattias Rönnblom
2024-01-31 16:06 ` Stephen Hemminger
2024-01-31 18:45 ` Mattias Rönnblom
2024-02-01 8:04 ` Morten Brørup
2024-02-02 10:19 ` Mattias Rönnblom
2024-02-02 12:42 ` Morten Brørup
2024-02-16 10:23 ` [RFC v4 1/4] " Mattias Rönnblom
2024-02-16 10:23 ` [RFC v4 2/4] eal: add bitset test suite Mattias Rönnblom
2024-02-16 10:23 ` [RFC v4 3/4] service: use multi-word bitset to represent service flags Mattias Rönnblom
2024-02-16 10:23 ` [RFC v4 4/4] event/dsw: optimize serving port logic Mattias Rönnblom
2024-05-05 7:33 ` [RFC v5 1/6] eal: add bitset type Mattias Rönnblom
2024-05-05 7:33 ` [RFC v5 2/6] eal: add bitset test suite Mattias Rönnblom
2024-05-05 7:33 ` [RFC v5 3/6] eal: add atomic bitset functions Mattias Rönnblom
2024-05-05 7:33 ` [RFC v5 4/6] eal: add unit tests for atomic bitset operations Mattias Rönnblom
2024-05-05 7:33 ` [RFC v5 5/6] service: use multi-word bitset to represent service flags Mattias Rönnblom
2024-05-05 7:33 ` Mattias Rönnblom [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240505073313.118515-6-mattias.ronnblom@ericsson.com \
--to=mattias.ronnblom@ericsson.com \
--cc=dev@dpdk.org \
--cc=harry.van.haaren@intel.com \
--cc=hofors@lysator.liu.se \
--cc=mb@smartsharesystems.com \
--cc=roretzla@linux.microsoft.com \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).