Keep a file in memory an any cost

Bryn M. Reeves bmr at redhat.com
Wed May 11 18:56:06 UTC 2011


On 05/11/2011 07:47 PM, JD wrote:
> On 05/11/11 11:19, Alain Spineux wrote:
>> Hello I have a file, that is an index, it is open all the time by the
>> application,
>> but sometime the access are slow because the file was moved out of the cache.
>>
>> How can I keep it in memory all the time ?
>> I can read it at regular interval, but this is a little over kill ?
>>
>> Any idea
>>
>> thanks.
>>
>>
> There is a kernel facility that nails pages to memory so that
> they are not paged out (such as for DMA purposes).
> But I do not know if such a facility is accessible directly from
> any userland calls via libc.
> BSD used to have a vadvise() call to accomplish such a feat.
> 

Linux has the madvise/posix_madvise calls. But madvise and friends are just that
- advisory. The kernel is free to ignore the advice if it likes. If you need
guarantees you want mlock/mlockall.

Regards,
Bryn.



More information about the users mailing list