> From: Stephen Hemminger [mailto:[email protected]]
> Sent: Friday, 4 September 2026 01.05
> 
> From: Scott Mitchell <[email protected]>
> 
> RTE_PTR_ADD and RTE_PTR_SUB APIs have a few limitations:
> 1. ptr cast to uintptr_t drops pointer provenance and
> prevents compiler optimizations
> 2. return cast discards qualifiers (const, volatile)
> which may hide correctness/concurrency issues.
> 3. Accepts both "pointers" and "integers as pointers" which
> overloads the use case and constrains the implementation
> to address other challenges.
> 
> This patch deprecates support for integer types which allows
> addressing each of the challenges above.
> 
> Examples:
> 1. Clang is able to optimize and improve __rte_raw_cksum
> (which uses RTE_PTR_ADD) by ~40% (100 bytes) to ~8x (1.5k bytes)
> TSC cycles/byte.
> 2. Refactoring discovered cases that dropped qualifiers (volatile)
> that the new API exposes.
> 
> Signed-off-by: Scott Mitchell <[email protected]>
> Reviewed-by: Stephen Hemminger <[email protected]>
> ---
> Changes from the original v24 submission (rebased to 26.11):
> 
> * Rebased on main: release notes moved to release_26_11.rst,
> and roc_cpt_debug.c updated for the cpt_cn10k_frag_info_s rename.
> 
> * Release notes: state that RTE_PTR_ADD/SUB reject integer arguments
> while RTE_PTR_ALIGN* still compile with them as deprecated usage.
> There are still some in-tree uses of integer arguments in mlx5.
> 
> * test_common.c: aligned uint16/32/64 dereference tests now also
> require increment to be a multiple of the type size, avoiding
> misaligned typed access.
> 
> * ena: BAR NULL check logs at DEBUG rather than ERR since the memory
> BAR is legitimately absent on non-LLQ devices.
> 
> * idxd: drop RTE_PTR_UNQUAL and FIXME on portal assignment, and the
> redundant (volatile void *) casts, since the fields are already
> volatile-qualified upstream.
> 
> * eal_common_memory.c: drop unrelated volatile qualifier on local elem
> pointer.
> * eal_common_fbarray.c: drop unused rte_debug.h include.
> * eal_memalloc.c (linux, windows): move base_va NULL check before
>   the allocation loop and return -1 instead of goto out.
> 
> * rte_mbuf.h, rte_mempool.h: drop __rte_assume() on pointers that
> are dereferenced immediately after; compiler already infers that
> form the immediate dereference.  keep RTE_ASSERT.
> 

That's a lot of code.
Thank you for working on this, Scott and Stephen.
Stronger typing is a valuable improvement.

I have reviewed selectively, so it's not a full review, but a big ack.

Acked-by: Morten Brørup <[email protected]>

Reply via email to