|WARNING| eal: introduce division round up macro
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Thu Aug 13 01:28:23 CEST 2026
Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/167631
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-08-12
# DPDK Patch Review
## Patch: "eal: introduce division round up macro"
---
## Summary
This patch consolidates multiple driver-specific `DIV_ROUND_UP` macro definitions into a single `RTE_DIV_ROUND_UP` macro in `rte_common.h` and updates all existing usages across the codebase.
---
## Errors
None found. The patch correctly introduces a common macro and mechanically replaces all occurrences with no correctness issues.
---
## Warnings
**1. Missing release notes update**
The patch introduces a new public API macro (`RTE_DIV_ROUND_UP`) in an installed header (`lib/eal/include/rte_common.h`) but does not update the release notes. This is a significant addition to the common API and should be documented in `doc/guides/rel_notes/release_<version>.rst`.
**Suggested fix:**
Add a release notes entry under "New Features" describing the new macro:
```rst
* **Added RTE_DIV_ROUND_UP macro.**
Added ``RTE_DIV_ROUND_UP(n, d)`` macro to ``rte_common.h`` for integer
division rounding up. This consolidates driver-specific implementations
into a single common macro.
```
---
## Info
**1. Consider adding RTE_EXPERIMENTAL tag (informational)**
The new macro `RTE_DIV_ROUND_UP` is added to the public API without the `__rte_experimental` tag. While macros typically don't use this tag, consider whether this macro should go through an experimental phase given it's a new API addition. However, since it's a simple utility macro with well-defined behavior matching existing patterns, marking it stable immediately is acceptable.
**2. Macro documentation could be more detailed (informational)**
The Doxygen comment is minimal:
```c
/**
* Macro to divide dividend n by divisor d, rounding up if d does not divide n.
*/
#define RTE_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
```
Consider adding:
- Parameter descriptions using `@param`
- Return value description using `@return`
- Example usage
- Note about integer division behavior
Example improvement:
```c
/**
* Divide two integers, rounding up.
*
* Divides @p n by @p d, rounding the result up to the nearest integer
* if @p d does not evenly divide @p n. Both operands must be non-negative
* for correct rounding behavior.
*
* @param n
* Dividend (numerator).
* @param d
* Divisor (denominator). Must be non-zero.
*
* @return
* Quotient of n/d rounded up to the nearest integer.
*
* @b EXAMPLE:
* @code
* // Calculate number of 4KB pages needed for 10000 bytes
* uint32_t pages = RTE_DIV_ROUND_UP(10000, 4096); // returns 3
* @endcode
*/
#define RTE_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
```
However, this level of documentation may be overkill for such a simple utility macro, so this is purely informational.
---
## Positive Observations
1. **Thorough consolidation**: The patch successfully removes 18+ duplicate definitions and updates all call sites consistently.
2. **Correct mechanical transformation**: All replacements maintain the same semantics. The patch correctly handles wrapped lines and preserves code formatting.
3. **No behavior changes**: This is a pure refactoring with no functional changes, reducing maintenance burden.
4. **Consistent naming**: `RTE_DIV_ROUND_UP` follows DPDK macro naming conventions (all caps with `RTE_` prefix).
5. **Clean compilation impact**: The changes span drivers, apps, and libraries but maintain independent compilation of each component.
---
## Conclusion
The patch is fundamentally sound and implements a valuable consolidation. The only required change is adding a release notes entry documenting the new public macro. The documentation suggestions are optional improvements.
More information about the test-report
mailing list