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 28EDE438DC; Tue, 16 Jan 2024 13:21:26 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9FE9140278; Tue, 16 Jan 2024 13:21:25 +0100 (CET) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2043.outbound.protection.outlook.com [40.107.22.43]) by mails.dpdk.org (Postfix) with ESMTP id 7E98C40042 for ; Tue, 16 Jan 2024 13:21:23 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nH0q+pd+LN+U8UocrCliyuM/5uf31yS5JU1/BVqrkpYqocFC8P5PNm5zNOVHoJ7bHBBS3RamhorrrJ4bByn6/JcruxADf1acq4Ww5oCQ37lVaqfNIxzkOB+wmHK4UA11IdfFwWH38+ozOOd3W21N88u++59HToWWFLXlFpxiqiURvtLRA1fRX0fTEaOJwjzeheP95ECojjQXNrNq4Y0N/8oqw83I8sAER5qw9Bdf2MLSwFeZkhTy+g4KavQWQyv3OMWNZbI5tJvkJbvxfprhB8ojSvXzb3V4z+o2eTHqxCe1D8vrhkunKU1Yt8H2xZPxiysSpjpL2PIHhEGiR5gOnQ== 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=0QtPu7m3/+LbO9XRctfoQYV78FkWgFtGd7CZK5qZJn4=; b=MN2hi+32GkESx6+sBiBkjixgDCqQnSqpvsgmGR5qz3TC44CY2Ur0vFnqMqMxKR2RPRd9ZNdSUo9NglNOW10mpdA9pm+lNyQ+GOLA0iGJWZK9WtS8+Dvoy9QjLVdb44BiYZTfhcCc6y1aTUFgdmgdtiDQGYMsqirHLIM1NwQKIvYqF7p6RX8doeK4z6SgHvH5ptC/QqSktp/Wzpqy/eZsQCLxcpq2ai1mgqUcT1/HY42yKjT68UvPwPmYNXXylhxZY3TokBYJXgc7Bu4rWgFsZfkAy7X9kd/ptkNzbhMwu/IM9W4/fUrWXJJpavliDH8Tw68lbHbiOe6KFII6GuT7lw== 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=0QtPu7m3/+LbO9XRctfoQYV78FkWgFtGd7CZK5qZJn4=; b=gHSQBcF7H/LVv6DZu5P/BeqM1W2gxScApgOdKAUVYCZhYtpqpiMBQ1fCD1u+AwUXwf7HrYUOb4QJm89eqHfjHF/TxnzvrlpsTeK9W9R3/gJNuOp/TvcMmQPaKQ1Ic9TM/vcpo0oPG7LJQjBzdFCq9DS2cYC4I44OIy5iE/VlPsFlKB/bCPIJ4tg0eLsusemiw1zjVTDLc4bZaEVZKQrJ+acXuz90NE3xBDTBMRkON5u6ax4bq4Dzr5IKf2RFUffw4zFokJvexckvt4cXMPCjSaLmJR6X7y8wjGaX9e89B0xIjP0Qzb7JfuyKmqSXir1CtDe4OY9fg9Xg1uffbIvDHQ== Received: from DUZPR01CA0245.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b5::25) by PA4PR07MB7614.eurprd07.prod.outlook.com (2603:10a6:102:c6::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.29; Tue, 16 Jan 2024 12:21:20 +0000 Received: from DB1PEPF00039230.eurprd03.prod.outlook.com (2603:10a6:10:4b5:cafe::76) by DUZPR01CA0245.outlook.office365.com (2603:10a6:10:4b5::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.29 via Frontend Transport; Tue, 16 Jan 2024 12:21:20 +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 DB1PEPF00039230.mail.protection.outlook.com (10.167.8.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.16 via Frontend Transport; Tue, 16 Jan 2024 12:21:20 +0000 Received: from seliicinfr00049.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.1118.40; Tue, 16 Jan 2024 13:21:19 +0100 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00049.seli.gic.ericsson.se (Postfix) with ESMTP id 1C8A6380061; Tue, 16 Jan 2024 13:21:19 +0100 (CET) From: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= To: Jerin Jacob CC: , , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= Subject: [PATCH v2] event/dsw: optimize serving port logic Date: Tue, 16 Jan 2024 13:12:50 +0100 Message-ID: <20240116121250.369538-1-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240114215051.366016-1-mattias.ronnblom@ericsson.com> References: <20240114215051.366016-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: DB1PEPF00039230:EE_|PA4PR07MB7614:EE_ X-MS-Office365-Filtering-Correlation-Id: bd1ddf7d-f9cf-4b48-969c-08dc168da566 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4bF8zxnfMqoPAiWev0B/aQjkrxJDhUkc7ieiSofQIJ9sfrJf5O9UDpnD55pMUJdCYUJuaSlezA7iEb6nSyz38DxOsND30jROE/pbvnbUqrBXFKrRa+sZ+p+CPsGkj2YYT7EUk3TMn6oy+uft8lFN4C7LQoj/uhgn7sh89h51eeZBC2v9RkyZGsr+yd6lekY1g1CsSADLMol/cznxllEqcgLyteW41Cm36Fn7E+uyUWWf+ChX7SAr4HpiWA9DhSUaWtOea/rq0n7Y8eQAWbkgqS49T/lOFlqM6Prx7tNZC37IhZL2IrugHt5FDIx5M696UyK7VRjExv7advwsXtgf5DNRi6QX6HDF80ISnY5fUUPGbnfbwdjH64LKIahy7pnNIU00kLb6/snnXS1IrRJq5BozVpSz5T5UgZmnxlqrdFah8kJ4sWMdNxrHXDZQGZ6A7pLEpAwh2UvEuv0ttaiqJGGh18JDBzEM38tM8fUbQ7v4O2phprGGY3Xxt2Mga1oQv/hQT5gGV4IIcX76Lsx2zv4OACwF+UN4vUZhhnSMyyjl/AvVAdA24HN05ytHXn0UuM7938fwamiCpx5ziJgeS/kYqgZaqEKxjHf7y4RGjG3BOV6tmMlR8XK6rAxdg4tMphM87ET9E4D8J7x3a0l4Y42MORpSKQUoA0c/bnuBLbfK9wMp/apG/n2D3y+HZiV5Phk6knvEwZLpRNeVY8WSRZcmm870qcFo7KY/RrDPsNiooEUQpoHgaH11EYV3dwvX 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)(346002)(136003)(39860400002)(396003)(376002)(230922051799003)(64100799003)(186009)(82310400011)(451199024)(1800799012)(40470700004)(46966006)(36840700001)(336012)(2616005)(6266002)(26005)(1076003)(107886003)(83380400001)(6666004)(36860700001)(82740400003)(47076005)(5660300002)(4326008)(41300700001)(2906002)(478600001)(8676002)(8936002)(70206006)(70586007)(6916009)(316002)(54906003)(86362001)(36756003)(82960400001)(356005)(7636003)(40480700001)(40460700003); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2024 12:21:20.0150 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bd1ddf7d-f9cf-4b48-969c-08dc168da566 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: DB1PEPF00039230.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR07MB7614 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 bitmask-based one. The maximum number of DSW event ports remains 64, but after this change can no longer easily be increased by modifying DSW_MAX_PORTS and recompiling. RFC v2: * supply mandantory message to static_assert(). Signed-off-by: Mattias Rönnblom --- drivers/event/dsw/dsw_evdev.c | 39 +++++++++++++++++++++-------------- drivers/event/dsw/dsw_evdev.h | 5 ++++- drivers/event/dsw/dsw_event.c | 10 +++------ 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/drivers/event/dsw/dsw_evdev.c b/drivers/event/dsw/dsw_evdev.c index 1209e73a9d..629c929cb2 100644 --- a/drivers/event/dsw/dsw_evdev.c +++ b/drivers/event/dsw/dsw_evdev.c @@ -144,24 +144,23 @@ 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; + uint64_t port_mask = UINT64_C(1) << port_id; + + queue->serving_ports |= port_mask; queue->num_serving_ports++; } static bool queue_remove_port(struct dsw_queue *queue, uint16_t port_id) { - uint16_t i; + uint64_t port_mask = UINT64_C(1) << port_id; + + if (queue->serving_ports & port_mask) { + queue->num_serving_ports--; + queue->serving_ports ^= port_mask; + 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 +255,20 @@ 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++) { + uint64_t port_mask = UINT64_C(1) << port_id; + + if (queue->serving_ports & port_mask) { + 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..8166340e1e 100644 --- a/drivers/event/dsw/dsw_evdev.h +++ b/drivers/event/dsw/dsw_evdev.h @@ -234,12 +234,15 @@ struct dsw_port { struct dsw_queue { uint8_t schedule_type; - uint8_t serving_ports[DSW_MAX_PORTS]; + uint64_t serving_ports; uint16_t num_serving_ports; uint8_t flow_to_port_map[DSW_MAX_FLOWS] __rte_cache_aligned; }; +/* Limited by the size of the 'serving_ports' bitmask */ +static_assert(DSW_MAX_PORTS <= 64); + struct dsw_evdev { struct rte_eventdev_data *data; diff --git a/drivers/event/dsw/dsw_event.c b/drivers/event/dsw/dsw_event.c index 93bbeead2e..23488d9030 100644 --- a/drivers/event/dsw/dsw_event.c +++ b/drivers/event/dsw/dsw_event.c @@ -447,13 +447,9 @@ 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; + uint64_t port_mask = UINT64_C(1) << port_id; - return false; + return queue->serving_ports & port_mask; } static bool @@ -575,7 +571,7 @@ 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 = rte_bsf64(queue->serving_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