Skip to content

Use page-aligned allocation only if required#317

Merged
colmmacc merged 2 commits intoaws:masterfrom
raycoll:malloc
Sep 27, 2016
Merged

Use page-aligned allocation only if required#317
colmmacc merged 2 commits intoaws:masterfrom
raycoll:malloc

Conversation

@raycoll
Copy link
Copy Markdown
Contributor

@raycoll raycoll commented Sep 25, 2016

Previously, we were nonconditionally doing page-aligned allocations.
This is only required if the user wishes to mlock all s2n data. For
performance, let's disable alignment if it isn't required.

closes #110

Previously, we were nonconditionally doing page-aligned allocations.
This is only required if the user wishes to mlock all s2n data. For
performance, let's disable alignment if it isn't required.

closes aws#110
b->size = size;
return 0;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would we better doing something like:

if (!use_mlock) {
    b->data = realloc(b->data ...)
    madvice(DONT_DUMP) ...
    return 0;

here? There's a lot of logic in this function to duplicate what realloc may do more efficiently.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Makes that branch terminal as well

b->data = data;
b->size = size;
b->allocated = size;
return 0;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We need to do the DONTDUMP here if we want to preserve that behavior.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Per http://man7.org/linux/man-pages/man2/madvise.2.html , madvise needs a page-aligned pointer as well.

@colmmacc colmmacc merged commit fa5e55d into aws:master Sep 27, 2016
@raycoll raycoll deleted the malloc branch October 10, 2016 16:02
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.

madvise needs to page-alligned memory pointer

2 participants