-
Notifications
You must be signed in to change notification settings - Fork 23
nexthop: reduce info size #367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughIn Pre-merge checks❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
3de3c13 to
66f64a5
Compare
73ffeee to
cbe593d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
modules/infra/control/gr_nh_control.h (2)
27-29: Round up header size to info’s alignment to avoid padding drift.The current subtraction ignores padding added to align
info(pointer-aligned). If padding appears beforeinfo,sizeof(struct nexthop)can exceed the intended cap or you underutilize space. Compute with ceil-to-alignment on the header:- uint8_t info - [RTE_CACHE_LINE_MIN_SIZE * 2 - sizeof(struct gr_nexthop_base) - - sizeof(uint32_t)] __rte_aligned(alignof(void *)); + uint8_t info[ + (RTE_CACHE_LINE_MIN_SIZE * 2) + - ( + ( (sizeof(struct gr_nexthop_base) + sizeof(uint32_t) + alignof(void *) - 1) + / alignof(void *) ) * alignof(void *) + ) + ] __rte_aligned(alignof(void *));This keeps the struct strictly within the target size across ABIs even if compiler inserts pre‑
infopadding.
31-31: Optional: strengthen invariant with explicit guard and verify commit message.The
infofield size is mathematically guaranteed > 0 by the existing constraints (struct bounded to 128 bytes), but adding an explicit guard improves clarity:static_assert(sizeof(struct nexthop) <= (RTE_CACHE_LINE_MIN_SIZE * 2)); +static_assert(MEMBER_SIZE(struct nexthop, info) > 0, "nexthop.info must be > 0");Clarify cache line wording: The commit claims "single cacheline" but
RTE_CACHE_LINE_MIN_SIZE * 2= 128 bytes, which spans 1 cache line on 128B architectures and 2 on 64B architectures. Verify the commit message matches the actual intent.Searches found no problematic hardcoded 128-byte assumptions or unsafe casts elsewhere in the codebase.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
modules/infra/control/gr_nh_control.h(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{c,h}
⚙️ CodeRabbit configuration file
**/*.{c,h}: -gr_vec_*()functions cannot fail. No need to check their return value.
gr_vec_free(x)always setsx = NULL. There is no risk of double free.ec_node_*()functions consume theirec_nodearguments. No leaks on error.rte_node->ctxis an uint8_t array of size 16, not a pointer.- Don't suggest to replace
assert()with graceful error checking.- We compile with
-std=gnu2x. Unnamed parameters in function definitions are valid.
Files:
modules/infra/control/gr_nh_control.h
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: build-and-tests (gcc-14, address, debug, ubuntu-24.04, -Dfrr=enabled, true)
- GitHub Check: build-and-tests (clang-16, none, debugoptimized, ubuntu-24.04, false)
- GitHub Check: rpm
- GitHub Check: build-and-tests (clang-15, none, debugoptimized, ubuntu-22.04, false)
- GitHub Check: build-and-tests (clang-18, none, debugoptimized, ubuntu-24.04, false)
- GitHub Check: build-and-tests (gcc-13, none, debugoptimized, ubuntu-24.04, -Dfrr=enabled, false)
- GitHub Check: deb
Reduce the size of the info field as we don't have any nh info using the whole 128bytes, so the whole "struct nexthop" fits 2 cache lines on x86 (and 1 cacheline on the generic arm arch). Signed-off-by: Christophe Fontaine <[email protected]> Reviewed-by: Robin Jarry <[email protected]>
cbe593d to
bab65df
Compare
Reduce the size of the info field as we don't have any structure using the whole 128 bytes.
Cap the size of the whole "struct nexthop" to a cacheline.
Summary by CodeRabbit
Note: Internal infrastructure optimization only — no direct user-facing impact.