Right now if you build an amd64 GENERIC kernel with KDTRACE_HOOKS and
try to load solaris.kmod and dtrace.kmod, it will fail with ENOMEM.
This happens because there's only something like 32 MB of KVA
available for the the module loader as set up between module_start and
module_end by initx86_load_memmap and determined by the definition of
NKL2_KIMG_ENTRIES in <amd64/pmap.h>:
#define NKL2_KIMG_ENTRIES 16
module_start = kern_end;
module_end = KERNBASE + NKL2_KIMG_ENTRIES * NBPD_L2;
where NBPD_L2 is 2 MB. NKL2_KIMG_ENTRIES was bumped from 10 a couple
years ago.
I don't understand what all the constraints on this limitation are,
other than that it is necessary for the module loader to relocate JMPs
without overflowing the instruction width. But I would like to avoid
having to bump this every time the kernel gets a little larger.
At the very least, in order to make dtrace work `out of the box' in
netbsd-7 (as far as it can without being on by default), can we bump
this to 32 for now?
And can someone who understands the issue better than I either find or
help me find a better way to impose the relevant constraint than to
hard-code 16 (or 32 or whatever) here?