Subject: Why does kernel malloc not use kseg0 addresses
To: None <port-mips@netbsd.org>
From: Toru Nishimura <locore32@gaea.ocn.ne.jp>
List: port-mips
Date: 04/10/2002 13:16:52
> 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 reasons I ask are:
>
>  - I appear to have a buggy TLB, but I would like to get things running
>    enough for people to start working on drivers.
>  - kseg0 addresses might improve performance by avoiding TLB
>    miss exceptions.
>
> Note: I am trying to port NetBSD to a processor whose memory management is
> like mips,  ...

The second point is definitely make sense and it's observed indeed a fairly
large number of TLB entries active to run KSEG2 address range for kernel.
The issue is the change would (might) bring an big impact the kernel internal.
It started its history with VAX/m68k/i386 style CPU which has no way
to handle PHY memory w/o MMU intervention.  And it'd remain KSEG2
memory operations (more or less) to make page-wise 0-copy move
possible.

Regarding to the 1st point, it'd be important to keep TLB hardware
stand straight since there is no chance for softwares to work correctly
and reliably w/o it.

Toru Nishimura