<div dir="ltr"><div>I&#39;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&#39;t seem likely. I think what you want is genalloc, the general purpose allocator.<br><br>I&#39;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&#39;s up to you where that comes from or how you allocate it from the kernel.<br><br></div><div>Hope that helps. I didn&#39;t know about genalloc before you asked and I&#39;ve been curious about other allocators after playing with kmem_cache.<br><br></div><div>Alex W<br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 20, 2015 at 9:49 AM, Kenneth Adam Miller <span dir="ltr">&lt;<a href="mailto:kennethadammiller@gmail.com" target="_blank">kennethadammiller@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Suppose I want to do something analogous to C++&#39;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.<div><br></div><div>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&#39;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&#39;ve allocated before.</div><div><br></div><div>The end result is what I need, and from which I&#39;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.</div><div><br></div><div>Is the above possible? I&#39;m pretty sure that it is.</div></div>
<br>_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
<a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" rel="noreferrer" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">Alex Wilson<br>(703) 300-2894<br></div>
</div>