[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fwd: [mirage-platform] [xen] switch to using the bigarray's C finaliser to free() page-aligned ... (#6)



Thanks to a spot of low-level detective work from Balraj and Dave, the interaction between reference-counted and garbage-collected IO pages should now actually work properly!

Haris, you may also run into this if using the Xen backend (it wont affect the UNIX backend), so be sure to merge it in.

-anil

Begin forwarded message:

From: Dave Scott <notifications@xxxxxxxxxx>
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
To: mirage/mirage-platform <mirage-platform@xxxxxxxxxxxxxxxxxx>

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



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.