Port-amd64 archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
2MB of zeros in kernel file
The NetBSD/amd64 kernel file has 2 MB of zeros near the beginning.
Why?
In October 2009, nick@ added `-z max-page-size=0x10000' to
Makefile.amd64 (r1.26/1.27), with the following comment:
> MAXPAGESIZE got bumped to 0x200000. Use -z maxpagesize=0x100000 until
> someone(tm) decides that kernels should have that alignment, etc.
Later, in February 2017, maxv@ bumped it to 0x20000 (r1.57):
> Put 2MB alignments between the kernel segments. This way the kernel image
> is entirely mapped with large pages, which uniformizes performance and
> reduces fluctuation. Sent on port-amd64.
The message `sent on port-amd64' was presumably:
https://mail-index.NetBSD.org/port-amd64/2017/02/03/msg002496.html
(although the link there no longer works so I cannot 100% confirm that
the patch proposed is what was committed)
These changes have the effect of putting 2 MB of zeros at the
beginning of the netbsd kernel file, as you can confirm with hexdump:
% hexdump -C netbsd
00000000 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 |.ELF............|
00000010 02 00 3e 00 01 00 00 00 00 90 20 80 ff ff ff ff |..>....... .....|
00000020 40 00 00 00 00 00 00 00 a8 cb ad 01 00 00 00 00 |@...............|
00000030 00 00 00 00 40 00 38 00 02 00 40 00 1d 00 1c 00 |....@.8...@.....|
00000040 01 00 00 00 05 00 00 00 00 00 20 00 00 00 00 00 |.......... .....|
00000050 00 00 20 80 ff ff ff ff 00 00 20 00 00 00 00 00 |.. ....... .....|
00000060 28 16 42 01 00 00 00 00 28 16 42 01 00 00 00 00 |(.B.....(.B.....|
00000070 00 00 20 00 00 00 00 00 01 00 00 00 06 00 00 00 |.. .............|
00000080 00 00 80 01 00 00 00 00 00 00 80 81 ff ff ff ff |................|
00000090 00 00 80 01 00 00 00 00 e0 7a 0a 00 00 00 00 00 |.........z......|
000000a0 00 00 20 00 00 00 00 00 00 00 20 00 00 00 00 00 |.. ....... .....|
000000b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00200000 0f 01 f8 48 a3 08 00 00 00 00 ff ff ff 48 a1 10 |...H.........H..|
...
I am not sure offhand whether the 2 MB of zeros get loaded into
memory, but I've been sitting on a patch from a year ago to replace it
by max-page-size=0x1000 with the effect of shaving those 2 MB of zeros
off the file.
I don't remember investigating the consequences of setting
max-page-size=0x1000 beyond shaving the 2 MB of zeros off the file;
it's possible I got stuck trying to get the large-page advantage
without the 2 MB of zeros by tweaking the ldscript instead.
Perhaps this isn't actually an issue if we always deal in compressed
kernel files, because gzip will handily compress a long run of zeros.
But I thought I'd open a discussion here so I can stop sitting on this
patch.
Home |
Main Index |
Thread Index |
Old Index