It depends on the history of the mapping. mprotect() does not fault in
any new pages, it just changes permissions on page table entries already
present. So, if you're talking about a fresh mapping, or an area of a
mapping which has not yet been accessed, you're correct. And you're
correct if you're talking about a private mapping (which needs write
protection to do copy-on-write). But those aren't cases of concern here.
In general, there will already be some page table entries present,
and mprotect() from shared readonly to readwrite currently adds write
permission to those entries, and no write fault will then occur on
first write to those pages. I was suggesting that we'd need to change
that (to the behaviour you expect) if we were trying to guarantee disk
space for unbacked dirty pages (without allocating on read fault).
(I'm referring above to the implementation in Linux 2.4 or 2.5:
I've not checked other releases or OSes, which could indeed arrange
permissions so that there's always a page-dirtying fault.)
Hugh
-
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/