All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Morten Brørup" <mb@smartsharesystems.com>
To: "Stephen Hemminger" <stephen@networkplumber.org>, <dev@dpdk.org>,
	"Wathsala Vithanage" <wathsala.vithanage@arm.com>,
	"Sun Yuechi" <sunyuechi@iscas.ac.cn>,
	"Bibo Mao" <maobibo@loongson.cn>
Cc: "Dariusz Sosnowski" <dsosnowski@nvidia.com>,
	"Viacheslav Ovsiienko" <viacheslavo@nvidia.com>,
	"Bing Zhao" <bingz@nvidia.com>, "Ori Kam" <orika@nvidia.com>,
	"Suanming Mou" <suanmingm@nvidia.com>,
	"Matan Azrad" <matan@nvidia.com>
Subject: RE: [RFC 2/3] net/mlx5: drop unnecessary STRICT_ALIGN
Date: Sat, 5 Sep 2026 12:00:30 +0200	[thread overview]
Message-ID: <98CBD80474FA8B44BF855DF32C47DC35F65A35@smartserver.smartshare.dk> (raw)
In-Reply-To: <20260904220953.3105930-3-stephen@networkplumber.org>

+ARM, RISC-V, LoongArch maintainers

> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Saturday, 5 September 2026 00.09
> 
> The transmit inline copy splits the 8 byte case into two 32 bit
> moves when RTE_ARCH_STRICT_ALIGN is set. Only armv8 aarch32 ever
> set that flag, and ARMv8 does unaligned access in hardware, so the
> split gains nothing. Use a single 64 bit move.
> 
> The destination is inline_data, at offset 4 of a 16 byte aligned
> dseg, so the 8 byte store is always misaligned. Write it through
> the unaligned type; a plain uint64_t store there is undefined
> behaviour and is reported by UBSAN.
> 
> The debug assertion on the inline data offset goes away with the
> strict alignment path since the wider move has no such requirement.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  drivers/net/mlx5/mlx5_tx.h | 12 +-----------
>  1 file changed, 1 insertion(+), 11 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_tx.h b/drivers/net/mlx5/mlx5_tx.h
> index 682dc07718..69a18f8a49 100644
> --- a/drivers/net/mlx5/mlx5_tx.h
> +++ b/drivers/net/mlx5/mlx5_tx.h
> @@ -1437,19 +1437,9 @@ mlx5_tx_dseg_iptr(struct mlx5_txq_data
> *__rte_restrict txq,
>  	dst = (uintptr_t)&dseg->inline_data[0];
>  	src = (uintptr_t)buf;
>  	if (len & 0x08) {
> -#ifdef RTE_ARCH_STRICT_ALIGN
> -		MLX5_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
> -		*(uint64_t *)dst = *(unaligned_uint64_t *)src;
> +		*(unaligned_uint64_t *)dst = *(unaligned_uint64_t *)src;
>  		dst += sizeof(uint64_t);
>  		src += sizeof(uint64_t);
> -#endif
>  	}
>  	if (len & 0x04) {
>  		*(uint32_t *)dst = *(unaligned_uint32_t *)src;
> --
> 2.53.0

This RFC series is an interesting idea!

I'm in favor of eliminating RTE_ARCH_STRICT_ALIGN and #ifdefs like the one in this patch; it makes the code cleaner.

And if we want to provide means for performance optimized code for architectures where alignment matter, we could introduce an "aligned4_uint64_t" type in addition to the "unaligned_uint64_t" type:

https://godbolt.org/z/Ts4jhcdoW

I'm not aware of the actual performance benefit such a new type would provide.

BTW: The names could be shorter, e.g. "uint64u_t" or "uint64a1_t" instead of "unaligned_uint64_t" for the unaligned type, and "uint64a4_t" for the 4-byte aligned type.

-Morten


  reply	other threads:[~2026-09-05 10:00 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04 22:09 [RFC 0/3] eal: make unaligned types really unaligned Stephen Hemminger
2026-09-04 22:09 ` [RFC 1/3] eal: make unaligned " Stephen Hemminger
2026-09-04 22:09 ` [RFC 2/3] net/mlx5: drop unnecessary STRICT_ALIGN Stephen Hemminger
2026-09-05 10:00   ` Morten Brørup [this message]
2026-09-04 22:09 ` [RFC 3/3] arm: remove no longer used RTE_ARCH_STRICT_ALIGN Stephen Hemminger
2026-09-06 17:09 ` [PATCH v2 0/5] eal: RTE_PTR_ADD qualifiers and real unaligned types Stephen Hemminger
2026-09-06 17:09   ` [PATCH v2 1/5] test: fix jhash 32 bit key type Stephen Hemminger
2026-09-06 17:09   ` [PATCH v2 2/5] eal: RTE_PTR_ADD/SUB API improvements Stephen Hemminger
2026-09-06 17:09   ` [PATCH v2 3/5] eal: make unaligned really unaligned Stephen Hemminger
2026-09-06 17:09   ` [PATCH v2 4/5] net/mlx5: drop unnecessary STRICT_ALIGN Stephen Hemminger
2026-09-06 17:09   ` [PATCH v2 5/5] arm: remove no longer used RTE_ARCH_STRICT_ALIGN Stephen Hemminger
2026-09-06 20:14   ` [PATCH v2 0/5] eal: RTE_PTR_ADD qualifiers and real unaligned types Morten Brørup
2026-09-07 18:31 ` [PATCH v3 0/5] eal: RTE_PTR_ADD and fix " Stephen Hemminger
2026-09-07 18:31   ` [PATCH v3 1/5] test: fix jhash 32 bit key type Stephen Hemminger
2026-09-07 18:31   ` [PATCH v3 2/5] eal: RTE_PTR_ADD/SUB API improvements Stephen Hemminger
2026-09-07 18:31   ` [PATCH v3 3/5] eal: make unaligned really unaligned Stephen Hemminger
2026-09-07 18:31   ` [PATCH v3 4/5] net/mlx5: drop unnecessary STRICT_ALIGN Stephen Hemminger
2026-09-07 18:31   ` [PATCH v3 5/5] arm: remove no longer used RTE_ARCH_STRICT_ALIGN Stephen Hemminger

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=98CBD80474FA8B44BF855DF32C47DC35F65A35@smartserver.smartshare.dk \
    --to=mb@smartsharesystems.com \
    --cc=bingz@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=dsosnowski@nvidia.com \
    --cc=maobibo@loongson.cn \
    --cc=matan@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=stephen@networkplumber.org \
    --cc=suanmingm@nvidia.com \
    --cc=sunyuechi@iscas.ac.cn \
    --cc=viacheslavo@nvidia.com \
    --cc=wathsala.vithanage@arm.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.