|
libbmm calls into the kernel a lot to perform various functions such as
translating between virtual and physical addresses, finding out the
buffer size, and so forth. Much of this can be done in userspace,
because we have that information at the point where the buffer is
allocated.
Rather than having to keep fetching it from the kernel, store it in our
own local bmm_buffer structure, and store this in a pair of rb trees -
one indexed by physical address and the other by virtual address. This
allows us to efficiently look up the bmm_buffer structure by either
address, and retrieve the other buffer attribute(s).
Reference: http://web.eecs.utk.edu/~plank/plank/rbtree/rbtree.html
|