* [dpdk-dev] [PATCH] net/mlx5: fix build with strict alignment enabled
@ 2019-10-15 14:56 Ali Alnubani
2019-10-15 15:06 ` Slava Ovsiienko
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Ali Alnubani @ 2019-10-15 14:56 UTC (permalink / raw)
To: dev; +Cc: Slava Ovsiienko, Jeremy Plsek
This patch converts some of the casts to unaligned integer types.
This fixes the following error, which is seen on x86, with
gcc 7.4.0:
drivers/net/mlx5/mlx5_rxtx.c: In function ‘mlx5_tx_dseg_iptr’:
drivers/net/mlx5/mlx5_rxtx.c:2740:9: error: passing argument 1 of
‘memcpy’ makes pointer from integer without a cast
[-Werror=int-conversion]
memcpy(dst, src, len);
^~~
The memcpy call is replaced with 2 copies of uint32 for better
performance on ARM.
Fixes: 18a1c20044c0 ("net/mlx5: implement Tx burst template")
Reported-by: Jeremy Plsek <jplsek@iol.unh.edu>
Signed-off-by: Ali Alnubani <alialnu@mellanox.com>
---
drivers/net/mlx5/mlx5_rxtx.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c
index 10d0ca116..d6a5106c5 100644
--- a/drivers/net/mlx5/mlx5_rxtx.c
+++ b/drivers/net/mlx5/mlx5_rxtx.c
@@ -2747,27 +2747,33 @@ mlx5_tx_dseg_iptr(struct mlx5_txq_data *restrict txq,
/* Unrolled implementation of generic rte_memcpy. */
dst = (uintptr_t)&dseg->inline_data[0];
src = (uintptr_t)buf;
+ if (len & 0x08) {
#ifdef RTE_ARCH_STRICT_ALIGN
- memcpy(dst, src, len);
+ assert(dst == RTE_PTR_ALIGN(dst, sizeof(uint32_t)));
+ *(uint32_t *)dst = *(unaligned_uint32_t *)src;
+ dst += sizeof(uint32_t);
+ src += sizeof(uint32_t);
+ *(uint32_t *)dst = *(unaligned_uint32_t *)src;
+ dst += sizeof(uint32_t);
+ src += sizeof(uint32_t);
#else
- if (len & 0x08) {
- *(uint64_t *)dst = *(uint64_t *)src;
+ *(uint64_t *)dst = *(unaligned_uint64_t *)src;
dst += sizeof(uint64_t);
src += sizeof(uint64_t);
+#endif
}
if (len & 0x04) {
- *(uint32_t *)dst = *(uint32_t *)src;
+ *(uint32_t *)dst = *(unaligned_uint32_t *)src;
dst += sizeof(uint32_t);
src += sizeof(uint32_t);
}
if (len & 0x02) {
- *(uint16_t *)dst = *(uint16_t *)src;
+ *(uint16_t *)dst = *(unaligned_uint16_t *)src;
dst += sizeof(uint16_t);
src += sizeof(uint16_t);
}
if (len & 0x01)
*(uint8_t *)dst = *(uint8_t *)src;
-#endif
}
/**
--
2.23.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-dev] [PATCH] net/mlx5: fix build with strict alignment enabled
2019-10-15 14:56 [dpdk-dev] [PATCH] net/mlx5: fix build with strict alignment enabled Ali Alnubani
@ 2019-10-15 15:06 ` Slava Ovsiienko
2019-10-17 7:19 ` [dpdk-dev] [PATCH v2] " Ali Alnubani
2019-10-20 7:58 ` [dpdk-dev] [PATCH] " Raslan Darawsheh
2 siblings, 0 replies; 4+ messages in thread
From: Slava Ovsiienko @ 2019-10-15 15:06 UTC (permalink / raw)
To: Ali Alnubani, dev; +Cc: Jeremy Plsek
> -----Original Message-----
> From: Ali Alnubani <alialnu@mellanox.com>
> Sent: Tuesday, October 15, 2019 17:56
> To: dev@dpdk.org
> Cc: Slava Ovsiienko <viacheslavo@mellanox.com>; Jeremy Plsek
> <jplsek@iol.unh.edu>
> Subject: [PATCH] net/mlx5: fix build with strict alignment enabled
>
> This patch converts some of the casts to unaligned integer types.
>
> This fixes the following error, which is seen on x86, with gcc 7.4.0:
>
> drivers/net/mlx5/mlx5_rxtx.c: In function ‘mlx5_tx_dseg_iptr’:
> drivers/net/mlx5/mlx5_rxtx.c:2740:9: error: passing argument 1 of ‘memcpy’
> makes pointer from integer without a cast [-Werror=int-conversion]
> memcpy(dst, src, len);
This orphan line look strange:
> ^~~
Could you, please, remove it?
The full compiler error message looks as non-appropriate either.
What do you think about replace one with description?
> The memcpy call is replaced with 2 copies of uint32 for better performance
> on ARM.
Replaced with completely unrolled copying for the data length up to 15B,
not only 2 copies of uint32.
I'm OK with this patch, after polishing commit message, you may append my
Acked-by to v2. Thanks.
With best regards, Slava
>
> Fixes: 18a1c20044c0 ("net/mlx5: implement Tx burst template")
>
> Reported-by: Jeremy Plsek <jplsek@iol.unh.edu>
> Signed-off-by: Ali Alnubani <alialnu@mellanox.com>
> ---
> drivers/net/mlx5/mlx5_rxtx.c | 18 ++++++++++++------
> 1 file changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c
> index 10d0ca116..d6a5106c5 100644
> --- a/drivers/net/mlx5/mlx5_rxtx.c
> +++ b/drivers/net/mlx5/mlx5_rxtx.c
> @@ -2747,27 +2747,33 @@ mlx5_tx_dseg_iptr(struct mlx5_txq_data
> *restrict txq,
> /* Unrolled implementation of generic rte_memcpy. */
> dst = (uintptr_t)&dseg->inline_data[0];
> src = (uintptr_t)buf;
> + if (len & 0x08) {
> #ifdef RTE_ARCH_STRICT_ALIGN
> - memcpy(dst, src, len);
> + assert(dst == RTE_PTR_ALIGN(dst, sizeof(uint32_t)));
> + *(uint32_t *)dst = *(unaligned_uint32_t *)src;
> + dst += sizeof(uint32_t);
> + src += sizeof(uint32_t);
> + *(uint32_t *)dst = *(unaligned_uint32_t *)src;
> + dst += sizeof(uint32_t);
> + src += sizeof(uint32_t);
> #else
> - if (len & 0x08) {
> - *(uint64_t *)dst = *(uint64_t *)src;
> + *(uint64_t *)dst = *(unaligned_uint64_t *)src;
> dst += sizeof(uint64_t);
> src += sizeof(uint64_t);
> +#endif
> }
> if (len & 0x04) {
> - *(uint32_t *)dst = *(uint32_t *)src;
> + *(uint32_t *)dst = *(unaligned_uint32_t *)src;
> dst += sizeof(uint32_t);
> src += sizeof(uint32_t);
> }
> if (len & 0x02) {
> - *(uint16_t *)dst = *(uint16_t *)src;
> + *(uint16_t *)dst = *(unaligned_uint16_t *)src;
> dst += sizeof(uint16_t);
> src += sizeof(uint16_t);
> }
> if (len & 0x01)
> *(uint8_t *)dst = *(uint8_t *)src;
> -#endif
> }
>
> /**
> --
> 2.23.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [dpdk-dev] [PATCH v2] net/mlx5: fix build with strict alignment enabled
2019-10-15 14:56 [dpdk-dev] [PATCH] net/mlx5: fix build with strict alignment enabled Ali Alnubani
2019-10-15 15:06 ` Slava Ovsiienko
@ 2019-10-17 7:19 ` Ali Alnubani
2019-10-20 7:58 ` [dpdk-dev] [PATCH] " Raslan Darawsheh
2 siblings, 0 replies; 4+ messages in thread
From: Ali Alnubani @ 2019-10-17 7:19 UTC (permalink / raw)
To: dev; +Cc: Jeremy Plsek, Viacheslav Ovsiienko
This patch converts some of the casts to unaligned integer types.
The memcpy call is replaced with explicit copying because it
may require type qualifiers in some environments.
Fixes: 18a1c20044c0 ("net/mlx5: implement Tx burst template")
Reported-by: Jeremy Plsek <jplsek@iol.unh.edu>
Signed-off-by: Ali Alnubani <alialnu@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
---
drivers/net/mlx5/mlx5_rxtx.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c
index 10d0ca116..d6a5106c5 100644
--- a/drivers/net/mlx5/mlx5_rxtx.c
+++ b/drivers/net/mlx5/mlx5_rxtx.c
@@ -2747,27 +2747,33 @@ mlx5_tx_dseg_iptr(struct mlx5_txq_data *restrict txq,
/* Unrolled implementation of generic rte_memcpy. */
dst = (uintptr_t)&dseg->inline_data[0];
src = (uintptr_t)buf;
+ if (len & 0x08) {
#ifdef RTE_ARCH_STRICT_ALIGN
- memcpy(dst, src, len);
+ assert(dst == RTE_PTR_ALIGN(dst, sizeof(uint32_t)));
+ *(uint32_t *)dst = *(unaligned_uint32_t *)src;
+ dst += sizeof(uint32_t);
+ src += sizeof(uint32_t);
+ *(uint32_t *)dst = *(unaligned_uint32_t *)src;
+ dst += sizeof(uint32_t);
+ src += sizeof(uint32_t);
#else
- if (len & 0x08) {
- *(uint64_t *)dst = *(uint64_t *)src;
+ *(uint64_t *)dst = *(unaligned_uint64_t *)src;
dst += sizeof(uint64_t);
src += sizeof(uint64_t);
+#endif
}
if (len & 0x04) {
- *(uint32_t *)dst = *(uint32_t *)src;
+ *(uint32_t *)dst = *(unaligned_uint32_t *)src;
dst += sizeof(uint32_t);
src += sizeof(uint32_t);
}
if (len & 0x02) {
- *(uint16_t *)dst = *(uint16_t *)src;
+ *(uint16_t *)dst = *(unaligned_uint16_t *)src;
dst += sizeof(uint16_t);
src += sizeof(uint16_t);
}
if (len & 0x01)
*(uint8_t *)dst = *(uint8_t *)src;
-#endif
}
/**
--
2.23.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-dev] [PATCH] net/mlx5: fix build with strict alignment enabled
2019-10-15 14:56 [dpdk-dev] [PATCH] net/mlx5: fix build with strict alignment enabled Ali Alnubani
2019-10-15 15:06 ` Slava Ovsiienko
2019-10-17 7:19 ` [dpdk-dev] [PATCH v2] " Ali Alnubani
@ 2019-10-20 7:58 ` Raslan Darawsheh
2 siblings, 0 replies; 4+ messages in thread
From: Raslan Darawsheh @ 2019-10-20 7:58 UTC (permalink / raw)
To: Ali Alnubani, dev; +Cc: Slava Ovsiienko, Jeremy Plsek
Hi,
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Ali Alnubani
> Sent: Tuesday, October 15, 2019 5:56 PM
> To: dev@dpdk.org
> Cc: Slava Ovsiienko <viacheslavo@mellanox.com>; Jeremy Plsek
> <jplsek@iol.unh.edu>
> Subject: [dpdk-dev] [PATCH] net/mlx5: fix build with strict alignment enabled
>
> This patch converts some of the casts to unaligned integer types.
>
> This fixes the following error, which is seen on x86, with
> gcc 7.4.0:
>
> drivers/net/mlx5/mlx5_rxtx.c: In function ‘mlx5_tx_dseg_iptr’:
> drivers/net/mlx5/mlx5_rxtx.c:2740:9: error: passing argument 1 of
> ‘memcpy’ makes pointer from integer without a cast
> [-Werror=int-conversion]
> memcpy(dst, src, len);
> ^~~
>
> The memcpy call is replaced with 2 copies of uint32 for better
> performance on ARM.
>
> Fixes: 18a1c20044c0 ("net/mlx5: implement Tx burst template")
>
> Reported-by: Jeremy Plsek <jplsek@iol.unh.edu>
> Signed-off-by: Ali Alnubani <alialnu@mellanox.com>
Patch applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-10-20 7:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-15 14:56 [dpdk-dev] [PATCH] net/mlx5: fix build with strict alignment enabled Ali Alnubani
2019-10-15 15:06 ` Slava Ovsiienko
2019-10-17 7:19 ` [dpdk-dev] [PATCH v2] " Ali Alnubani
2019-10-20 7:58 ` [dpdk-dev] [PATCH] " Raslan Darawsheh
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).