|WARNING| [1/1] eal: add API to get CPU socket ID

dpdklab at iol.unh.edu dpdklab at iol.unh.edu
Tue Sep 15 02:54:44 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-15

# DPDK Patch Review

## Patch: eal: add API to get CPU socket ID

### Summary
This patch adds `rte_cpu_socket_id()` to map an OS logical CPU ID to its NUMA socket without requiring an EAL lcore ID. The implementation reuses the existing `eal_cpu_socket_id()` helper.

---

## Errors

### 1. Missing `__rte_experimental` tag
**File:** `lib/eal/include/rte_lcore.h`

The new public API function `rte_cpu_socket_id()` is not marked as experimental, which is required for all new API additions per DPDK guidelines.

**Fix:** Add `__rte_experimental` alone on the line immediately before the return type:

```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);
```

### 2. Incorrect export macro usage
**File:** `lib/eal/common/eal_common_lcore.c`

New experimental symbols must use `RTE_EXPORT_EXPERIMENTAL_SYMBOL` with the version parameter, not `RTE_EXPORT_SYMBOL`.

**Fix:** Change the export macro:

```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);
}
```

---

## Warnings

### 1. Release notes should mention experimental status
**File:** `doc/guides/rel_notes/release_26_11.rst`

The release notes entry does not indicate that this is an experimental API, which helps set user expectations.

**Suggested improvement:**

```rst
* eal: Added experimental API ``rte_cpu_socket_id()`` to map an OS logical
  CPU ID to the NUMA socket containing that CPU.
```

### 2. Missing test coverage
No test additions are included in this patch. New API functions should have tests added to `app/test`.

**Suggested action:** Add a unit test in `app/test/test_lcore.c` that validates `rte_cpu_socket_id()` returns consistent results with the existing socket ID APIs for configured lcores.

---

## Informational

### 1. Function parameter validation
The implementation directly calls `eal_cpu_socket_id(cpu_id)` without validation. Consider whether the public API should validate that `cpu_id` is within a reasonable range, or document the behavior when an invalid CPU ID is provided.

The current documentation states "or 0 if unavailable" which suggests any invalid CPU ID returns 0, but this depends on the `eal_cpu_socket_id()` implementation per OS.

---

## Code Quality

**Style compliance:** The code follows DPDK C style guidelines (indentation, bracing, naming).

**Structure:** The patch is well-structured with appropriate updates to `.mailmap`, release notes, implementation, and header.

**Documentation:** Doxygen comment is present and follows DPDK conventions.

---

## Final Recommendation

The patch must be revised to address the two **Errors** (missing `__rte_experimental` tag and incorrect export macro). The warnings about test coverage and release notes wording should also be addressed before merging.


More information about the test-report mailing list