Subject: that VM/fs cache coherency problem
To: None <tech-kern@NetBSD.ORG>
From: der Mouse <mouse@Collatz.McRCIM.McGill.EDU>
List: tech-kern
Date: 07/31/1995 10:45:04
This buffer cache versus VM cache problem is biting me seriously now.
What would be involved in fixing it? At this point, I'd be willing to
take a fix that carries an efficiency penalty, perhaps even a serious
one, because the manifestation that's troubling me is much more
serious than weirdness with vi: tail -f on logfiles is coredumping.
(The problem seems to be related to tail's tendency to read the file
via mmap().)
What I'm seeing: I run a make with output and error redirected into a
file. After a while, I run tail -f on that file and it coredumps. I
built a copy of tail with -g and poked around with gdb; what's
happening is that the memory obtained with mmap() contains an old copy
of the file, ending partway through it (about 20% of the way in the
tests I did). Accesses to pages that are beyond the page containing
the last byte of the file produce errors in gdb, SIGBUS when done from
the process. Even running tail without -f does this.
But if I copy the file and tail the copy, it works fine.
As it stands, it seems to me that we simply cannot use mmap() on files
that might change...which wouldn't be such a problem if so many basic
utilities didn't use mmap(). Could someone point me towards the
relevant bits of code, so I can start hacking on things? I'm about
ready to do something like make any write to a file force a full
re-pagein of any memory objects backed by that file...it might impair
performance, but basic tools are breaking in sufficiently crippling
ways that I'll take even a serious performance hit for the sake of
making things start working again.
der Mouse
mouse@collatz.mcrcim.mcgill.edu