Thread (25 messages) 25 messages, 4 authors, 2007-05-29

Re: [CFT] read+shared mmap write+read data corruption

From: James Bottomley <hidden>
Date: 2007-05-29 03:07:02

On Mon, 2007-05-28 at 16:39 +0200, Lennert Buytenhek wrote:
On Mon, May 28, 2007 at 09:17:55AM -0500, James Bottomley wrote:
quoted
quoted
quoted
Ok, output on parisc is:

jejb@ioz:~$ ./a.out
firstfirstfirst
firstfirstfirst
secondsecondsec

Which is correct.  It remains correct even if I drop the msync().
With Lennert's new program, I get mostly:

firstfirstfirst
firstfirstfirst
firstfirstfirst

but occasionally:

firstfirstfirst
firstfirstfirst
secondsecondsec

However, if I open code the memcpy() in the MAPREAD to copy one word
at a time, then I reliably get the "secondsecondsec" line.  But if I
convert the memcpy() in MAPWRITE in the same way, I'm back to mostly
getting the failure with the occasional success.  Utterly confused.

Unless someone's got a theory, I'm stumped.
I think you're not flushing correctly in munmap() ... but I'm not sure
the linux API actually requires this.
Having to (conditionally) invalidate the kernel direct mapping for
every userland page we unmap would kind of suck..
Lets just verify it is a stale kernel mapping first.  Try this patch: it
will cohere the kernel aliases but not the user ones, so if the problem
goes away its definitely a stale kernel alias rather than a dirty user
one.  Actually, I can't find a patch ... what I want is a
flush_kernel_dcache_page() before

		if (mapping_writably_mapped(mapping))
			flush_dcache_page(page);

But arm doesn't seem to implement the API ... you must have some
equivalent, though, if you can find it ... I think it's

 __cpuc_coherent_kern_range(lowmem_page_address(page), lowmem_page_address(page)+PAGE_SIZE);

But I'm not an arm expert.

James

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help