Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 07 Aug 2003 11:06:46 -0400
From:      Ed L Cashin <ecashin@uga.edu>
To:        "Luoqi Chen" <lchen@briontech.com>
Cc:        hackers@freebsd.org
Subject:   Re: COW and mprotect on non-shared memory
Message-ID:  <87smodwlq1.fsf@uga.edu>
In-Reply-To: <AHEKICEOIHLOGINAFIINIEDICBAA.lchen@briontech.com> ("Luoqi Chen"'s message of "Wed, 6 Aug 2003 13:45:37 -0700")
References:  <AHEKICEOIHLOGINAFIINIEDICBAA.lchen@briontech.com>

next in thread | previous in thread | raw e-mail | index | archive | help
"Luoqi Chen" <lchen@briontech.com> writes:

[Ed writes]
>> That means that if I do this:
>> 
>>     for (i = 0; i < n; ++i) {
>>       assert(!mprotect(p, pgsiz, PROT_NONE));
>>       assert(!mprotect(p, pgsiz, PROT_READ|PROT_WRITE|PROT_EXEC));
>>       p[i] = i & 0xff;
>>     }
>> 
>> ... I get n minor page faults!  Pretty amazing, but I guess they
>> figured nobody does that.  

...
> The first mprotect() removes the physical mapping from the page
> table, the second mprotect() doesn't do anything because the mapping
> isn't there. So when the page is accessed, a fault is needed to
> insert the mapping back to the page table.

OK, thanks.  I can see that in sys/i386/i386/pmap.c.  It leaves me
wondering what MAP_ENTRY_COW is for, though.

-- 
--Ed L Cashin            |   PGP public key:
  ecashin@uga.edu        |   http://noserose.net/e/pgp/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?87smodwlq1.fsf>