From owner-freebsd-hackers@FreeBSD.ORG Thu Aug 7 08:06:48 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id ABFF137B401 for ; Thu, 7 Aug 2003 08:06:48 -0700 (PDT) Received: from marblerye.cs.uga.edu (marblerye.cs.uga.edu [128.192.101.172]) by mx1.FreeBSD.org (Postfix) with SMTP id 87C6943F75 for ; Thu, 7 Aug 2003 08:06:47 -0700 (PDT) (envelope-from ecashin@uga.edu) Received: (qmail 29553 invoked from network); 7 Aug 2003 15:06:46 -0000 Received: from localhost (HELO uga.edu) (127.0.0.1) by 0 with SMTP; 7 Aug 2003 15:06:46 -0000 To: "Luoqi Chen" From: Ed L Cashin Date: Thu, 07 Aug 2003 11:06:46 -0400 In-Reply-To: ("Luoqi Chen"'s message of "Wed, 6 Aug 2003 13:45:37 -0700") Message-ID: <87smodwlq1.fsf@uga.edu> User-Agent: Gnus/5.090014 (Oort Gnus v0.14) Emacs/21.2 (i386-debian-linux-gnu) References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii cc: hackers@freebsd.org Subject: Re: COW and mprotect on non-shared memory X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Aug 2003 15:06:49 -0000 "Luoqi Chen" 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/