Bart Samwel <bart@xxxxxxxxx> wrote:
When I saw this thread I've fiddled for a bit with the block_dump
functionality that's in the laptop_mode patch. I wanted to see if it
could support a similar thing completely from user space (except for the
block_dump code, of course). I've written a small tool to generate a
complete file that lists tuples (sector, size, device) from the kernel
output in syslog; it parses all "READ block xxx" messages since the
last reboot. Putting this through sort -n -u delivers a nicely sorted
file, ready for optimized reading.
Unfortunately I'm now stuck within the other part, which is reading the
pages back in memory at the next boot. It's not working, and I was hoping someone here could take a look and tell me what I'm doing wrong.
Linux caches disk data on a per-file basis. So if you preload pagecache
via the /dev/hda1 "file", that is of no benefit to the /etc/passwd file. Each one has its own unique pagecache. When reading pages for /etc/passwd
we don't go looking for the same disk blocks in the cache of /dev/hda1.
Which is why the userspace cache preloading needs to know the pathnames of
all the relevant files - it needs to open and read each one, applying
knowledge of disk layout while doing it.