On 04/20/2018 07:21 PM, Jonathan Tan wrote:
On Tue, 17 Apr 2018 16:34:42 +0000
Jameson Miller <jamill@xxxxxxxxxxxxx> wrote:
@@ -19,8 +19,27 @@ struct mem_pool {
/* The total amount of memory allocated by the pool. */
size_t pool_alloc;
+
+ /*
+ * Array of pointers to "custom size" memory allocations.
+ * This is used for "large" memory allocations.
+ * The *_end variables are used to track the range of memory
+ * allocated.
+ */
+ void **custom, **custom_end;
+ int nr, nr_end, alloc, alloc_end;
This seems overly complicated - the struct mem_pool already has a linked
list of pages, so couldn't you create a custom page and insert it behind
the current front page instead whenever you needed a large-size page?
Yes - that is another option. However, the linked list of pages includes
memory that *could* have space for an allocation, while the "custom"
region will never have left over memory that can be used for other
allocations. When searching pages for memory to satisfy a request, there
is no reason to search through the "custom" pages. There is a trade-off
between complexity and implementation, so I am open to suggestions.
This was discussed in [1], where it originally was implemented closer to
what you describe here.
Also, when combining, there could be some wasted space on one of the
pages. I'm not sure if that's worth calling out, though.
Yes, we bring over the whole page. However, these pages are now
available for new allocations.
[1]
https://public-inbox.org/git/xmqqk1u2k91l.fsf@xxxxxxxxxxxxxxxxxxxxxxxxx/