Bug#561203: threads and fork on machine with VIPT-WB cache
On Fri, 2010-04-02 at 11:41 +0900, NIIBE Yutaka wrote:
> (9) Process B does read-access on memory, which gets *NEW* data in
> cache (if process space identifier color is same).
> Process B does write-access on memory which causes memory fault,
> as it's COW memory.
>
> Note: Process B sees *NEW* data because it's VIPT-WB cache.
> It shares same memory in this situation.
So I think the bug here is that you're confusing aliasing with SMP cache
coherence. In an alias situation, the same physical line is mapped to
multiple lines in a processor's cache (at different virtual addresses),
which means you can get a different answer depending on which alias you
read.
In COW breaking, the page table entry is copied, so A and B no longer
have page table entries at the same physical location. If the COW is
intact, A and B have the same physical page, but it's also accessed by
the same virtual address, hence no aliasing.
In an SMP incoherent system, A and B could get different results (if on
different CPUs) because the write protect is in the cache of A but not
B. However, PA is SMP coherent, so the act of B reading a line which is
dirty in A's cache causes a flush before the read completes via the
cache chequerboard logic and B ends up reading the same value A would
have read.
James
Reply to: