Probably the right way of attaching such metadata to a VMA would be
remembering it alongside the VMA in a very simple way.
For example, when we perform a reservation we would allocate a refcounted
object and assign it to the VMA (pointer, xarray, whatever).
Duplicating the VMA would increase the refcount. Freeing a VMA would
decrease the refcount.
Once the refcount goes to zero, we undo the reservation and free the object.
We would not adjust a reservation on partial VMA unmap (split + unmap A or
B), but I strongly assume that would just be fine as long as we undo the
reservation once the refcount goes to 0.
Yeah this is a really good idea actually, almost kinda what refcounts are
for haha...
The problem is we talk about this idly here, but neither of us wants to
actually write PAT code I'd say, so this may go nowhere. But maybe one of
us will get so frustrated that we do this anyway but still...
Then again - actually, is this something you are planning to tackle?