Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Recently while reading Linux internals I came across page cache and buffer cache. If I understand correctly buffer cache is used to cache the data buffers that are used by the block device drivers.These buffers are of fixed sizes (for example 512 bytes) and contain blocks of information that have either been read from a block device or are being written to it.
A page cache is used to speed up access to images and data on disk. It is used to cache the logical contents of a file a page at a time and is accessed via the file and offset within the file. As pages are read into memory from disk, they are cached in the page cache.
I don't understand the need for two caches. Assuming that the underlying filesystems block size is 512bytes Whenever I read some files from block device, I cache the contents of the blocks read (i.e., 512bytes) in the buffer cache.
Assuming that the page size is 1024 bytes (Page size and block size might be different??), whenever there is a read operation for memory mapped files then that page should be brought from disk in to page cache.If all the blocks (512bytes) of that page are in buffer cache then these blocks will be read from buffer cache and the corresponding page is cached in page cache?? otherwise the page is read from disk into the buffer cache.
one reason for having a buffer cache is to speed up the access of data and image files since one need not have to calculate the blocks required to read from disk (In other words no need for the 'bmap' algorithm), you can directly index into the buffer cache by vnode and offset.
I'd say that the two terms are probably interchangeable.
What you have here is a fairly general-purpose disk cache that knows how to keep information from several sources. (For example, pages from an executable program or library come from that library file.) A lot of the practical speed of the Linux system comes from its caching.
Last edited by sundialsvcs; 04-21-2008 at 07:48 AM.
There is no difference now because Linux uses a unified buffer cache. Historically the filesystem page cache used to be separate from the block device buffer cache, and this separation was probably inherited from 4.3BSD-style architectures. But in Linux the two were unified quite a long time ago, certainly by the time the ext2fs was written in 1994 since it is described as such in this paper from that era.
It is really important that any "Linux internals" texts that you may be reading must be extremely recent. Otherwise they probably aren't at all accurate anymore.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.