Comment 6 for bug 1039916

Revision history for this message
TJ (tj) wrote :

The issue is being caused by calls the system's mmap() function failing to allocate the requested VMA mappings.

After some further debugging and playing with values I modified backend/back_linux.c::map_dev_mem() so that when mmap() returns MAP_FAILED the function adjusts the requested allocation to progressively smaller sizes (in steps of 256 bytes).

If the allocation differs from the request it is reported to stderr. If the allocation totally fails the program exits.

Here's the output on my amd64 system:

$ ./smartdimmer -g
OK: map_mem(): PEXTDEV requested 0x1000 and received 0x1000 after 0 attempts at 0xd5101000
OK: map_mem(): PEXTDEV requested 0x1000 and received 0x1000 after 0 attempts at 0xd5100000
OK: map_mem(): PEXTDEV requested 0x1000 and received 0x1000 after 0 attempts at 0xd5000000
OK: map_mem(): PEXTDEV requested 0x2000 and received 0x2000 after 0 attempts at 0xd5601000
ERR: map_mem(): PDISPLAY requested 0x10000 but received 0x8000 after 8 attempts at 0xd5610000
OK: map_mem(): PEXTDEV requested 0x2000 and received 0x2000 after 8 attempts at 0xd5680000
ERR: map_mem(): PRAMIN requested 0x100000 but received 0x0 after 264 attempts at 0xd5700000

So it looks like requests for large maps are causing problems.