Message ID | 20240809090439.589295-1-mattias.ronnblom@ericsson.com (mailing list archive) |
---|---|
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 443E245777; Fri, 9 Aug 2024 11:14:43 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7868942E8D; Fri, 9 Aug 2024 11:14:23 +0200 (CEST) Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on2042.outbound.protection.outlook.com [40.107.103.42]) by mails.dpdk.org (Postfix) with ESMTP id 742D3427E3 for <dev@dpdk.org>; Fri, 9 Aug 2024 11:14:19 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aAQnbSA8YUEz1dreQyszghXNMhtYqEdjw5Z3pAEDDP7uBUpplRwY2WbcU0ieQ1E+CY3tSh6T2JEbd0HuOOVvNh0YUORS9czzMY31j0Ur177OmhpHUPBLv0FIxYyg0gXH/U69TbDAMfmUI2C3gNHcAc7yTh335xcdtiQq/2Q9QCxRNhXhxN3MbEg8TTbGnA3P/rQUGvSxHoDY+UAZwV0kskXIg7sRyS7hdVDPw8z4Uj/nzOvO3UCA9bmW8zn8MjwTFa3N297O99s61yddHLYdl3Rmg0tcQyiC1L82plHAdr40cgzHPjidttVSdDl288kXMRHmit/I4EslR2Wrb9PrIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=mfV0PuRHvGFS2wtRcZJIO+BbTfNrJByPCGUQ/M3caYc=; b=BmQTS8CLiT8wmnMbdFbO4iV22u+cmjwcEL0A5+blj6bptPh2o2EE5YumqybVto74FlKLxw6So/ufmSrzgjiYP+T4Yqk7qdcuKivFXmHjfl6YLHPjaUsVe16I9KZISINRgXUQsVCa9rbAsaB7Hu6Q98hzByTnhpkXzITo6XkiKIU/ewNtGh6kxuJXsibpbqcj589nlptMkI20KGqMHyXyw65qnjfFCm6gZP1C595CTH2PUWf8G3SNi8dc7zidXBzy1lnYwvGI0I5yjY3SZcBGh4TKCnJiovXoCPfMno9xHqIJSLR3RxV5Na8SpSMnMBGCYl+zxOAiBPgzu4wKpSESnw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 192.176.1.74) smtp.rcpttodomain=arm.com 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=mfV0PuRHvGFS2wtRcZJIO+BbTfNrJByPCGUQ/M3caYc=; b=G276N0TZevYSI5fTbAV6iBcD0Mm3nMKX38hyajDJeMTYHCMaiMpViIGnlwfHO155xkFdVih/RxLvWuVYdJ8RCk6BQp1MXENq81QmmJc/lrpvFmu5h4A7zJ0B7Q3YV989mOIsk7gAj6l6M1OEOOINhE583harUDAjC8KAADoM55yj62Xjd/p9YHfoMci7YRt0hrBqIZRmwwN9bK1Pb3kpQO+yyRpzKuIjXrOtZ6HblMtgRfm8RjNaqJhycIfjsuw/7WAjj4m+Tzg3v8mpegpfnvfd0E1YB+jusoZHSXNOOLUPKoYw7jMkp4jqSVaWMMAnabAaS/9WZVkd7P+7JNi0vQ== Received: from PR1P264CA0136.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:2ce::11) by DB8PR07MB6379.eurprd07.prod.outlook.com (2603:10a6:10:134::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.15; Fri, 9 Aug 2024 09:14:16 +0000 Received: from AM4PEPF00025F96.EURPRD83.prod.outlook.com (2603:10a6:102:2ce:cafe::77) by PR1P264CA0136.outlook.office365.com (2603:10a6:102:2ce::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.15 via Frontend Transport; Fri, 9 Aug 2024 09:14:16 +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 AM4PEPF00025F96.mail.protection.outlook.com (10.167.16.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.2 via Frontend Transport; Fri, 9 Aug 2024 09:14:15 +0000 Received: from seliicinfr00050.seli.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.67) with Microsoft SMTP Server id 15.2.1544.11; Fri, 9 Aug 2024 11:14:15 +0200 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00050.seli.gic.ericsson.se (Postfix) with ESMTP id 7D8BB1C006A; Fri, 9 Aug 2024 11:14:15 +0200 (CEST) From: =?utf-8?q?Mattias_R=C3=B6nnblom?= <mattias.ronnblom@ericsson.com> To: <dev@dpdk.org> CC: <hofors@lysator.liu.se>, Heng Wang <heng.wang@ericsson.com>, "Stephen Hemminger" <stephen@networkplumber.org>, Joyce Kong <joyce.kong@arm.com>, Tyler Retzlaff <roretzla@linux.microsoft.com>, =?utf-8?q?Morten_Br=C3=B8rup?= <mb@smartsharesystems.com>, =?utf-8?q?Mattia?= =?utf-8?q?s_R=C3=B6nnblom?= <mattias.ronnblom@ericsson.com> Subject: [PATCH 0/5] Improve EAL bit operations API Date: Fri, 9 Aug 2024 11:04:34 +0200 Message-ID: <20240809090439.589295-1-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240505083737.118649-2-mattias.ronnblom@ericsson.com> References: <20240505083737.118649-2-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: AM4PEPF00025F96:EE_|DB8PR07MB6379:EE_ X-MS-Office365-Filtering-Correlation-Id: 9b84db5a-b891-4a4b-c53a-08dcb853a46b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|376014|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?5uUXRCQF2cB+LGvS2FYh0CELFkvdXs6?= =?utf-8?q?ihkbmAuSV1QbzsXsAuL2MQAJQOxK7Byrq3m6ZuH9Ar52Dl0zNaCCqP5KALm7ZE1yx?= =?utf-8?q?vRKVhF8nI6fFjrKb4HvsObwQIh3EOqqz3pZqdo/F1oqho6uLKYlGihxtRuK6kqzSF?= =?utf-8?q?sz1jswgZ804hTDhUvX9F537idxS1wFwxLCNa1pNLr4ggHhyJfAoKpruAxl+ufYAFN?= =?utf-8?q?P4ptdYDVl1lNsXpBJyQ5fwQhrB2Maz6+KhUYzI58QmJV14quw99U2EXBX5p9AvSqD?= =?utf-8?q?jWmiUj7Rf9JeWZg3+zSEhBHuz9AiG3m8hQZoeKzjn74+OgzKQc3WbIcGqHncLXbM7?= =?utf-8?q?4p7lZGr/4wtrq//vT+11bM1Tg/EUeovp1D6FFsJ9AnWpgw8d49zDj/4iV1pGKWS2c?=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8?q?VAdf8X+pyI/Wx2MNywpHS+ywpwJTzlVLvDiquFxRqHc9K1xlictc3m7smSo5ovYgb?= =?utf-8?q?B6OsMeLqh8TpQNYuPSyS0JCVmha/bsq67WmIWdKFjY7HipdvLDyhO4+MYwZ6Ofk6U?= =?utf-8?q?yutMKU5CKSI?= 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:(13230040)(1800799024)(82310400026)(376014)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2024 09:14:15.9465 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9b84db5a-b891-4a4b-c53a-08dcb853a46b 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: AM4PEPF00025F96.EURPRD83.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR07MB6379 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions <dev.dpdk.org> List-Unsubscribe: <https://mails.dpdk.org/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://mails.dpdk.org/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <https://mails.dpdk.org/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org |
Series | Improve EAL bit operations API | |
Message
Mattias Rönnblom
Aug. 9, 2024, 9:04 a.m. UTC
This patch set represent an attempt to improve and extend the RTE bitops API, in particular for functions that operate on individual bits. All new functionality is exposed to the user as generic selection macros, delegating the actual work to private (__-marked) static inline functions. Public functions (e.g., rte_bit_set32()) would just be bloating the API. Such generic selection macros will here be referred to as "functions", although technically they are not. The legacy <rte_bitops.h> rte_bit_relaxed_*() functions is replaced with two new families: rte_bit_[test|set|clear|assign|flip]() which provides no memory ordering or atomicity guarantees, but does provide the best performance. The performance degradation resulting from the use of volatile (e.g., forcing loads and stores to actually occur and in the number specified) and atomic (e.g., LOCK-prefixed instructions on x86) may be significant. rte_bit_[test|set|clear|assign|flip]() may be used with volatile word pointers, in which case they guarantee that the program-level accesses actually occur. rte_bit_atomic_*() which provides atomic bit-level operations, including the possibility to specifying memory ordering constraints (or the lack thereof). The atomic functions take non-_Atomic pointers, to be flexible, just like the GCC builtins and default <rte_stdatomic.h>. The issue with _Atomic APIs is that it may well be the case that the user wants to perform both non-atomic and atomic operations on the same word. Having _Atomic-marked addresses would complicate supporting atomic bit-level operations in the bitset API (proposed in a different RFC patchset), and potentially other APIs depending on RTE bitops for atomic bit-level ops). Either one needs two bitset variants, one _Atomic bitset and one non-atomic one, or the bitset code needs to cast the non-_Atomic pointer to an _Atomic one. Having a separate _Atomic bitset would be bloat and also prevent the user from both, in some situations, doing atomic operations against a bit set, while in other situations (e.g., at times when MT safety is not a concern) operating on the same objects in a non-atomic manner. Unlike rte_bit_relaxed_*(), individual bits are represented by bool, not uint32_t or uint64_t. The author found the use of such large types confusing, and also failed to see any performance benefits. A set of functions rte_bit_*_assign() are added, to assign a particular boolean value to a particular bit. All new functions have properly documented semantics. All new functions operate on both 32 and 64-bit words, with type checking. _Generic allow the user code to be a little more impact. Have a type-generic atomic test/set/clear/assign bit API also seems consistent with the "core" (word-size) atomics API, which is generic (both GCC builtins and <rte_stdatomic.h> are). The _Generic versions avoids having explicit unsigned long versions of all functions. If you have an unsigned long, it's safe to use the generic version (e.g., rte_set_bit()) and _Generic will pick the right function, provided long is either 32 or 64 bit on your platform (which it is on all DPDK-supported ABIs). The generic rte_bit_set() is a macro, and not a function, but nevertheless has been given a lower-case name. That's how C11 does it (for atomics, and other _Generic), and <rte_stdatomic.h>. Its address can't be taken, but it does not evaluate its parameters more than once. C++ doesn't support generic selection. In C++ translation units the _Generic macros are replaced with overloaded functions, implemented by means of a huge, complicated C macro mess. Mattias Rönnblom (5): eal: extend bit manipulation functionality eal: add unit tests for bit operations eal: add atomic bit operations eal: add unit tests for atomic bit access functions eal: extend bitops to handle volatile pointers app/test/test_bitops.c | 414 ++++++++++++++++++- lib/eal/include/rte_bitops.h | 778 ++++++++++++++++++++++++++++++++++- 2 files changed, 1174 insertions(+), 18 deletions(-)