Dentry cache (and inode)
The Linux file system subsystem has three levels. VFS (virtual file system), which implements the system call interface and processes intersecting mount points and default permissions and restrictions. Below are the drivers for individual file systems, and those which in turn interact with drivers for block devices (disks, memory cards, etc., Network interfaces are an exception).
Several classes are the interface between VFS and the file system (it’s just C, so structures containing pointers to functions, etc., but this is an object-oriented interface is conceptual). The main three classes are the inode , which describes any object (file or directory) in the dentry file system, which describes the entry in the directory and file , which describes the file opened by the process. When installed, the file system driver creates inode and dentry root for it, while others are created on demand when the process wants to access the file and, ultimately, expired. This is cache and inode.
Yes, this means that for every open file and any directory to the root there should be inode and dentry structures allocated in the memory core that represent it.
Page Cache
On Linux, each page of memory containing user area data is represented by a single page structure. This may mean that the page is anonymous (it can be replaced with a swap space, if available) or associate it with an inode on some file system (it can be written and re-read from the file system), and it can be part of any number of memory cards, that is, visible in the address space of some process. The sum of all pages loaded into memory is the page cache.
Pages are used to implement the mmap interface, and although regular system read and write calls can be implemented by the file system in other ways, most interfaces use a common function that also uses pages. There are common functions that, when requested to read a file, select pages and call the file system to fill them one by one. For a file system based on block devices, it simply calculates the corresponding addresses and delegates this filling to the block device driver.
ramdev (ramdisk)
Ramdev is a regular block device. This allows you to place any file system on top of it, but it is limited by the interface of the block device. And it only has methods to fill in the page highlighted by the caller and write it back. This is exactly what is necessary for real block devices, such as disks, memory cards, a USB storage device, etc., But for ramdisk this means that the data exists in memory twice, once in ramdev memory and once in memory allocated to the caller subscriber.
This is an old way to implement initrd . Since the time when initrd was a rare and exotic occurrence.
Tmpfs
Tmpfs is different. This is a dummy file system. The methods that it provides VFS are the absolute minimum minimum to make it work (as such, it perfectly documents what the inode, dentry, and file methods should do). Files exist only if the inode cache has the corresponding inode and dentry created when the file was created and never expired until the file was deleted. Pages are associated with files when data is written and otherwise behave as anonymous (data can be stored in swap, page structures remain in use as long as the file exists).
This means that there are no extra copies of data in memory, and all this is much simpler and because of this a little faster. It simply uses data structures that serve as a cache for any other file system as the main storage.
This is a new way to implement initrd ( initramfs , but the image is still just called initrd ).
It is also a way to implement "posix shared memory" (which simply means that tmpfs is mounted on /dev/shm , and applications can freely create files there and mmap, simple and efficient) and recently even /tmp and /run (or /var/run ) often have tmpfs specifically designed for laptops so that the disks cannot spin or avoid wear in the case of SSDs.