From: "Morten Brørup" <mb@smartsharesystems.com>
To: "Tyler Retzlaff" <roretzla@linux.microsoft.com>, <dev@dpdk.org>,
"Stanislaw Kardach" <kda@semihalf.com>
Cc: "Mattias Rönnblom" <mattias.ronnblom@ericsson.com>,
"Anatoly Burakov" <anatoly.burakov@intel.com>,
"Bruce Richardson" <bruce.richardson@intel.com>,
"David Christensen" <drc@linux.vnet.ibm.com>,
"Harry van Haaren" <harry.van.haaren@intel.com>,
"Konstantin Ananyev" <konstantin.v.ananyev@yandex.ru>,
"Min Zhou" <zhoumin@loongson.cn>,
"Ruifeng Wang" <ruifeng.wang@arm.com>
Subject: RE: [PATCH] eal: use C11 alignas instead of GCC attribute aligned
Date: Wed, 15 Nov 2023 21:08:05 +0100 [thread overview]
Message-ID: <98CBD80474FA8B44BF855DF32C47DC35E9F02F@smartserver.smartshare.dk> (raw)
In-Reply-To: <1700069997-4399-2-git-send-email-roretzla@linux.microsoft.com>
> From: Tyler Retzlaff [mailto:roretzla@linux.microsoft.com]
> Sent: Wednesday, 15 November 2023 18.40
>
> Now that we have enabled C11 replace the use of __rte_cache_aligned
> and __rte_aligned(n) with alignas(RTE_CACHE_LINE_SIZE) and
> __rte_aligned(n) respectively.
>
[...]
> typedef union rte_xmm {
> + alignas(16)
> xmm_t x;
> uint8_t u8[XMM_SIZE / sizeof(uint8_t)];
> uint16_t u16[XMM_SIZE / sizeof(uint16_t)];
> uint32_t u32[XMM_SIZE / sizeof(uint32_t)];
> uint64_t u64[XMM_SIZE / sizeof(uint64_t)];
> double pd[XMM_SIZE / sizeof(double)];
> -} __rte_aligned(16) rte_xmm_t;
> +} rte_xmm_t;
Your patch message should mention that C11 doesn't allow alignas() being applied to the declarations of struct/union types, so it is applied to the first field in the struct/union, which has the same effect.
Someone unfamiliar with alignas() would expect:
-typedef union rte_xmm {
+typedef alignas(16) union rte_xmm {
[...]
-} __rte_aligned(16) rte_xmm_t;
+} rte_xmm_t;
[...]
> #ifndef RTE_VECT_RISCV_H
> #define RTE_VECT_RISCV_H
>
> +#include <stdalign.h>
> #include <stdint.h>
> #include "generic/rte_vect.h"
> #include "rte_common.h"
> @@ -23,13 +24,14 @@
> #define XMM_MASK (XMM_SIZE - 1)
>
> typedef union rte_xmm {
> + alignas(16) /* !! NOTE !! changed to 16 it looks like this was a
> bug? */
> xmm_t x;
> uint8_t u8[XMM_SIZE / sizeof(uint8_t)];
> uint16_t u16[XMM_SIZE / sizeof(uint16_t)];
> uint32_t u32[XMM_SIZE / sizeof(uint32_t)];
> uint64_t u64[XMM_SIZE / sizeof(uint64_t)];
> double pd[XMM_SIZE / sizeof(double)];
> -} __rte_aligned(8) rte_xmm_t;
> +} rte_xmm_t;
Yes, this looks very much like a bug.
Even if a RISC-V CPU could handle alignment like that, it might interact with other software/hardware expecting type-sized alignment, i.e. 16-byte alignment, so partially using 8-byte alignment would cause bugs.
It should be a separate patch with a Fixes tag.
We need to urgently decide if this bug should live on in DPDK 23.11, or if the fix should be included although we are very late in the release process.
Stanislaw, what do you think?
Furthermore, I wonder if it can be backported to stable, and to what extent backporting it would break the ABI/API.
next prev parent reply other threads:[~2023-11-15 20:08 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-15 17:39 [PATCH] RFC: " Tyler Retzlaff
2023-11-15 17:39 ` [PATCH] eal: " Tyler Retzlaff
2023-11-15 18:13 ` Bruce Richardson
2023-11-15 18:27 ` Tyler Retzlaff
2023-11-15 20:08 ` Morten Brørup [this message]
2023-11-15 21:03 ` Tyler Retzlaff
2023-11-15 22:43 ` Stanisław Kardach
2023-11-16 10:12 ` Mattias Rönnblom
2024-01-25 18:37 ` [PATCH] RFC: " Tyler Retzlaff
2024-01-25 22:53 ` Morten Brørup
2024-01-25 23:31 ` Tyler Retzlaff
2024-01-26 10:05 ` Mattias Rönnblom
2024-01-26 10:18 ` Morten Brørup
2024-01-27 19:15 ` Mattias Rönnblom
2024-01-28 8:57 ` Morten Brørup
2024-01-28 10:00 ` Mattias Rönnblom
2024-01-29 19:43 ` Tyler Retzlaff
2024-01-30 8:08 ` Mattias Rönnblom
2024-01-30 17:39 ` Tyler Retzlaff
2024-01-30 17:59 ` Bruce Richardson
2024-01-30 18:01 ` Bruce Richardson
2024-01-30 18:04 ` Tyler Retzlaff
2024-01-30 18:18 ` Mattias Rönnblom
2024-01-31 16:04 ` Mattias Rönnblom
2024-01-30 8:09 ` Morten Brørup
2024-01-30 9:28 ` Mattias Rönnblom
2024-01-30 10:17 ` Morten Brørup
2024-01-30 13:00 ` Morten Brørup
2024-01-30 17:54 ` Tyler Retzlaff
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=98CBD80474FA8B44BF855DF32C47DC35E9F02F@smartserver.smartshare.dk \
--to=mb@smartsharesystems.com \
--cc=anatoly.burakov@intel.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=drc@linux.vnet.ibm.com \
--cc=harry.van.haaren@intel.com \
--cc=kda@semihalf.com \
--cc=konstantin.v.ananyev@yandex.ru \
--cc=mattias.ronnblom@ericsson.com \
--cc=roretzla@linux.microsoft.com \
--cc=ruifeng.wang@arm.com \
--cc=zhoumin@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).