Skip to contentSkip to conversation

Proposed changes to flush_dcache_page to fix our shared ro mapping problem

parisc-linux James Bottomley 1 participant 1 message Aug 23, 2003 PA-RISC architecture

lore
Share & tools
lore
#0 lore raw

The attached should do it

(plus the fix to preserve the VM_MAYSHARE flag on remap).

I've verified that this fixes the glibc tst-mmap-eofsync test.

James

===== arch/parisc/kernel/cache.c 1.4 vs edited =====

arch/parisc/kernel/cache.c +29 -1
@@ -232,7 +232,8 @@
 
 	if (!page->mapping)
 		return;
-
+	/* check shared list first if it's not empty...it's usually
+	 * the shortest */
 	list_for_each(l, &page->mapping->i_mmap_shared) {
 		struct vm_area_struct *mpnt;
 		unsigned long off;
@@ -243,6 +244,33 @@
 		 * If this VMA is not in our MM, we can ignore it.
 		 */
 		if (mpnt->vm_mm != mm)
+			continue;
+
+		if (page->index < mpnt->vm_pgoff)
+			continue;
+
+		off = page->index - mpnt->vm_pgoff;
+		if (off >= (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT)
+			continue;
+
+		flush_cache_page(mpnt, mpnt->vm_start + (off << PAGE_SHIFT));
+
+		/* All user shared mappings should be equivalently mapped,
+		 * so once we've flushed one we should be ok
+		 */
+		return;
+	}
+
+	/* then check private mapping list for read only shared mappings
+	 * which are flagged by VM_MAYSHARE */
+	list_for_each(l, &page->mapping->i_mmap) {
+		struct vm_area_struct *mpnt;
+		unsigned long off;
+
+		mpnt = list_entry(l, struct vm_area_struct, shared);
+
+
+		if (mpnt->vm_mm != mm || !(mpnt->vm_flags & VM_MAYSHARE))
 			continue;
 
 		if (page->index < mpnt->vm_pgoff)