Subject: [mirage-platform] [xen] switch to using the bigarray's C finaliser to free() page-aligned ... (#6)
Date: 25 September 2012 15:58:26 EDT
...buffers
Using an ocaml finaliser on the bigarray value doesn't work because
sub-bigarrays are distinct ocaml values which share the underlying data.
When the parent ocaml value is finalised the child bigarray may still
be in scope somewhere and the data accidentally scared.
Now we directly call memalign() which calls _xmalloc() which calls
alloc_pages() to allocate individual blocks and rely on the fact that
sub-bigarrays all share a common "proxy" object and the underlying data
is not free()d until the refcount within the proxy drops to zero i.e.
all related bigarrays are unreachable. This replaces the (broken) ocaml-level
freelist implementation with a (hopefully working) C-level one.
If we run out of memory and memalign() fails, we return None and allow
the ocaml world to run a Gc.compact() which might call enough finalizers
to allow the request to be satisfied.
This has only been superficially tested -- I need to give it more of a hammering.
You can merge this Pull Request by running:
git pull https://github.com/djs55/mirage-platform fix-bigarray
Or view, comment on, or merge it at:
https://github.com/mirage/mirage-platform/pull/6
Commit Summary
- [xen] switch to using the bigarray's C finaliser to free() page-align…
File Changes
- M xen/lib/io_page.ml (45)
- M xen/runtime/kernel/page_stubs.c (35)
Patch Links
—
Reply to this email directly or view it on GitHub.