Skip to content

Conversation

ovsrobot
Copy link
Owner

@ovsrobot ovsrobot commented Oct 5, 2025

NOTE: This is an auto submission for "net/mlx5: release allocated indexed pools".

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

Summary by Sourcery

Add cleanup of allocated indexed pools for flow resources on device close to prevent memory leaks

Bug Fixes:

  • Invoke mlx5_flow_pools_destroy in mlx5_dev_close to release previously allocated indexed pools

Enhancements:

  • Introduce mlx5_flow_pools_destroy to iterate and destroy flow index pools

Summary by CodeRabbit

  • Bug Fixes
    • Improved resource cleanup on device shutdown for the MLX5 driver by releasing flow-related memory pools, preventing potential memory leaks.
    • Enhances stability for long-running applications, hot-plug scenarios, and repeated port start/stop cycles, especially in environments with many flow rules.

The cited commit allocated indexped pools but those pools
were never released. Fix it.

Fixes: b4edeaf ("net/mlx5: replace flow list with indexed pool")
Cc: stable@dpdk.org

Signed-off-by: Roi Dayan <roid@nvidia.com>
Acked-by: Bing Zhao <bingz@nvidia.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
Copy link

sourcery-ai bot commented Oct 5, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds mechanism to release indexed flow pools by introducing a dedicated cleanup function and invoking it during device shutdown.

Sequence diagram for device close and flow pool cleanup

sequenceDiagram
    participant "mlx5_dev_close()"
    participant "mlx5_flow_pools_destroy()"
    participant "mlx5_ipool_destroy()"
    "mlx5_dev_close()"->>"mlx5_flow_pools_destroy()": Call during device close
    loop For each flow pool in priv->flows
        "mlx5_flow_pools_destroy()"->>"mlx5_ipool_destroy()": Destroy non-null pool
    end
Loading

Class diagram for updated mlx5_priv flow pool management

classDiagram
    class mlx5_priv {
        flows[MLX5_FLOW_TYPE_MAXI]: ipool*
        domain_id: int
        ...
    }
    class mlx5_flow_pools_destroy {
        +mlx5_flow_pools_destroy(priv: mlx5_priv*)
    }
    mlx5_flow_pools_destroy --> mlx5_priv : uses
    class mlx5_ipool_destroy {
        +mlx5_ipool_destroy(ipool*)
    }
    mlx5_flow_pools_destroy --> mlx5_ipool_destroy : calls
    mlx5_priv "1" o-- "MLX5_FLOW_TYPE_MAXI" ipool : flows array
Loading

File-Level Changes

Change Details Files
Add flow pool destruction helper
  • Introduce static mlx5_flow_pools_destroy()
  • Iterate over priv->flows up to MLX5_FLOW_TYPE_MAXI
  • Call mlx5_ipool_destroy() for each non-null pool
drivers/net/mlx5/mlx5.c
Invoke flow pool cleanup on device close
  • Insert call to mlx5_flow_pools_destroy(priv) in mlx5_dev_close()
drivers/net/mlx5/mlx5.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

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 - here's some feedback:

  • Consider resetting priv->flows[i] to NULL after calling mlx5_ipool_destroy to avoid dangling pointers in the private data.
  • Ensure mlx5_flow_pools_destroy is invoked in any early error‐exit paths during flow pool setup so partial initialization failures don’t leak pools.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider resetting priv->flows[i] to NULL after calling mlx5_ipool_destroy to avoid dangling pointers in the private data.
- Ensure mlx5_flow_pools_destroy is invoked in any early error‐exit paths during flow pool setup so partial initialization failures don’t leak pools.

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.

Copy link

coderabbitai bot commented Oct 5, 2025

Walkthrough

Adds a static mlx5_flow_pools_destroy(priv) to free flow IP pools and invokes it from mlx5_dev_close() to ensure pools are destroyed during device close.

Changes

Cohort / File(s) Summary
Flow pool cleanup
drivers/net/mlx5/mlx5.c
Introduces mlx5_flow_pools_destroy(priv) to iterate over MLX5_FLOW_TYPE_MAXI and destroy non-null priv->flows[i] via mlx5_ipool_destroy; calls this cleanup from mlx5_dev_close() before clearing the private structure.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant App
    participant Driver as mlx5_dev_close()
    participant Pools as mlx5_flow_pools_destroy()
    participant IPool as mlx5_ipool_destroy()

    App->>Driver: close device
    Driver->>Pools: destroy flow pools
    loop for i in [0..MLX5_FLOW_TYPE_MAXI)
        alt priv->flows[i] != NULL
            Pools->>IPool: mlx5_ipool_destroy(priv->flows[i])
            IPool-->>Pools: freed
        else
            note over Pools: skip null entry
        end
    end
    Pools-->>Driver: done
    Driver-->>App: close complete
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I nibble through code with tidy delight,
Sweeping old pools from the closing night.
One hop per flow, I free what’s due—
No crumbs of leaks for bugs to chew.
Burrow secure, device sleeps tight,
Rabbit approves: cleanup done right. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% 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 title “net/mlx5: release allocated indexed pools” accurately captures the primary change of adding cleanup for flow IP pools in the mlx5 driver, is concise and specific to the modified code, and aligns with the raw summary of changes.
✨ 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_36292

📜 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 76393b9 and e954531.

📒 Files selected for processing (1)
  • drivers/net/mlx5/mlx5.c (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
drivers/net/mlx5/mlx5.c (1)
drivers/net/mlx5/mlx5_utils.c (1)
  • mlx5_ipool_destroy (845-894)
⏰ 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 (2)
drivers/net/mlx5/mlx5.c (2)

2339-2349: LGTM! The function correctly releases flow pool resources.

The implementation properly iterates through all flow types and destroys allocated indexed pools with appropriate NULL checks. The cleanup logic aligns with the existing pattern used elsewhere in the driver.


2540-2540: LGTM! Proper placement ensures flow pools are released during device close.

The call is correctly positioned after flow flushes (lines 2399-2401) and before the final memset that clears the private structure. This ordering ensures pools are destroyed only after flows are flushed and before the structure is zeroed.


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.

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.

2 participants