Subject: Re: Why does kernel malloc not use kseg0 addresses (i.e. physical
To: None <port-mips@netbsd.org>
From: Glenn Serre <gaserre@spiresoftware.com>
List: port-mips
Date: 04/09/2002 08:21:19
Good morning,

On 8 Apr 2002 cgd@broadcom.com wrote:
> 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:
>
[...]

> However, it would be no small amount of careful work to undertake...
>

Since malloc seems to get memory from UVM in chumks that are multiples of
page size, a first attempt might se uvm_pagealloc() for page-sized
chunks and uvm_pglistalloc() to allocate multiple pages, perhaps falling
back to uvm_km_kmemalloc() if uvm_pglistalloc() fails.  The fallback might
be problematic when it comes time to free the memory, though.

If I get something working, I will send a patch for consideration.

Thanks!
--Glenn S.