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 CBB22438E6; Wed, 17 Jan 2024 08:49:34 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 47987402B0; Wed, 17 Jan 2024 08:49:34 +0100 (CET) Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2087.outbound.protection.outlook.com [40.107.105.87]) by mails.dpdk.org (Postfix) with ESMTP id 282C4402A6 for ; Wed, 17 Jan 2024 08:49:33 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R78g3vm6jReYWS9rMDZPeZhTuL+5lxQ1MJJtYfQPivm+F8/hzDbKdAJL+VkWcUcp6VSwEsrx0DBUUTWdtAlfRhRuBcacyVEyXnzfnvIxCvKXiRTXOsJUpgN4/ReqDMB3ra4YOtC337dwZjuBPhpUXlGXKicEvJafOf4shhIewNpUwlEJyrYxNL4Oc4o4OPmTIQEV/rgffteMy4kX7j68QASccuG99rpRtItbOYjnti366cpxo3quwY0hr03AU3LuWciJxzcHHeuxkmHHPjthZ5bSRgHBP5V+V6VDKDa6mFFxKpl2Hb3EUd8IwVF82YK8Ay4c1ym2J83uJ/0ZMEHKdQ== 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=z8wg7TKlqzOY8MRpc+Sm0IYMqzDZNQCO5a4hnX+YtY0=; b=ldzHr1btdowkS66TjceVK7A6mbTvJ5PUKpEQiA0YM3Vraml5Vl2j6dh7YZ6Nwoe9QzZDo2HAHV2z8nOUv1/PvoDftey11vlkaBxArcK3cUWKLcPYKtEZl58DwyrOw/4uqOl7wCgkU7oGPiJc/MJqoMUBCkZPvy1Knv2I2aYQToGWUbQIxQWj1MqcyV9YD2U47SDhzimC3/lBKjhSvzncEgCZF3zioQXYp8a1pXs9Gpkd4+hnePYOK9vRPdMJmekX5UYiAWEF+uZyEcGcDmq13ahL03WXwUFdT2WQ0UJLJBXs6SHdSF6BSzSqeU5qXguj0Elu+46508Cpx+jhV7nwXw== 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=z8wg7TKlqzOY8MRpc+Sm0IYMqzDZNQCO5a4hnX+YtY0=; b=P7jgwIbqeTPz7twVOIqshvFT77I0RWnOy3esfrxc/co1CkXRU1khBmSs+4vs7Mf/6Umu1GG/xmFLJleQiTPz+QX6IuL+70PHwB5ITlts+r4f17Bx1jYtcpBxijTh9WYimEKVgDTjAwuj8TI2adoMd//Dvw4l3UG929HfRd7UEUPO1bYGraodOMcPvZ34qsz+fO9w3LfRMcu5y6wAdNs9KBMI3lHPzQrjw1FXmLMD1luxS5OXcR89y7M6+VCMXMeV3H14DPISnLLoV2Hz2s8+K2U8rme8W21TEv9G1IHoRSbqBTz+liHofWbGAm5u3kHPVIkmLOvQwRpJCWwJtHujlQ== Received: from DU2PR04CA0331.eurprd04.prod.outlook.com (2603:10a6:10:2b4::19) by PAVPR07MB9312.eurprd07.prod.outlook.com (2603:10a6:102:311::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.23; Wed, 17 Jan 2024 07:49:31 +0000 Received: from DU6PEPF0000B621.eurprd02.prod.outlook.com (2603:10a6:10:2b4:cafe::e1) by DU2PR04CA0331.outlook.office365.com (2603:10a6:10:2b4::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.29 via Frontend Transport; Wed, 17 Jan 2024 07:49:31 +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.7202.16 via Frontend Transport; Wed, 17 Jan 2024 07:49:30 +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; Wed, 17 Jan 2024 08:49:29 +0100 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00049.seli.gic.ericsson.se (Postfix) with ESMTP id 4172E380061; Wed, 17 Jan 2024 08:49:29 +0100 (CET) From: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= To: Jerin Jacob CC: , , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= Subject: [PATCH v3] event/dsw: optimize serving port logic Date: Wed, 17 Jan 2024 08:41:11 +0100 Message-ID: <20240117074111.371682-1-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240116121250.369538-1-mattias.ronnblom@ericsson.com> References: <20240116121250.369538-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_|PAVPR07MB9312:EE_ X-MS-Office365-Filtering-Correlation-Id: 18b515f3-26bf-4d7c-029d-08dc1730d6d9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GEjpkjpoLwA7DSEUDIpyxX11+CtdXfwlPlQvM5UEx658ZbgZ7M0sOc9Z9kJQfE69xALLyCeqBoQGaOKBefqb+YdZT5Fy67Ow0plU9ODaghKLo3rqsXBYiXZ7hW1kYbCGqiQE6Uzp3SdXgk2EaGSaWTRQmy/NojLoN5sZDxDZWcQfVCu3o+zboDA1JfYSOfRusJ+LYrAVi8H+zx8c0riBWrlVKidAlIzx95zFoBYes7Jc9nl/yCPHvPbPbzCXcniaFshcDsXk4LcBDu2F4kFS57T6ZhNEPBAdNScwRMVo2gf+o36+FSYS8ruxsMly0M15CTPqckmrQ8OREdnXf981oVmgXy46jdsYnieF8l44BMp19GlI30yno+eKaCwG+Hd85S89z71VbDsvWu7g2qhDvjMOZswfdfxnV/YMKV/nP0NMUdF0alESFHoEH9BDHx03g51Dco4KQfRFn+EKCU0bvmTy8R7pIS+etQYHEcv4rwvla6fEyloHH+lMfBnNzBWJCtLiqZQq0XFVI0uvwTEu5UdBuN7fSolL7uk/UQ76kci4fl8bDIZ1WioYoJ5kgKgX7JGFmQ2CnFCMiq4Pfwp1t2/jJWGvqqh2lWoDLqbZKioY4RkqeYVo8KZTWpndlSqUrWXW6K4prB/fMFUZKDX3YMI55SBzHnQd4JaKD7odcACcpOIzytT/e68ymL1OBwpGfcmsu8Gduarl/4NLQghjb+4FrqOn0obf3JIVIHTmi8x0fOuN3NX+cQcf18U5vmOp 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)(39860400002)(346002)(136003)(396003)(376002)(230922051799003)(451199024)(186009)(82310400011)(1800799012)(64100799003)(46966006)(36840700001)(40470700004)(47076005)(1076003)(107886003)(26005)(336012)(6266002)(2616005)(83380400001)(82960400001)(356005)(7636003)(36860700001)(41300700001)(82740400003)(8676002)(8936002)(6916009)(54906003)(70206006)(316002)(5660300002)(2906002)(70586007)(4326008)(6666004)(478600001)(36756003)(86362001)(40480700001)(40460700003); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2024 07:49:30.9401 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 18b515f3-26bf-4d7c-029d-08dc1730d6d9 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: PAVPR07MB9312 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 v3: * supply mandantory message to static_assert(). RFC v2: * accidentally left out the contents, which instead was included in v3. 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..d745c89673 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, "Max compile-time port count exceeded"); + 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