|SUCCESS| mbuf: fix mbuf operations history recording

dpdklab at iol.unh.edu dpdklab at iol.unh.edu
Mon Apr 20 01:39:19 CEST 2026


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

_AI Code Review_

=== Patch Review: series.patch (via Claude) ===
Review date: 2026-04-19

Commit: 20260419221220.86455-1-mb at smartsharesystems.com
Author: Morten Brorup <mb at smartsharesystems.com>
Subject: [PATCH] mbuf: fix mbuf operations history recording

This patch addresses two bugs related to mbuf operations history recording:
1. A potential segmentation fault when allocating mbufs from a mempool fails
2. Duplicate recording of allocation operations in rte_pktmbuf_alloc_bulk()

> diff --git a/lib/mbuf/rte_mbuf.h b/lib/mbuf/rte_mbuf.h
> index e7c3bbadd4..60ec8158cd 100644
> --- a/lib/mbuf/rte_mbuf.h
> +++ b/lib/mbuf/rte_mbuf.h
> @@ -663,14 +663,14 @@ static __rte_always_inline int
>  rte_mbuf_raw_alloc_bulk(struct rte_mempool *mp, struct rte_mbuf **mbufs, unsigned int count)
>  {
>  	int rc = rte_mempool_get_bulk(mp, (void **)mbufs, count);
> -	if (likely(rc == 0)) {
> -		for (unsigned int idx = 0; idx < count; idx++)
> -			__rte_mbuf_raw_sanity_check_mp(mbufs[idx], mp);
> -	}
> +	if (unlikely(rc))
> +		return rc;

Does this change introduce incorrect behavior for branch prediction 
optimization? The commit message states this fixes a segmentation fault 
when allocation fails, but the original code already had an if statement 
checking rc == 0 before dereferencing mbufs. How does changing from 
if (likely(rc == 0)) to if (unlikely(rc)) fix the segmentation fault 
described in the commit message?

> +	for (unsigned int idx = 0; idx < count; idx++)
> +		__rte_mbuf_raw_sanity_check_mp(mbufs[idx], mp);
>  
>  	rte_mbuf_history_mark_bulk(mbufs, count, RTE_MBUF_HISTORY_OP_LIB_ALLOC);
>  
> -	return rc;
> +	return 0;
>  }

[ ... ]


More information about the test-report mailing list