mpool_free vs. mpool_add_chunk when deallocating a page table's root

23 views
Skip to first unread message

Hong-Seok Kim

unread,
Jan 10, 2020, 9:15:36 AM1/10/20
to Hafnium
A minor issue but just to keep a record.

mm_alloc_page_tables() is used to allocate a new page table node. It calls either mpool_alloc() or mpool_alloc_contiguous(), depending on the input parameter count. In the current implementation, count can be more than 1 only when allocating the root of a Stage 2 page table.


On the other hand, when deallocating a page table root, the current implementation unconditionally uses mpool_add_chunk(), which is meant to be used for deallocating multi-page nodes. The implication is that, even when the root is a single page node, mpool_add_chunk() is used for its deallocation. Since a single page node is also a chunk, the current implementation is not broken. However, for consistency, we may want to use mpool_free() instead of mpool_add_chunk() in such a case.

However, in the current implementation, there is no way to tell the size of a page table's root. One possibility is to add a new field to keep the size of the root in the structure mm_ptable.


Reply all
Reply to author
Forward
0 new messages