Subject: Buffer cache oddities
To: None <tech-kern@NetBSD.ORG>
From: Thor Lancelot Simon <firstname.lastname@example.org>
Date: 12/10/1996 06:50:28
Apologies in advance to anyone who's sick of watching from a distance as I
dig through the buffer cache code; I never claimed to be well informed!
After spending most of the night reading through parts of the kernel source
in a diner I wanted a decent picture of what the _actual result_ of various
parts of the buffer cache code looked like on one of my typical systems here
at work. I built a kernel with DEBUG and turned on debug.syncprt with sysctl.
One of my suspicions was immediately confirmed: There are *NO* buffers larger
than 8K on my system, ever. The machine in question is a fairly small-memory
machine, so I have nbuf=bufpages; however, within a minute or so of runtime,
about 2/3 of the buffers are 8k, as I'd expect (all of my filesystems have 8K
blocks), and about 1/3 remain at 4K. This is the in-use buffers; the 8K
buffers have been created, of course, by stripping pages from other buffers;
at the default size of one page (4K, on the i386), this means that a lot of
buffers went away onto the EMPTY list.
Although diagrams in the 4.4 book seem to show much larger buffers than 8K,
after reading through vfs_bio.c a number of times I don't exactly understand
how such buffers would in fact be used, since buffers are indexed by
filesystem and logical block number. Were buffers larger than a filesystem
block to exist, how could one ensure that getblk() would in fact find the
buffer containing block X, if it's not the first block of the buffer? And
since getblk() doesn't return an offset into the buffer, how would one
_access_ such blocks?
It doesn't seem to matter, since the read-ahead code allocates a buffer per
block, so I can't see what would ever read in such a >8K buffer anyhow.
After running my system for about fifteen minutes doing a pretty heavy mix of
I/O (several compiles, a large CVS checkout, deliberately induced heavy
paging) I in fact still have no buffers larger than 8K.
I just did a bunch of dd's from raw (shouldn't do anything, right?) and block
devices with bs=16k and bs=64k. Still no buffers larger than 8K in the buffer
So what did increasing MAXBSIZE change, exactly? I must be misunderstanding
something very fundamental. Please humor me.
A more surprising revelation is that the AGE list is always empty. Again, is
this correct? Why?
If you've read this far, thanks.