Posted Jan 28, 2010 17:18 UTC (Thu) by iabervon (subscriber, #722)
Parent article: fincore()
It seems to me like, once you're using both fadvise() and a non-portable syscall, you could inform the kernel in more detail about your actual usage pattern, and it could store the info and decide what to do. The system should be able to make good choices if you could tell the kernel, in order, the pages you intend to use (up until the kernel tells you it doesn't want to store any more hints for you), and have the kernel only prefetch up to where it can fit in memory, prefer to drop the ones which are further out (and likely newest rather than oldest), and remember what you've requested that isn't in memory such that when you drop your interest in the pages you've passed, it can prefetch new ones then.
It doesn't make sense to have a userspace heuristic for figuring out kernel limits when you need kernel support to implement it, particularly if the information you're getting only helps if you are right about the kernel's heuristics. Maybe the kernel will stop evicting pages that have been requested but not used when asked to prefetch more pages, and heuristics based on checking whether pages are in core and an assumption as to the kernel's use of the hints will give entirely wrong results.