vmtouch is definitely NOT going to manage this.
mmap(2) on the files you instruct it to.
Even if you get the kernel to cache
readdir(2), it's still a linear operation, and still hits disk in many cases:
In the current VFS readdir operation, the low-level
file system is always called, even if the entire directory is in
(2017/08/07 18:40 UTC followup):
ls -l does a lot more than just
readdir(2) is obsolete anyway,
readdir(3) is a wrapper for
(f)stat on the directory &
getdents on the directory. The
-l option of
ls also causes an
lstat on every entry in it.
getdents in itself is just a wrapper to whatever a given filesystem provides for the
.iterate pointers on directory file struct's operations. In the case of
ext4, this winds up down in
Some filesystems do implement caching at that layer (NFS is a very clear example), but others might hit disk still.
For the root of your original question, you could write some daemon that repeatedly keeps running
getdents on a given directory, but there's no way to pin those dentry items in the kernel cache otherwise, and it's possible that the kernel completely ignores that cache from a separate thread (depends on the filesystem).
ext4 for a moment, if the filesystem has the
dir_index feature, you can do
chattr +I dir on a directory to mark a directory as being htree-indexed (very small directories use that cache as well if the filesystem feature is set)