Placement Allocation within the kernel

Alex Wilson alex.david.wilson at gmail.com
Thu Aug 20 18:26:27 EDT 2015


I'm a little confused about the whole page table bit, since (according to
my limited knowledge) that would mean managing page attributes and playing
nice with the MMU. Although I think I understand what you meant by the
rest. I believe kmalloc internally uses the slab allocator to bunch up
memory into the caches in order to minimize fragmentation. So re-purposing
kmalloc for a different chunk of memory doesn't seem likely. I think what
you want is genalloc, the general purpose allocator.

I've seen genalloc used around the kernel for more fine-grained
allocations. Generally it seems that you create a pool, then add a chunk of
memory to the pool, then make any number of allocations and frees, then
free the pool. Of course, you need to find memory to add to the pool first,
but it's up to you where that comes from or how you allocate it from the
kernel.

Hope that helps. I didn't know about genalloc before you asked and I've
been curious about other allocators after playing with kmem_cache.

Alex W


On Thu, Aug 20, 2015 at 9:49 AM, Kenneth Adam Miller <
kennethadammiller at gmail.com> wrote:

> Suppose I want to do something analogous to C++'s new in userspace. But
> instead, I want an entirely new page table to be constructed at the
> location of my choosing. In addition, I want a specific region for that
> page table to manage, and this requires that this region no longer be
> available to the rest of kernel code in order that it cannot be served for
> allocation elsewhere.
>
> To illustrate what I want to do, I think it would be ok to imagine that I
> allocate a very large contiguous region of memory within which to do this.
> Once that region of memory is allocated, it can't be served elsewhere, so
> that serves my purpose. Then what I want to do is have an equivalent of
> kmalloc and free that not only takes size and a pointer respectively, but
> also the table which to reference in order to do the allocation from. To
> begin with, before I do work allocation with this table, I need a function
> that will construct such a table correctly at the location of my choosing
> within the large block that I mentioned that I've allocated before.
>
> The end result is what I need, and from which I've derived the above
> requirements: I can have the default memory management facilities within
> the kernel reused to suit my needs. Kmalloc and kfree will coalesce the
> table behind the scenes for me, which is what I want to avoid.
>
> Is the above possible? I'm pretty sure that it is.
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>


-- 
Alex Wilson
(703) 300-2894
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150820/00d37677/attachment.html 


More information about the Kernelnewbies mailing list