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

Initial data structures and functionality for mbox_allocator. #133

Merged
merged 1 commit into from
May 8, 2015

Conversation

bturrubiates
Copy link

This is open for discussion and so @hppritcha has an interface to work with.

Thoughts?

Signed-off-by: Ben Turrubiates [email protected]

@bturrubiates bturrubiates force-pushed the topic/mbox-allocator branch from 0f5b12a to 21f36ef Compare April 30, 2015 22:30
* @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,
Copy link
Member

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

Copy link
Author

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.

Copy link

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.

Copy link
Author

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

@jswaro
Copy link
Member

jswaro commented May 3, 2015

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.

@bturrubiates
Copy link
Author

@jswaro I think the initial plan was that a couple of blocks would be mmaped up front in mbox_allocator_create and mbox_alloc would just partition it up hand out the handles.

@bturrubiates bturrubiates force-pushed the topic/mbox-allocator branch from 21f36ef to 8cda423 Compare May 4, 2015 15:25
@hppritcha
Copy link
Member

@jswaro for IAA did you ever allocate blocks of mailboxes at once?

@jswaro
Copy link
Member

jswaro commented May 4, 2015

@bturrubiates
I understand that they will be allocated in chunks as a slab, but will there be occasions where you might do mbox_alloc repeatedly within the same function call, for which a calloc-esque call would be beneficial?

@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.

@bturrubiates bturrubiates force-pushed the topic/mbox-allocator branch 2 times, most recently from 4c99bd0 to 0bfad1e Compare May 4, 2015 15:41
@hppritcha
Copy link
Member

2015-05-04 9:29 GMT-06:00 James Swaro [email protected]:

@hppritcha https://github.com/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.

yes that's the basic reason for allocation by slab.


Reply to this email directly or view it on GitHub
#133 (comment)
.

@bturrubiates
Copy link
Author

@jswaro
I'm not sure I understand. What do you mean by a 'calloc-esque' call?

return 0;
}

int mbox_free(struct gnix_mbox *ptr)
Copy link

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.

Copy link
Author

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.

Copy link

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().

Copy link
Author

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.

Copy link
Author

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?

@hppritcha @ztiffany

Copy link
Member

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.

@bturrubiates bturrubiates force-pushed the topic/mbox-allocator branch 2 times, most recently from 18d2a9b to 3d52393 Compare May 4, 2015 16:21
@jswaro
Copy link
Member

jswaro commented May 4, 2015

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);
}

@bturrubiates
Copy link
Author

@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.

@hppritcha
Copy link
Member

not at the moment, but maybe sometime in the future?

@hppritcha
Copy link
Member

I don't think we need such a function right now though.

@bturrubiates bturrubiates force-pushed the topic/mbox-allocator branch from 3d52393 to cb6d9b3 Compare May 4, 2015 17:36
@bturrubiates
Copy link
Author

@ztiffany @jswaro @hppritcha
Ready for review.


*filename = full_filename;

file_id++;
Copy link
Member

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?

Copy link
Author

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.

@bturrubiates
Copy link
Author

I think this is ready for a second look: @jswaro @hppritcha

return ret;
}

static int __find_free(struct gnix_mbox_alloc_handle *handle,
Copy link
Member

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.");
}
Copy link
Member

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... 

@bturrubiates bturrubiates force-pushed the topic/mbox-allocator branch from 4fb6273 to cd01dfc Compare May 7, 2015 22:07
@bturrubiates
Copy link
Author

@jswaro @ztiffany @hppritcha
Ready again

@bturrubiates
Copy link
Author

Whenever this is reviewed, I'll squash into less commits.

@jswaro
Copy link
Member

jswaro commented May 7, 2015

Looks good.

@hppritcha
Copy link
Member

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]>
@bturrubiates bturrubiates force-pushed the topic/mbox-allocator branch from c026454 to 9ef1375 Compare May 8, 2015 16:06
@bturrubiates
Copy link
Author

@hppritcha I'm seeing this:

[----] ../prov/gni/test/datagram.c:401: Assertion failed: cm_nic->control_progress == FI_PROGRESS_MANUAL
[====] dg_allocation::dgram_wc_post_exchg_manual: (0.00s)
[====] Synthesis: Tested: 130 | Passing: 129 | Failing: 1 | Crashing: 0

Is that normal?
Opened issue #152.

bturrubiates added a commit that referenced this pull request May 8, 2015
Initial data structures and functionality for mbox_allocator.
@bturrubiates bturrubiates merged commit ab90252 into ofi-cray:master May 8, 2015
@bturrubiates bturrubiates deleted the topic/mbox-allocator branch May 29, 2015 18:27
jswaro pushed a commit to jswaro/libfabric that referenced this pull request Sep 11, 2018
Break out option parsing for client-server tests into common code.
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.

4 participants