|WARNING| [1/1] eal: add API to get CPU socket ID
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Mon Sep 14 22:03:16 CEST 2026
Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/169560
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-09-14
# Review of DPDK Patch: eal: add API to get CPU socket ID
## Summary
This patch adds a new public API function `rte_cpu_socket_id()` to map OS logical CPU IDs to NUMA socket IDs. The implementation is straightforward, reusing existing internal EAL infrastructure.
---
## Errors
None found.
---
## Warnings
### 1. Missing `__rte_experimental` marker on new public API
**Issue:** The new function `rte_cpu_socket_id()` is a public API addition but is not marked as `__rte_experimental`.
**Why it matters:** All new public API functions must be marked experimental initially per DPDK policy, allowing the API to stabilize before becoming part of the stable ABI.
**Fix:** Add `__rte_experimental` to the function declaration in `rte_lcore.h`:
```c
/**
* Get the ID of the NUMA node for a CPU.
*
* This function maps an OS logical CPU ID to the NUMA node containing
* that CPU.
*
* @param cpu_id
* The OS logical CPU ID.
* @return
* The ID of cpu_id's NUMA node, or 0 if unavailable.
*/
__rte_experimental
unsigned int
rte_cpu_socket_id(unsigned int cpu_id);
```
And update the export macro in `eal_common_lcore.c`:
```c
RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_cpu_socket_id, 26.11)
unsigned int
rte_cpu_socket_id(unsigned int cpu_id)
{
return eal_cpu_socket_id(cpu_id);
}
```
### 2. New public API lacks usage in testpmd and functional tests
**Issue:** The patch adds a new public API function but does not add any usage in testpmd or tests in the functional test suite.
**Why it matters:** New APIs should be tested to verify correct behavior and provide usage examples. This helps ensure the API works as intended and serves as documentation for users.
**Fix:** Add appropriate test coverage in `app/test/` using the `TEST_ASSERT` macros and `unit_test_suite_runner` infrastructure. Example test cases could verify:
- Returns valid socket ID for online CPUs
- Handles invalid CPU IDs gracefully
- Returns consistent results when called multiple times for the same CPU
---
## Info
### 1. Release notes update location
The release notes update in `release_26_11.rst` under "API Changes" is appropriate. However, since this is marked as a future release (September 2026 is in the past as of the current date 2026-09-14), verify this is the correct target release file.
### 2. Consider adding bounds validation
While `eal_cpu_socket_id()` likely handles invalid CPU IDs, consider documenting the behavior when `cpu_id` is out of range or refers to an offline CPU. The current documentation says "or 0 if unavailable" but doesn't clarify what "unavailable" means (offline CPU, invalid ID, etc.).
---
## Positive Observations
- Clean implementation reusing existing infrastructure
- Proper mailmap entry added
- Documentation follows Doxygen format
- Code style is correct (return type on separate line, proper indentation)
- Export macro placement is correct (in .c file, on line before function)
- Solves a legitimate use case (topology lookup without lcore mapping)
More information about the test-report
mailing list