LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 04-18-2008, 01:30 PM   #1
Nayaka
LQ Newbie
 
Registered: Dec 2007
Posts: 3

Rep: Reputation: 0
Difference between page cache and buffer cache


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.

Can somebody clarify this?
 
Old 04-19-2008, 04:17 AM   #2
traene
Member
 
Registered: Jan 2005
Distribution: Archlinux, Debian, Centos
Posts: 222

Rep: Reputation: 35
Maybe this can clarify a bit:
http://en.wikipedia.org/wiki/Swap_sp...ersus_swapping

A bit more information can be found here:
http://learnlinux.tsf.org.za/courses...nals/ch05.html
 
Old 04-19-2008, 04:46 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,125

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Same thing.
 
Old 04-21-2008, 07:46 AM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939
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.
 
Old 09-27-2011, 03:17 AM   #5
highlandsun
LQ Newbie
 
Registered: Jan 2005
Posts: 7

Rep: Reputation: 0
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.

http://e2fsprogs.sourceforge.net/ext2intro.html
 
Old 09-28-2011, 08:23 AM   #6
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Buffer cache jeesun Linux - Enterprise 1 10-07-2007 07:29 AM
buffer cache size gsr_kashyap Red Hat 6 09-18-2006 01:15 AM
minix buffer cache computer Linux - General 2 02-10-2006 06:09 AM
buffer cache in minix computer Linux - Newbie 1 02-09-2006 10:53 AM
file buffer cache jwstric2 Linux - General 2 06-30-2004 04:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 01:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration