It looks like if there is a solution to this problem. If you change only one line in src/include/portability/mem.h from:
#define PG_MMAP_FLAGS (MAP_SHARED|MAP_ANONYMOUS|MAP_HASSEMAPHORE)
#define PG_MMAP_FLAGS (MAP_LOCKED|MAP_SHARED|MAP_ANONYMOUS|MAP_HASSEMAPHORE)
PostgreSQL shared memory should be locked in physical RAM and never been swapped/paged out to disk.
In order for this to work you obviously need enough physical RAM, and the user PostgreSQL runs as needs permission to lock enough memory, though. So you better check the ulimit:
unlimited (or at least big enough)
Otherwise you get this rather cryptic error at startup:
"could not map anonymous shared memory: resource temporarily unavailable"
If you are not root, it will say "resource temporarily unavailable" and hide the real cause. Since PostgreSQL refuses to run as root, you'll never see the real error: "cannot allocate memory".
Well I'm no PostgreSQL hacker. I seems to be working but is it really that easy to fix?