|SUCCESS| [v2] eal: fix data race in hugepage prefault

dpdklab at iol.unh.edu dpdklab at iol.unh.edu
Mon Jun 1 21:30:35 CEST 2026


Test-Label: ai-code-review
Test-Status: SUCCESS
https://dpdk.org/patch/164743

_AI Code Review_

=== Patch Review: series.patch (via Claude) ===
Review date: 2026-06-01

Commit: <git sha needed>
Author: Stephen Hemminger <stephen at networkplumber.org>
Subject: [PATCH v2] eal: fix data race in hugepage prefault

This patch addresses a data race in the hugepage allocation code where
a non-atomic load+store sequence is replaced with an atomic fetch-or
operation. The race occurs when secondary processes attach during
rte_eal_init().

> diff --git a/.mailmap b/.mailmap
> index 43febb9030..3c45e365d3 100644
> --- a/.mailmap
> +++ b/.mailmap

[ ... ]

> diff --git a/lib/eal/linux/eal_memalloc.c b/lib/eal/linux/eal_memalloc.c
> index a39bc31c7b..7359a41d3f 100644
> --- a/lib/eal/linux/eal_memalloc.c
> +++ b/lib/eal/linux/eal_memalloc.c
> @@ -25,6 +25,7 @@
>  #include <linux/falloc.h>
>  #include <linux/mman.h> /* for hugetlb-related mmap flags */
>  
> +#include <rte_atomic.h>
>  #include <rte_common.h>
>  #include <rte_log.h>
>  #include <rte_eal.h>

Does this code conform to the include ordering requirements? According to
the coding style guide, system headers should be grouped separately from
DPDK headers, with a blank line between groups. The rte_atomic.h include
appears to be inserted between system headers (linux/mman.h) and other
DPDK headers (rte_common.h), but there is no blank line separating system
headers from DPDK headers above it.

> @@ -597,10 +598,11 @@ alloc_seg(struct rte_memseg *ms, void *addr, int socket_id,
>  
>  	/* we need to trigger a write to the page to enforce page fault and
>  	 * ensure that page is accessible to us, but we can't overwrite value
> -	 * that is already there, so read the old value, and write itback.
> -	 * kernel populates the page with zeroes initially.
> +	 * that is already there.
> +	 * Use an atomic OR with zero to touch the page without changing its contents.
>  	 */
> -	*(volatile int *)addr = *(volatile int *)addr;
> +	(void)rte_atomic_fetch_or_explicit((__rte_atomic uint64_t *)addr, 0,
> +					   rte_memory_order_relaxed);

Does this code make assumptions about hugepage size and alignment? The
original code uses a volatile int (32-bit), but the new code casts addr
to uint64_t. Can this cause unaligned access issues if addr is not
8-byte aligned?

Does the relaxed memory ordering provide sufficient guarantees for the
intended use case? The comment indicates the goal is to trigger a page
fault and ensure page accessibility. Does relaxed ordering ensure the
kernel will commit the backing page before any subsequent operations?

Does the atomic operation correctly handle the write fault requirement?
The original code explicitly wrote back the read value, triggering a
write fault. Does an atomic read-modify-write with OR-zero guarantee
the same kernel behavior for page commitment on all supported platforms?

>  
>  	iova = rte_mem_virt2iova(addr);
>  	if (iova == RTE_BAD_PHYS_ADDR) {


More information about the test-report mailing list