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

Allow non-contiguous malloc() when memory is fragmented. #854

Closed
nyh opened this issue Feb 20, 2017 · 0 comments
Closed

Allow non-contiguous malloc() when memory is fragmented. #854

nyh opened this issue Feb 20, 2017 · 0 comments

Comments

@nyh
Copy link
Contributor

nyh commented Feb 20, 2017

This is a low-priority item, but I'm creating this issue so we don't forget this idea.

Currently, OSv's default (non-debugging) malloc(), large allocations (over a page size) call malloc_large() which returns a chunk of memory which is not only contiguous in virtual memory, it is also contiguous in physical memory. This may fail if we are doing a very large allocation and the memory is already fragmented - even if enough memory is available.

If the allocation request is very big (e.g., bigger than a huge page) or contiguous allocation fails, it might make sense to fall back to mmap(). If we do this, there are additional complications: We need free() to recognize this memory (and remember its size) and be able to unmap it. For potential use in drivers which want physical memory, it would also be nice to fix virt_to_phys() to work on mmap'ed memory, or more efficiently - create a function which can take a virtual address range and returns a list of physical address ranges (the virt_to_phys template in <osv/mmu.hh> does exactly this, but needs support for mmap'ed memory).

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

No branches or pull requests

1 participant