Message ID | 1709574764-9041-1-git-send-email-roretzla@linux.microsoft.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 52B3C43B9B; Mon, 4 Mar 2024 18:52:53 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0FB8E410EA; Mon, 4 Mar 2024 18:52:53 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id B47474027D for <dev@dpdk.org>; Mon, 4 Mar 2024 18:52:50 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 03CA520B74C0; Mon, 4 Mar 2024 09:52:49 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 03CA520B74C0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1709574770; bh=EK+x0EGE7Sl/o3gcXXKNJqexuLOCO5A408S47KC3ajc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UjjrEokZc8gLx7fm5nPnO9zxwEDWPqvBBpMPcnLao795hyt3JbsTJM0H2lwBCT9qk njX5TQ+PSSVExP+9WAmcFxMPxFX6Y8YvMQ7M++V0yAU7sGkxHUubWXWbtWKsraQLqX nmqpCJx6oZ3PKs0sUc/CFfVXBSWl00amefzaROmg= From: Tyler Retzlaff <roretzla@linux.microsoft.com> To: dev@dpdk.org Cc: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>, Bruce Richardson <bruce.richardson@intel.com>, Chengwen Feng <fengchengwen@huawei.com>, Cristian Dumitrescu <cristian.dumitrescu@intel.com>, David Christensen <drc@linux.vnet.ibm.com>, David Hunt <david.hunt@intel.com>, Ferruh Yigit <ferruh.yigit@amd.com>, Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>, Jasvinder Singh <jasvinder.singh@intel.com>, Jerin Jacob <jerinj@marvell.com>, Kevin Laatz <kevin.laatz@intel.com>, Konstantin Ananyev <konstantin.v.ananyev@yandex.ru>, Min Zhou <zhoumin@loongson.cn>, Ruifeng Wang <ruifeng.wang@arm.com>, Sameh Gobriel <sameh.gobriel@intel.com>, Stanislaw Kardach <kda@semihalf.com>, Thomas Monjalon <thomas@monjalon.net>, Vladimir Medvedkin <vladimir.medvedkin@intel.com>, Yipeng Wang <yipeng1.wang@intel.com>, Tyler Retzlaff <roretzla@linux.microsoft.com> Subject: [PATCH v7 00/39] use C11 alignas Date: Mon, 4 Mar 2024 09:52:05 -0800 Message-Id: <1709574764-9041-1-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 |
use C11 alignas
|
|
Message
Tyler Retzlaff
March 4, 2024, 5:52 p.m. UTC
The current location used for __rte_aligned(a) for alignment of types and variables is not compatible with MSVC. There is only a single location accepted by both toolchains. For variables standard C11 offers alignas(a) supported by conformant compilers i.e. both MSVC and GCC. For types the standard offers no alignment facility that compatibly interoperates with C and C++ but may be achieved by relocating the placement of __rte_aligned(a) to the aforementioned location accepted by all currently supported toolchains. ** NOTE ** Finally, In the interest of not creating more API (internal or not) the series does not introduce a wrapper for C11 alignas. If we don't introduce a macro an application can't take a dependency. v7: * no changes, rebase for merge conflict introduced by fix Doxygen processing of vector struct in commit f5746d3fa2f9f08179878c22a0ec1f598a7f15a1 * add some Acked-by: to existing patches. v6: * update static_assert to use XMM_SIZE instead of literal integer 16 * update 2 explicit alignments of ring struct fields to use * alignas(sizeof(uint64_t)) instead of alignas(8) v5: * rebase series. * reword all commit messages with why the change is necessary. * document guidance for the usage of __rte_aligned macro indicating that it should be used for type alignment only and advising that for variable alignment standard C11 alignas(a) should be preferred. v4: * restore explicit alignment of 8-byte integers in mbuf and ring patches, natural alignment may be 4-bytes on 32-bit targets. v3: * add missing patches for __rte_cache_aligned and __rte_cache_min_aligned v2: * add missing #include <stdalign.h> for alignas macro. Tyler Retzlaff (39): eal: use C11 alignas eal: redefine macro to be integer literal for MSVC stack: use C11 alignas sched: use C11 alignas ring: use C11 alignas pipeline: use C11 alignas net: use C11 alignas mbuf: use C11 alignas hash: use C11 alignas eventdev: use C11 alignas ethdev: use C11 alignas dmadev: use C11 alignas distributor: use C11 alignas acl: use C11 alignas vhost: use C11 alignas timer: use C11 alignas table: use C11 alignas reorder: use C11 alignas regexdev: use C11 alignas rcu: use C11 alignas power: use C11 alignas rawdev: use C11 alignas port: use C11 alignas pdcp: use C11 alignas node: use C11 alignas mldev: use C11 alignas mempool: use C11 alignas member: use C11 alignas lpm: use C11 alignas ipsec: use C11 alignas jobstats: use C11 alignas bpf: use C11 alignas compressdev: use C11 alignas cryptodev: use C11 alignas dispatcher: use C11 alignas fib: use C11 alignas gpudev: use C11 alignas graph: use C11 alignas ip_frag: use C11 alignas lib/acl/acl_run.h | 4 ++-- lib/acl/acl_run_altivec.h | 6 ++++-- lib/acl/acl_run_neon.h | 6 ++++-- lib/bpf/bpf_pkt.c | 4 ++-- lib/compressdev/rte_comp.h | 4 ++-- lib/compressdev/rte_compressdev_internal.h | 8 +++---- lib/cryptodev/cryptodev_pmd.h | 8 +++---- lib/cryptodev/rte_cryptodev_core.h | 4 ++-- lib/dispatcher/rte_dispatcher.c | 4 ++-- lib/distributor/distributor_private.h | 34 ++++++++++++++++-------------- lib/distributor/rte_distributor.c | 5 +++-- lib/dmadev/rte_dmadev_core.h | 4 ++-- lib/dmadev/rte_dmadev_pmd.h | 8 +++---- lib/eal/arm/include/rte_vect.h | 4 ++-- lib/eal/common/malloc_elem.h | 4 ++-- lib/eal/common/malloc_heap.h | 4 ++-- lib/eal/common/rte_keepalive.c | 3 ++- lib/eal/common/rte_random.c | 4 ++-- lib/eal/common/rte_service.c | 8 +++---- lib/eal/include/generic/rte_atomic.h | 4 ++-- lib/eal/include/rte_common.h | 23 +++++++++++++------- lib/eal/loongarch/include/rte_vect.h | 8 +++---- lib/eal/ppc/include/rte_vect.h | 4 ++-- lib/eal/riscv/include/rte_vect.h | 4 ++-- lib/eal/x86/include/rte_vect.h | 9 +++++--- lib/eal/x86/rte_power_intrinsics.c | 10 +++++---- lib/ethdev/ethdev_driver.h | 8 +++---- lib/ethdev/rte_ethdev.h | 16 +++++++------- lib/ethdev/rte_ethdev_core.h | 4 ++-- lib/ethdev/rte_flow_driver.h | 4 ++-- lib/eventdev/event_timer_adapter_pmd.h | 4 ++-- lib/eventdev/eventdev_pmd.h | 8 +++---- lib/eventdev/rte_event_crypto_adapter.c | 16 +++++++------- lib/eventdev/rte_event_dma_adapter.c | 16 +++++++------- lib/eventdev/rte_event_eth_rx_adapter.c | 8 +++---- lib/eventdev/rte_event_eth_tx_adapter.c | 4 ++-- lib/eventdev/rte_event_timer_adapter.c | 9 ++++---- lib/eventdev/rte_event_timer_adapter.h | 8 +++---- lib/eventdev/rte_eventdev.h | 10 +++------ lib/eventdev/rte_eventdev_core.h | 4 ++-- lib/fib/dir24_8.h | 4 +++- lib/fib/trie.h | 4 +++- lib/gpudev/gpudev_driver.h | 4 ++-- lib/graph/graph_private.h | 4 ++-- lib/graph/graph_stats.c | 4 ++-- lib/graph/rte_graph.h | 4 ++-- lib/graph/rte_graph_worker_common.h | 17 +++++++++------ lib/hash/rte_cuckoo_hash.h | 16 ++++++++------ lib/hash/rte_thash.c | 4 +++- lib/hash/rte_thash.h | 8 +++---- lib/ip_frag/ip_reassembly.h | 8 +++---- lib/ipsec/rte_ipsec.h | 4 ++-- lib/ipsec/sa.h | 4 ++-- lib/jobstats/rte_jobstats.h | 8 +++---- lib/lpm/rte_lpm.h | 5 +++-- lib/lpm/rte_lpm6.c | 8 +++---- lib/mbuf/rte_mbuf_core.h | 6 +++--- lib/member/rte_member.h | 8 +++---- lib/member/rte_member_ht.h | 4 ++-- lib/member/rte_member_sketch.c | 4 ++-- lib/mempool/rte_mempool.h | 27 ++++++++++++------------ lib/mldev/rte_mldev.h | 4 ++-- lib/mldev/rte_mldev_core.h | 4 ++-- lib/net/net_crc_avx512.c | 14 ++++++------ lib/net/net_crc_neon.c | 11 +++++----- lib/net/net_crc_sse.c | 17 ++++++++------- lib/net/rte_arp.h | 8 +++---- lib/net/rte_ether.h | 8 +++---- lib/node/node_private.h | 4 ++-- lib/node/pkt_cls.c | 4 +++- lib/pdcp/rte_pdcp.h | 4 ++-- lib/pipeline/rte_pipeline.c | 4 ++-- lib/pipeline/rte_port_in_action.c | 3 ++- lib/pipeline/rte_swx_ipsec.c | 4 +++- lib/pipeline/rte_table_action.c | 24 ++++++++++----------- lib/port/rte_port_frag.c | 4 ++-- lib/power/power_acpi_cpufreq.c | 4 ++-- lib/power/power_amd_pstate_cpufreq.c | 4 ++-- lib/power/power_cppc_cpufreq.c | 4 ++-- lib/power/power_intel_uncore.c | 4 ++-- lib/power/power_pstate_cpufreq.c | 4 ++-- lib/power/rte_power_pmd_mgmt.c | 4 ++-- lib/rawdev/rte_rawdev.h | 4 ++-- lib/rcu/rte_rcu_qsbr.h | 16 ++++++++------ lib/regexdev/rte_regexdev_core.h | 8 +++---- lib/reorder/rte_reorder.c | 8 +++---- lib/ring/rte_ring_core.h | 16 ++++++++------ lib/ring/rte_ring_peek_zc.h | 4 ++-- lib/sched/rte_sched.c | 21 +++++++++--------- lib/sched/rte_sched_common.h | 2 -- lib/stack/rte_stack.h | 16 ++++++++------ lib/table/rte_swx_table_learner.c | 4 ++-- lib/table/rte_table_acl.c | 3 ++- lib/table/rte_table_array.c | 7 +++--- lib/table/rte_table_hash_cuckoo.c | 4 +++- lib/table/rte_table_hash_ext.c | 3 ++- lib/table/rte_table_hash_key16.c | 4 +++- lib/table/rte_table_hash_key32.c | 4 +++- lib/table/rte_table_hash_key8.c | 4 +++- lib/table/rte_table_hash_lru.c | 3 ++- lib/table/rte_table_lpm.c | 3 ++- lib/table/rte_table_lpm_ipv6.c | 3 ++- lib/timer/rte_timer.c | 4 ++-- lib/vhost/vhost.h | 8 +++---- lib/vhost/vhost_crypto.c | 4 ++-- 105 files changed, 407 insertions(+), 349 deletions(-)
Comments
On Mon, Mar 4, 2024 at 6:53 PM Tyler Retzlaff <roretzla@linux.microsoft.com> wrote: > > The current location used for __rte_aligned(a) for alignment of types > and variables is not compatible with MSVC. There is only a single > location accepted by both toolchains. > > For variables standard C11 offers alignas(a) supported by conformant > compilers i.e. both MSVC and GCC. > > For types the standard offers no alignment facility that compatibly > interoperates with C and C++ but may be achieved by relocating the > placement of __rte_aligned(a) to the aforementioned location accepted > by all currently supported toolchains. > > ** NOTE ** > > Finally, In the interest of not creating more API (internal or not) the > series does not introduce a wrapper for C11 alignas. If we don't introduce > a macro an application can't take a dependency. I have been looking into adding some check so that we catch new introductions of __rte_*aligned calls... Wdyt of: diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh index c47ea59501..632397f42d 100755 --- a/devtools/checkpatches.sh +++ b/devtools/checkpatches.sh @@ -336,6 +336,21 @@ check_internal_tags() { # <patch> return $res } +check_aligned_attributes() { # <patch> + res=0 + + for token in __rte_aligned __rte_cache_aligned __rte_cache_min_aligned; do + if [ $(grep -E '^\+.*\<'$token'\>' "$1" | \ + grep -vE '\<(struct|union)[[:space:]]*'$token'\>' | \ + wc -l) != 0 ]; then + echo "Please only use $token for struct or union types alignment." + res=1 + fi + done + + return $res +} + check_release_notes() { # <patch> rel_notes_prefix=doc/guides/rel_notes/release_ IFS=. read year month release < VERSION @@ -445,6 +460,14 @@ check () { # <patch-file> <commit> ret=1 fi + ! $verbose || printf '\nChecking alignment attributes:\n' + report=$(check_aligned_attributes "$tmpinput") + if [ $? -ne 0 ] ; then + $headline_printed || print_headline "$subject" + printf '%s\n' "$report" + ret=1 + fi + ! $verbose || printf '\nChecking release notes updates:\n' report=$(check_release_notes "$tmpinput") if [ $? -ne 0 ] ; then
Hello Tyler, On Mon, Mar 4, 2024 at 6:53 PM Tyler Retzlaff <roretzla@linux.microsoft.com> wrote: > > The current location used for __rte_aligned(a) for alignment of types > and variables is not compatible with MSVC. There is only a single > location accepted by both toolchains. > > For variables standard C11 offers alignas(a) supported by conformant > compilers i.e. both MSVC and GCC. > > For types the standard offers no alignment facility that compatibly > interoperates with C and C++ but may be achieved by relocating the > placement of __rte_aligned(a) to the aforementioned location accepted > by all currently supported toolchains. > > ** NOTE ** > > Finally, In the interest of not creating more API (internal or not) the > series does not introduce a wrapper for C11 alignas. If we don't introduce > a macro an application can't take a dependency. I reorganised the commits since those were global/mechanical changes in lib/. As part of the alignas() conversion, I updated the references to __rte_*aligned in the documentation so that there is no "bad example" in doc/. I converted the cacheline1 field to alignas in the mbuf library, but also in eventdev and security libraries. With this, there is no remaining construct like struct|union { ... } __rte_*aligned in lib/. I added a check in checkpatches.sh so that we don't reintroduce wrongly placed __rte_*aligned tags. I made this check global (iow not restricted to lib/) so that developers touching drivers/ and other parts of DPDK are made aware of this change of use of __rte_*aligned tags. Series applied.
On Wed, Mar 06, 2024 at 10:55:36AM +0100, David Marchand wrote: > Hello Tyler, > > On Mon, Mar 4, 2024 at 6:53 PM Tyler Retzlaff > <roretzla@linux.microsoft.com> wrote: > > > > The current location used for __rte_aligned(a) for alignment of types > > and variables is not compatible with MSVC. There is only a single > > location accepted by both toolchains. > > > > For variables standard C11 offers alignas(a) supported by conformant > > compilers i.e. both MSVC and GCC. > > > > For types the standard offers no alignment facility that compatibly > > interoperates with C and C++ but may be achieved by relocating the > > placement of __rte_aligned(a) to the aforementioned location accepted > > by all currently supported toolchains. > > > > ** NOTE ** > > > > Finally, In the interest of not creating more API (internal or not) the > > series does not introduce a wrapper for C11 alignas. If we don't introduce > > a macro an application can't take a dependency. > > I reorganised the commits since those were global/mechanical changes in lib/. > > As part of the alignas() conversion, I updated the references to > __rte_*aligned in the documentation so that there is no "bad example" > in doc/. > > I converted the cacheline1 field to alignas in the mbuf library, but > also in eventdev and security libraries. > With this, there is no remaining construct like struct|union { ... } > __rte_*aligned in lib/. > > I added a check in checkpatches.sh so that we don't reintroduce > wrongly placed __rte_*aligned tags. > I made this check global (iow not restricted to lib/) so that > developers touching drivers/ and other parts of DPDK are made aware of > this change of use of __rte_*aligned tags. > > Series applied. Great to have this done, thank you David! > > -- > David Marchand