Subject: Re: Why does kernel malloc not use kseg0 addresses (i.e.
To: None <firstname.lastname@example.org>
From: None <email@example.com>
Date: 04/08/2002 16:22:09
At Mon, 8 Apr 2002 22:41:42 +0000 (UTC), "Glenn Serre" wrote:
> From a quick look at the kernel malloc code, it appears to me that on mips
> systems, malloc could return addresses in kseg0, rather than virtual
> addresses. Why does malloc use virtual addresses?
The short answer is 'because it does'.
The longer answer includes the points:
* on some ports, there _is_ no kseg0-ish segment, so kernel malloc has
to go through the kernel virtual memory map on at least some ports.
* for large (> 1 page size) allocations, it's easiest to do the
allocations with virtual memory (rather than worrying about
coalescing multiple physical pages). Note that these types of
allocations are fairly rare (though, due to their size, if they are
being accessed regularly with some amount of randomness, that might
mean that it's even more beneficial to use kseg0, because if not
they'll thrash the TLB...)
* kernel malloc is a fairly critical subsystem, and therefore it's
fairly important that modifications done to it be carefully tested
and shown to be correct on various architectures.
* allocations of fixed-size objects are (over time) being converted to
use pools, which can (and IIRC do) use kseg0, so it becomes less
important over time.
personally, and i've not put a _lot_ of thought into this, it might be
interesting to convert the less-than-page-size allocations to allocate
from pools with the appropriate sized elements...
that would at least get rid of the use of TLB entries, on ports for
which that is possible, for most of the rest of the kernel data
However, it would be no small amount of careful work to undertake...