locking pages into a processes` working set

From: Richard B. Johnson
Date: Fri Mar 26 2004 - 09:18:46 EST



I have been trying to lock pages down so I can get
a stable bench-mark without a bunch of paging.
I have tried mlock(), mlockall(), etc., but both
the RSS and SIZE entries shown by `top` vary all
over the place when the process is active.

`strace` of an attempt to keep some shared memory
resident. It seems to work as far as `strace`
shows.

munmap(0x400cc000, 4096) = 0
shmget(4277009102, 1052672, IPC_CREAT|IPC_EXCL|0x180|0600) = 425984
shmctl(425984, IPC_STAT, 0xbffff698) = 0
shmat(425984, 0, 0) = 0x400cc000
shmctl(425984, IPC_RMID, 0xbffff698) = 0
mlock(0x400cc000) = 0

However, it doesn't.

Also, there are bugs in `strace`. This version (4.2) doesn't show
the length parameter passed to mlock() and the version distributed
with RH (4.4) shows two '0's instead of the length parameter.

Maybe mlock() and friends don't prevent paging, but
only prevent the pages from being written to swap?
Could somebody tell me how to keep memory from being
paged, i.e., in the processes` working-set all the time.

I have an application on an imbedded system that almost
works. It's frustrating. If I could keep the application's
pages resident it would work fine. If I mmap physical pages
the kernel doesn't know about, it works fine. But if I
try to do more "standard" stuff and use shared RAM, the
application gets far behind the data-rate and I'm screwed.

The kernel version is 2.4.24. Maybe it's broken?

Cheers,
Dick Johnson
Penguin : Linux version 2.4.24 on an i686 machine (797.90 BogoMips).
Note 96.31% of all statistics are fiction.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/