[PATCH] linux/mem: atomically prefault hugepages in alloc_seg

Stephen Hemminger stephen at networkplumber.org
Wed May 20 19:07:38 CEST 2026


On Wed, 20 May 2026 14:57:56 +0200
Michal Sieron <michal.sieron at nokia.com> wrote:

> In rare cases, when a secondary process calls rte_eal_init() it can
> cause a data race during page prefaulting in alloc_seg().
> 
> An atomic compare-exchange in a loop should eliminate the data race.
> 
> Signed-off-by: Michal Sieron <michal.sieron at nokia.com>
> ---

AI had good suggestion when reviewing this.
Your version is still racy (on the read side).

A simple non-racy, and no loop version would be:

	rte_atomic_fetch_or_explicit((int *)addr, 0, rte_memory_order_relaxed);


More information about the dev mailing list