Subject: Re: Disallowing mmapping of NULL
To: None <tech-kern@netbsd.org>
From: Joerg Sonnenberger <joerg@britannica.bec.de>
List: tech-kern
Date: 01/29/2007 22:35:36
On Mon, Jan 29, 2007 at 09:31:36PM +0000, David Laight wrote:
> It might be true that some of the program header gets mapped to zero, but that
> would be a permanent mapping, not something that a program might expect mmap()
> to perform.

The patch doesn't distinguish between uvm_map called via exec and
uvm_map called via mmap.

> Historically a byte read from address 0 returned the value 0, so that code
> could do 'if (*ptr)' instead of 'if (ptr && *ptr)' in order to save code bytes.

Yeah, other optimisations possible when you know that NULL is a valid
(readable) address is more aggressive prefetch. IBM showed some
interesting benchmarks with SPEC and XLC on PowerPC. Patching the NULL
mapping on Linux and telling the compiler about it could improve
performance up to 10% for individual tests.

Joerg