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 EEC14438C4; Sun, 14 Jan 2024 22:59:28 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 81D5D40291; Sun, 14 Jan 2024 22:59:28 +0100 (CET) Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2044.outbound.protection.outlook.com [40.107.105.44]) by mails.dpdk.org (Postfix) with ESMTP id CAAF94013F for ; Sun, 14 Jan 2024 22:59:26 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BU9bX+wFHJH0Ol3MWKe8O2OMaFhHMtVf8H7vBAKzCGxucyi8WJn2wHQHiLuUZv3SUfvXrh9IPlMmMvf2GUWxfgUJU4+PnUcdgL5hRuBU86M9yTmE3fn/hhJJA850e8YlNdKWH3wlcWa+yDovjSBuTtdILlIcy14uJt8AlagNHtb2KexmdNEASmCRBn+O6Qw0aMJBwkmQHNvOy3Nl/WSMIC0swXLKWF9lJvrfMWoCg/i9tFAuDqKY2aboaEseMYu+2HvawNY+U/i3+D3dLi6uZnYQb2sp+F/F7w5eg8wRSQOcXSiuC/D3qmPK8crp0Lblm08jR0aafHHMAO7FU885HA== 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=S/5xCizc/1jQBsPlu1ruRGFW+g5e7qqcmeiMDUqgA5I=; b=Z1TGMGrzfOxxsNgLK2ia4A/iXdhoP0ELr2Lv2w3SJ+BBsBJfyAxSSebbUDe2vYUSwb/wQOyslDdtYUopoPoBZBm4BsbgY6aNLyc9y2jI4kbNZ/AeRC91mEG8oxf3TfuQK/TKsc1wM0/9C1wCokxlaFE6mVyUFkouFgMHq1oq2x76gXaTXvuoqAs7Fhuy8VefqxvgTQ3xCADUhC5HtQdpwk1qKfZ+dG1dY18MDxXLcGhzZvKwy2IS2vFz+7tc/WhEfwzFFYvrgtcqCe/wT9m4O+XY0r6K66dPoZieWRKLPU1X7hDLy8KXlvf9I3d0N1+idXucboBb5VsrWIku8bcsDg== 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=S/5xCizc/1jQBsPlu1ruRGFW+g5e7qqcmeiMDUqgA5I=; b=jOAcuNk/GFbgozm/BTMOLU8sFPZymw8eNf+c6A+ZFxa95oeVhK7lIoWNSd6L83tU4Rdzho1kQSJoRL0Bf6YKwXrXTBuAxnukBfb750sZdOg0WpHtDSOVB/TcFaJ1ha9i7gTisDldj+QfC4gAaD+4nXtA/rZjGZS0+0QXyLvkXPg5sSdyotCMzbEaYhZgofwka6AA2DrrS/UIdr15D/fn5yP4r7nT4fbPExN5JZ8U4jDoLBoG1jo7ZOU1N9PyjHLANhPmz50fUanZL9G1PWZ+8MjrFpANzRVkBXYhy+tQi4e0A6PWPlZlKU0I2zLce04D0TmjOVZA7iSoK5DjkxOZxw== Received: from DU2PR04CA0083.eurprd04.prod.outlook.com (2603:10a6:10:232::28) by DB9PR07MB7338.eurprd07.prod.outlook.com (2603:10a6:10:219::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.23; Sun, 14 Jan 2024 21:59:25 +0000 Received: from DU6PEPF00009527.eurprd02.prod.outlook.com (2603:10a6:10:232:cafe::b0) by DU2PR04CA0083.outlook.office365.com (2603:10a6:10:232::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.23 via Frontend Transport; Sun, 14 Jan 2024 21:59:25 +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 DU6PEPF00009527.mail.protection.outlook.com (10.167.8.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.16 via Frontend Transport; Sun, 14 Jan 2024 21:59:25 +0000 Received: from seliicinfr00050.seli.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.64) with Microsoft SMTP Server id 15.2.1118.40; Sun, 14 Jan 2024 22:59:24 +0100 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00050.seli.gic.ericsson.se (Postfix) with ESMTP id ABEE11C006A; Sun, 14 Jan 2024 22:59:24 +0100 (CET) From: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= To: Jerin Jacob CC: , , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= Subject: [PATCH] event/dsw: optimize serving port logic Date: Sun, 14 Jan 2024 22:50:51 +0100 Message-ID: <20240114215051.366016-1-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 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: DU6PEPF00009527:EE_|DB9PR07MB7338:EE_ X-MS-Office365-Filtering-Correlation-Id: 9410a595-a958-4ff9-9946-08dc154c129a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xoF2lip33SCS5n7EInbvubBQ599f5SQk3Lt+mnhAWXuYcUJ0gcMDdHXVGbWOv6t7HIPSJ+ZTQ1FIKoyZceuVZtbLNlrzy7LUj94efCQ/hAbvSEi/xJrmheHpIvLBr80Cxedwjechbx3uNIwK3HqolhYz72TgyRt/G9Tg41f0SUmvkrAFMqGzWjCn2zrtVeRm+MTb/bkibiten6L3pZAlKZhS7kVvYOTNCJrt8fvzuCSJ430hZ1tRnb2BPCeEckzhe6aam8dvLOeuHzZWBhvezr2v4VooujzoKclpkGZIeJlXD2zSMgsPA8Scvxh5Z6UqfjjI24FQU65kjIeCwS21PhEBkb0QOLo4CR6eT17DmCn7iYU81L65DQl/pmF3/1SYXVhrMpGsClYrEwnjUZudwGVxopi+ie03/7AXLcVwlhv4L4A5tQ2gtiEtv8gK84IEva3BgTjEuNBAK8WIHle29pQEwBG415HrbBecOt2HAHmQXykOO/RaJrkPw3WWsnYhQ53+LZCE4xbIZXCqe/lKieBdqpeRpIQ5q7Ku70aJBaFUqlaJz8wEx+b78tRhhdNgQhm2XiuV1fkx7dOtYqkUtn3w453uKDkYjL3XLbPikAOefatBfrnMudfN0UcIyriOoUw0ysyGdWG+uyKbsztbz9GVHx8/WIA2TK5+PXK6qhBfx+XXlGtVkG/a6n8WYuYGxdwX+aexpeX8pPDX/rAUgaAporYMsuIceTHOTOC/uMtVyvNLYI99lnpKO2iOdip2 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)(346002)(136003)(39860400002)(376002)(230922051799003)(186009)(64100799003)(1800799012)(82310400011)(451199024)(40470700004)(46966006)(36840700001)(83380400001)(36860700001)(47076005)(2616005)(1076003)(6266002)(8936002)(26005)(82740400003)(336012)(4326008)(356005)(7636003)(41300700001)(8676002)(54906003)(70206006)(70586007)(5660300002)(2906002)(107886003)(6916009)(316002)(6666004)(478600001)(86362001)(36756003)(82960400001)(40460700003)(40480700001); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jan 2024 21:59:25.2806 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9410a595-a958-4ff9-9946-08dc154c129a 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: DU6PEPF00009527.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR07MB7338 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 recompile. 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