Messages in this thread Patch in this message | | | Date | Thu, 4 Sep 2003 18:26:39 +0100 | From | Jamie Lokier <> | Subject | Re: [PATCH] Alternate futex non-page-pinning and COW fix |
| |
Linus Torvalds wrote: > The only person who should ever test VM_MAYSHARE is somebody who does > reporting back to user space: VM_MAYSHARE basically ends up meaning "the > user _asked_ for a shared mapping". While "VM_SHARED" means "this mapping > can actually contain a shared dirty page".
Precisely. And for futex, the correct meaning is "the user asked for a shared mapping": a FUTEX_WAIT on a shared mapping of a file opened read-only _should_ be woken by a FUTEX_WAKE on the same file by another process.
> The VM itself should only ever care about VM_SHARED. Because that's the > only bit that has real semantic meaning.
remap_file_pages() returns -EINVAL on mappings of read-only file handles because it tests VM_SHARED. There is no good reason not to remap a read-only file - it doesn't complain about remapping a PROT_READ mapping of a writable file!
Patch tested and attached.
Enjoy, -- Jamie
Subject: [PATCH] Allow remap_file_pages() on read-only files Patch: nonlinear-mayshare-2.6.0-test4-02.2jl
This changes remap_file_pages() to work on mappings of read-only file handles. Without this it returns -EINVAL.
diff -urN --exclude-from=dontdiff orig-2.6.0-test4/mm/fremap.c nonlinear-2.6.0-test4/mm/fremap.c --- orig-2.6.0-test4/mm/fremap.c 2003-07-08 21:44:29.000000000 +0100 +++ nonlinear-2.6.0-test4/mm/fremap.c 2003-09-04 18:19:45.000000000 +0100 @@ -145,10 +145,11 @@ vma = find_vma(mm, start); /* * Make sure the vma is shared, that it supports prefaulting, - * and that the remapped range is valid and fully within - * the single existing vma: + * and that the remapped range is valid and fully within the + * single existing vma. VM_MAYSHARE is checked (not VM_SHARED) + * so that read-only files can be remapped too: */ - if (vma && (vma->vm_flags & VM_SHARED) && + if (vma && (vma->vm_flags & VM_MAYSHARE) && vma->vm_ops && vma->vm_ops->populate && end > start && start >= vma->vm_start && end <= vma->vm_end) - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |