-
Notifications
You must be signed in to change notification settings - Fork 9
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
Initial data structures and functionality for mbox_allocator. #133
Initial data structures and functionality for mbox_allocator. #133
Conversation
0f5b12a
to
21f36ef
Compare
* @param alloc_handle IN Gnix_mbox_alloc_handle to use as allocator. | ||
* @param ptr IN/OUT Pointer that contains allocated gnix_mbox. | ||
*/ | ||
int mbox_alloc(struct gnix_mbox_alloc_handle *alloc_handle, |
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.
I think we'll want to feed a pointer to a pointer for mbox_alloc. struct gnix_mbox **ptr
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.
Good catch. I'll fix that.
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.
Shouldn't it be "struct gnix_mbox *ptr"? The interface fills out a descriptor allocated by the user.
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.
I'm not sure, it could really go either way.... @hppritcha
Looks fine to me. Do we have a need for more extended set of calls than just alloc and free? Would it be beneficial to provide a call for allocating blocks of mailbox space at once? I have some implementation related questions that we can defer to another issue. |
@jswaro I think the initial plan was that a couple of blocks would be mmaped up front in |
21f36ef
to
8cda423
Compare
@jswaro for IAA did you ever allocate blocks of mailboxes at once? |
@bturrubiates @hppritcha We allocated blocks of mailboxes internally, but never externally. This was done to save on MDD registrations. I'm assuming this would be analogous to allocating a new slab within the allocator. |
4c99bd0
to
0bfad1e
Compare
2015-05-04 9:29 GMT-06:00 James Swaro [email protected]:
|
@jswaro |
return 0; | ||
} | ||
|
||
int mbox_free(struct gnix_mbox *ptr) |
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.
I don't see anything in gnix_mbox that allows you to look up the correct slab to free.
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.
If I understand you correctly, you could use the memory handle and the base pointer.
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.
We'd have to have some global list of mbox allocators then, right? I'd recommend passing the mbox allocator handle to mbox_free().
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.
Oh, I get what you're saying now. Yeah I guess that detail was overlooked.
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.
Actually that requires keeping track of mailbox <-> allocator at a layer above this. Do we just want to shove a pointer to the allocator inside of each mailbox? It loses 8 bytes per mailbox, but is worth it to do that rather than rely on book keeping at the layer above?
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.
I think having a pointer to the allocator would be ideal. It makes the free call more simple and we could catch invalid frees by checking for a NULL allocator field.
18d2a9b
to
3d52393
Compare
By calloc-esque, I'm referring to the possibility of allocating several mailboxes within a single call instead of multiple calls. Do we ever see a case where we might do the following? for (i = 0; i < num_ep; ++i) {
mbox_alloc(alloc_handle, &ep->mbox);
} |
@jswaro I'm not sure. I had asked @hppritcha about usage and whether we want to have a count parameter, but I don't think it was in his use cases. |
not at the moment, but maybe sometime in the future? |
I don't think we need such a function right now though. |
3d52393
to
cb6d9b3
Compare
@ztiffany @jswaro @hppritcha |
|
||
*filename = full_filename; | ||
|
||
file_id++; |
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.
sounds a little crazy but could we make file_id an atomic counter?
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.
Sure. I actually should probably go do a round of updates and use strtok_r, strerror_r, and update file_id to be an atomic counter.
I think this is ready for a second look: @jswaro @hppritcha |
return ret; | ||
} | ||
|
||
static int __find_free(struct gnix_mbox_alloc_handle *handle, |
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.
Nice usage.
ret = gnix_mbox_allocator_destroy(allocator); | ||
assert_eq(ret, -FI_EINVAL, | ||
"gnix_mbox_allocator_destroy succeeded on NULL handle."); | ||
} |
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.
A few more tests would be prudent:
mbox_exhaustion -- can we test if a new slab has been allocated when resources are exhausted?
mbox_allocation -- can we allocate multiple mboxes and ensure they are all different?
mbox_free_err -- can we free a mailbox twice and get the proper return code ?
mbox_free_array -- can we allocate multiple mailboxes, perhaps off different slabs, and free them all without error?
so on and so forth...
4fb6273
to
cd01dfc
Compare
@jswaro @ztiffany @hppritcha |
Whenever this is reviewed, I'll squash into less commits. |
Looks good. |
looks good to me too! |
Implemented: - gnix_mbox_allocator_create - gnix_mbox_allocator_destroy - gnix_mbox_alloc - gnix_mbox_free - Add criterion tests to ensure that creation of allocator works with various page sizes. - Add a test to allocate multiple mailboxes and ensure they are different. - Add tests to make sure failure cases work properly. - Add tests to make sure that an extra slab is created when one has been exhausted. Signed-off-by: Ben Turrubiates <[email protected]>
c026454
to
9ef1375
Compare
@hppritcha I'm seeing this:
|
Initial data structures and functionality for mbox_allocator.
Break out option parsing for client-server tests into common code.
This is open for discussion and so @hppritcha has an interface to work with.
Thoughts?
Signed-off-by: Ben Turrubiates [email protected]