Skip to content

Conversation

@ovsrobot
Copy link
Owner

@ovsrobot ovsrobot commented Oct 28, 2025

NOTE: This is an auto submission for "[v2] graph: fix xstats description allocation".

See "http://patchwork.dpdk.org/project/dpdk/list/?series=36490" for details.

Summary by Sourcery

Bug Fixes:

  • Remove incorrect sizeof wrapping of the description size constant in xstat_desc allocation

Summary by CodeRabbit

  • Bug Fixes
    • Corrected memory allocation calculation in graph statistics module to ensure proper descriptor sizing and improve reliability.

Fix the extended stats name allocation size: instead of allocating
RTE_NODE_XSTAT_DESC_SIZE (64 bytes), only sizeof(RTE_NODE_XSTAT_DESC_SIZE)
were allocated for each xstat name.

Fixes: 070db97 ("graph: support node xstats")
Signed-off-by: Christophe Fontaine <cfontain@redhat.com>
Acked-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
@sourcery-ai
Copy link

sourcery-ai bot commented Oct 28, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Fix xstats description allocation by correcting the size calculation in stats_mem_populate.

Class diagram for xstats description allocation in stats_mem_populate

classDiagram
    class rte_graph_cluster_stats {
        +int socket_id
        +stat
    }
    class stat {
        +xstat_desc
        +xstat_count
    }
    class graph_node {
        +node
    }
    class node {
        +name
        +xstats
    }
    class xstats {
        +nb_xstats
    }
    rte_graph_cluster_stats --> stat
    stat --> xstat_desc
    stat --> xstat_count
    graph_node --> node
    node --> xstats
    xstats --> nb_xstats
Loading

File-Level Changes

Change Details Files
Correct xstats description allocation size
  • Removed misuse of sizeof on RTE_NODE_XSTAT_DESC_SIZE
  • Replaced allocation expression with direct multiplication by RTE_NODE_XSTAT_DESC_SIZE
lib/graph/graph_stats.c

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link

coderabbitai bot commented Oct 28, 2025

Walkthrough

A memory allocation bug fix in the graph statistics module corrects the size calculation for xstat_desc by removing an incorrect sizeof() call, ensuring proper descriptor allocation based on the number of extended statistics.

Changes

Cohort / File(s) Summary
Memory allocation fix
lib/graph/graph_stats.c
Corrected size calculation from sizeof(RTE_NODE_XSTAT_DESC_SIZE) * nb_xstats to RTE_NODE_XSTAT_DESC_SIZE * nb_xstats for accurate memory allocation

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Verify that RTE_NODE_XSTAT_DESC_SIZE is a size constant (not a struct) to confirm the fix is semantically correct
  • Confirm the allocation size now matches the intended descriptor size for the given number of xstats

Poem

🐰 A rabbit hopped through memory's lane,
Found sizeof() causing memory pain,
Removed the redundant call with care,
Now allocations are proper and fair! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "graph: fix xstats description allocation" (excluding the metadata tags "[PWCI]" and "[v2]") directly and clearly summarizes the main change in the changeset. The title specifically references the fix to xstats description memory allocation in the graph module, which matches precisely with the core change described in the summary. The title is concise, specific, and meaningful, avoiding vague terminology or excessive noise while making it clear to reviewers what was modified.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch series_36490

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 39b54f2 and 0fc9b24.

📒 Files selected for processing (1)
  • lib/graph/graph_stats.c (1 hunks)
⏰ 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). (1)
  • GitHub Check: Sourcery review
🔇 Additional comments (1)
lib/graph/graph_stats.c (1)

304-311: Critical bug fix: Correct memory allocation for xstat descriptors.

The removal of sizeof() wrapper around RTE_NODE_XSTAT_DESC_SIZE is the correct fix. The previous code was allocating memory based on the size of the constant itself (typically 4-8 bytes) rather than using the constant's value (the actual descriptor size). This severe under-allocation would have caused buffer overflows during the string copy operations at lines 314-316, leading to memory corruption.

The fix properly allocates RTE_NODE_XSTAT_DESC_SIZE * nb_xstats bytes, matching the usage pattern at line 316 where RTE_NODE_XSTAT_DESC_SIZE is used as the string size limit.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants