From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AED9C43B30; Fri, 16 Feb 2024 11:32:00 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D20B94330E; Fri, 16 Feb 2024 11:31:51 +0100 (CET) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2043.outbound.protection.outlook.com [40.107.13.43]) by mails.dpdk.org (Postfix) with ESMTP id BA630402DD for ; Fri, 16 Feb 2024 11:31:48 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cn4JIMN1yypv1KmoSd17YJRdezzvnEJcqNPmReDIF5ZjIYbSaDJhmy31wH4Jqq6mkAhhGJztfCjip4s/XsSBH7W65YKURjf3xvewMIMLGArbH1sxhgDzHJD0LPdts7uBV9iR33iae8Cu2v4eMhAB77NS2zbMv/5/TDCik2WSGsZPg59kJayFkUdvDROQP+YF4aQA+EfKOuWO6030P9qgez0ftsfTtvgAO1EfGv9Z57BA5uHoBqF6OlTJh+4TMjmJAFCyj22hRdApsJkcr2YsCG+tsU2EKfIYTLqrSX+UD6O5Yhx8sX1YvYOEJ9FyFfugNhWtB4CAUM4ZG05Fi3Rixg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+YSApPRKWcdd2D9JT2bZlPmblZF1koIbJYQpUH3KfZc=; b=CGS+TQKl7t10Au6Wl/XEaS2BqQWm1DJ87y+M5EboxckLKrdBpDPxW06jrLgYoq6XxeD2m6stLYRiT1QmMmIofDjb5ww+sgWpznF/IQdiII/AImEEu0eB+05zVEzcXn17VchMm27msYBgoftkw3tKOWf6Z9YzjKn1X8PUVPbAjiwtxe/e26tAFdpWWg60sWB0D/nQCooT61q1sVmjzKeAIMdhDviurbCddCK0WyYb642MIEw8ojNG1784urcOF36wFglGn0jiECPX1H3pTbOBh7KwSeJVMIHxVt779PpfOQ5IaIi9nZKrtw+COaAxsS4P2OZJVCBTsvVpfmIsFAxhgg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 192.176.1.74) smtp.rcpttodomain=dpdk.org smtp.mailfrom=ericsson.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ericsson.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+YSApPRKWcdd2D9JT2bZlPmblZF1koIbJYQpUH3KfZc=; b=XSAXduYXrAer/VJYb3gl50W1t9E/tduaZsZJHkUSRZpD8JOdVqTwpLhSbjTXiMtcB87+799KqP8OOqqmAQiarULAd1MRZGhMOkhTAy5XiZ/Nhys/wiZYjVC5hnwJhsJB6eHMdExq72yzc6qoYVV2wOkWcUT98q/2DJzFRE1wrHbulC8hzCs1zPKJHq/mAnAgaDDl47tdySGWDkn7RCKrpmK12JkSdK2B8W1xMNEraUpG7d0eHpeAh7Eb3J6b6kUaCLyKdPnHLbqIhyjG+hy/tb9DkV5AV7yxfmB0Xz8I3hoGCUeCDHD/5SSPKzlgrGU+uX6tyv0VQib21qXOunOtTQ== Received: from DU2PR04CA0278.eurprd04.prod.outlook.com (2603:10a6:10:28c::13) by GVXPR07MB10014.eurprd07.prod.outlook.com (2603:10a6:150:122::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.31; Fri, 16 Feb 2024 10:31:47 +0000 Received: from DU6PEPF0000B621.eurprd02.prod.outlook.com (2603:10a6:10:28c:cafe::88) by DU2PR04CA0278.outlook.office365.com (2603:10a6:10:28c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.40 via Frontend Transport; Fri, 16 Feb 2024 10:31:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 192.176.1.74) smtp.mailfrom=ericsson.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ericsson.com; Received-SPF: Pass (protection.outlook.com: domain of ericsson.com designates 192.176.1.74 as permitted sender) receiver=protection.outlook.com; client-ip=192.176.1.74; helo=oa.msg.ericsson.com; pr=C Received: from oa.msg.ericsson.com (192.176.1.74) by DU6PEPF0000B621.mail.protection.outlook.com (10.167.8.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.25 via Frontend Transport; Fri, 16 Feb 2024 10:31:46 +0000 Received: from seliicinfr00050.seli.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.63) with Microsoft SMTP Server id 15.2.1258.12; Fri, 16 Feb 2024 11:31:46 +0100 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00050.seli.gic.ericsson.se (Postfix) with ESMTP id 0B5F21C0084; Fri, 16 Feb 2024 11:31:46 +0100 (CET) From: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= To: CC: , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Tyler Retzlaff , Stephen Hemminger , Harry van Haaren , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= Subject: [RFC v4 4/4] event/dsw: optimize serving port logic Date: Fri, 16 Feb 2024 11:23:48 +0100 Message-ID: <20240216102348.480407-4-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240216102348.480407-1-mattias.ronnblom@ericsson.com> References: <20240131131301.418361-1-mattias.ronnblom@ericsson.com> <20240216102348.480407-1-mattias.ronnblom@ericsson.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU6PEPF0000B621:EE_|GVXPR07MB10014:EE_ X-MS-Office365-Filtering-Correlation-Id: 3c23fdc6-b8d0-4b5f-c48f-08dc2eda7a33 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OnvdJnyYM41wf4BVWEgJnp6SsFGdOLApP1RS0sPY+DTlB+RRhnm2SfOrXTqnc6A/zALeVlDy7MRQWa3G/1VQB/S2WeL2b/R+Ts+/mqgehziRf2zeRrn/NTiGmjIjaRbgq3FISmXmfOZGXjfAPY5uIIIDUrbChp4qLkfuMbFIeUGoKH/xgzXm6903VF378EcLh621YjoxTrlu+jJPNGfgwGNfN67xc7M0wvuwyislLPQrldaBvgDKc9Vr1Kxug8uP/2ka6fz3G4GvExzPcof8Wddzoz3BDYFNOJNRQ2DSSJ3rT0V6ypUDxO4thysrUqqOAtQ0ocnAjKtoM3e09VEW2SDU7sjYdmfPL6a5w9yISmSchBOR4IIpPW4sh/MgAqEMvIya5ju05AD76vQD1aj90g/1PpZBi+MoEm/rwUeBpBFP/GYbqhJsKYyhxQSBzsssqGVb9tn6xlYOkRCI8EixdoyfbCar+72+UUVzbSIQF5FCuFkxsY3i0XjLWb/PBHWjK9XZ9/VEmReo0nm5oMxzlNhiXOfM5Cx1P5KCepQ9C8q7cAW+JaK4iK7uP7HalZHz+RzKYAzLNlE5C5ov73wJm9qReQKgCaN0ZmalyL+pACCILkBQGJcCVQVtVCx5U6Gx2Y62Pbn3JuhqjlYANM/qNGeu+z0pDDOpJot1lY/U44w= X-Forefront-Antispam-Report: CIP:192.176.1.74; CTRY:SE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:oa.msg.ericsson.com; PTR:office365.se.ericsson.net; CAT:NONE; SFS:(13230031)(4636009)(396003)(376002)(39860400002)(136003)(346002)(230922051799003)(82310400011)(36860700004)(451199024)(1800799012)(186009)(64100799003)(46966006)(40470700004)(82740400003)(316002)(82960400001)(7636003)(356005)(1076003)(8936002)(4326008)(2906002)(8676002)(6916009)(70586007)(70206006)(86362001)(26005)(107886003)(83380400001)(336012)(41300700001)(54906003)(6266002)(5660300002)(36756003)(2616005)(478600001); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2024 10:31:46.6791 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3c23fdc6-b8d0-4b5f-c48f-08dc2eda7a33 X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=92e84ceb-fbfd-47ab-be52-080c6b87953f; Ip=[192.176.1.74]; Helo=[oa.msg.ericsson.com] X-MS-Exchange-CrossTenant-AuthSource: DU6PEPF0000B621.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR07MB10014 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 --- drivers/event/dsw/dsw_evdev.c | 34 +++++++++++++++++++--------------- drivers/event/dsw/dsw_evdev.h | 3 ++- drivers/event/dsw/dsw_event.c | 11 ++++------- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/drivers/event/dsw/dsw_evdev.c b/drivers/event/dsw/dsw_evdev.c index 1209e73a9d..a0781e4141 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,24 +145,19 @@ dsw_queue_release(struct rte_eventdev *dev __rte_unused, static void queue_add_port(struct dsw_queue *queue, uint16_t port_id) { - queue->serving_ports[queue->num_serving_ports] = port_id; + 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) { - uint16_t i; + if (rte_bitset_test(queue->serving_ports, port_id)) { + queue->num_serving_ports--; + rte_bitset_clear(queue->serving_ports, port_id); + return true; + } - for (i = 0; i < queue->num_serving_ports; i++) - if (queue->serving_ports[i] == port_id) { - uint16_t last_idx = queue->num_serving_ports - 1; - if (i != last_idx) - queue->serving_ports[i] = - queue->serving_ports[last_idx]; - queue->num_serving_ports--; - return true; - } return false; } @@ -256,10 +252,18 @@ 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 port_idx = - rte_rand() % queue->num_serving_ports; - uint8_t port_id = - queue->serving_ports[port_idx]; + uint8_t skip = rte_rand_max(queue->num_serving_ports); + uint8_t port_id; + + for (port_id = 0;; port_id++) { + if (rte_bitset_test(queue->serving_ports, + port_id)) { + if (skip == 0) + break; + skip--; + } + } + dsw->queues[queue_id].flow_to_port_map[flow_hash] = port_id; } diff --git a/drivers/event/dsw/dsw_evdev.h b/drivers/event/dsw/dsw_evdev.h index 6416a8a898..503a63cbb2 100644 --- a/drivers/event/dsw/dsw_evdev.h +++ b/drivers/event/dsw/dsw_evdev.h @@ -7,6 +7,7 @@ #include +#include #include #include @@ -234,7 +235,7 @@ struct dsw_port { struct dsw_queue { uint8_t schedule_type; - uint8_t serving_ports[DSW_MAX_PORTS]; + RTE_BITSET_DECLARE(serving_ports, DSW_MAX_PORTS); uint16_t num_serving_ports; uint8_t flow_to_port_map[DSW_MAX_FLOWS] __rte_cache_aligned; diff --git a/drivers/event/dsw/dsw_event.c b/drivers/event/dsw/dsw_event.c index 93bbeead2e..b855f9ecf1 100644 --- a/drivers/event/dsw/dsw_event.c +++ b/drivers/event/dsw/dsw_event.c @@ -447,13 +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]; - uint16_t i; - - for (i = 0; i < queue->num_serving_ports; i++) - if (queue->serving_ports[i] == port_id) - return true; - return false; + return rte_bitset_test(queue->serving_ports, port_id); } static bool @@ -575,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 = queue->serving_ports[0]; + 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