Skip to content
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

[catnip] Memory Pool Abstraction #84

Merged
merged 10 commits into from
Apr 12, 2022
Merged

[catnip] Memory Pool Abstraction #84

merged 10 commits into from
Apr 12, 2022

Conversation

ppenna
Copy link
Contributor

@ppenna ppenna commented Apr 12, 2022

Description

In this PR, I mostly introduce the enhancement that is described in #83.

Here is a digest of the commits:

  • In commit 2a31472 I drop bad checks that were used in the pointer arithmetic for allocating/releasing mbufs.
  • In commit dc73ffe I introduce the MemoryPool abstraction.
  • In commit c31d48b and 729f091 I refactor the code to rely on the MemoryPool abstraction
  • In commit 837ed50 I drop the indirect memory pool, because it is not required to provide the shallow copy of mbufs (rte_pktmbuf_clone does the job) and it was causing interdependency between several modules.

@ppenna ppenna added the enhancement Enhancement Request on an Existing Feature label Apr 12, 2022
@ppenna ppenna requested a review from BrianZill April 12, 2022 14:21
@ppenna ppenna self-assigned this Apr 12, 2022
@BrianZill
Copy link
Contributor

Is the title meant to say "[canip]" or "[catnip]"?

unsafe {
rte_pktmbuf_free(self.ptr);
}
MemoryPool::free_mbuf(self.ptr);
self.ptr = ptr::null_mut();
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems very un-Rustian. Now that the unsafe code is contained inside MemoryPool::free_mbuf(), it seems strange to be nullifying self.ptr here. I would expect free_mbuf() to be doing this for us, so we don't have access to a bogus pointer upon return.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Somehow we should make the raw pointer null, because it is not managed by Rust. I did not get what you are suggesting. Could you clarify it further?

Copy link
Contributor

Choose a reason for hiding this comment

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

I was suggesting that free_mbuf() null out self.ptr itself. To really do this right, we (or rather, the MemoryPool) would hide the "*mut rte_mbuf" inside a Rust type of our own creation. We'd pass that type into free_mbuf(), it would take ownership, etc.

But don't worry about it, this is probably good enough for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I got it and agree. I'm refactoring Mbuf so as to make this interface cleaner too. Thanks.

@ppenna ppenna changed the title [canip] Memory Pool Abstraction [catnip] Memory Pool Abstraction Apr 12, 2022
ppenna added a commit that referenced this pull request Apr 12, 2022
@ppenna ppenna requested a review from BrianZill April 12, 2022 20:38
Copy link
Contributor

@BrianZill BrianZill left a comment

Choose a reason for hiding this comment

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

Okay.

@ppenna ppenna force-pushed the enhancement-catnip-mempool branch from 17a4cd0 to f36af86 Compare April 12, 2022 22:24
@ppenna ppenna merged commit 39346cc into dev Apr 12, 2022
@ppenna ppenna deleted the enhancement-catnip-mempool branch April 12, 2022 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement Request on an Existing Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants