Subject: Re: Do some disk accesses miss the UVM?
To: David Laight <>
From: Alasdair Baird <>
List: tech-kern
Date: 01/24/2002 21:12:39
 > The buffer cache (currently the default 13Mb) is large enough that 'find
 > . | wc' leaves all the data it wants cached,  however 'du -s .' has to
 > access the disk.  I can't see how the latter requires access to any more
 > data.

Metadata (inodes) still lives in the old buffer cache, IIRC.

As to how 13Mb can easily be consumed, one answer is fragmentation.  As the
minimum allocation within the buffer cache is one machine page (4k on ix86)
and there may be a need to read in a single 512 byte sector to access one
single inode, we suddenly have a situation where memory is not used being
used terribly efficiently.  Such is life.

 > FWIW I've found this snippet of code in brelse() (kern/vfs_bio.c):
 >                 if (bp->b_vp) {
 >                         reassignbuf(bp, bp->b_vp);
 >                         brelvp(bp);
 >                 }
 > I can't see the point of the reassignbuf() at all - even if it weren't
 > followed by a brelvp() call, which makes it particularly pointless.

That bit of code can be arrived at if there was an error performing I/O (see
the handling of B_ERROR some lines up).  It is just checking if the buffer
is still associated with a device's vnode and, if so, taking action to grab
it back.