On Wed, Sep 29, 2021 at 02:07:42PM -0400, Noel Chiappa wrote:
From: Larry
McVoy
If you read(2) a page and mmap()ed it and then
did a write(2) to the
page, the mapped page is the same physical memory as the write()ed
page. Zero coherency issues.
Now I'm confused; read() and write() semantically include a copy operation
(so there are then two copies of that data chunk, and possible consistency
issues between them), and the copied item is not necessarily page-sized (so
you can't ensure consistency between the original+copy by mapping it in). So
when one does a read(file, &buffer, 1), one gets a _copy of just that byte_
in the process' address space (and similar for write()).
Yes, there's no coherency issue between the contents of an mmap()'d page, and
the system's idea of what's in that page of the file, but that's a
_different_ coherency issue.
That "different" coherency issue is the one I was talking about. SunOS
got rid of it, when HP-UX etc grudgingly implemented mmap() they did not
have a unified page cache, they had pages that were mmapped but the data
was copied from the buffer cache. It was a mess for years and years.