From owner-freebsd-hackers Sun Nov 16 17:05:13 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id RAA28258 for hackers-outgoing; Sun, 16 Nov 1997 17:05:13 -0800 (PST) (envelope-from owner-freebsd-hackers) Received: from dyson.iquest.net (dyson.iquest.net [198.70.144.127]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id RAA28245 for ; Sun, 16 Nov 1997 17:05:06 -0800 (PST) (envelope-from toor@dyson.iquest.net) Received: (from root@localhost) by dyson.iquest.net (8.8.7/8.8.5) id UAA26711; Sun, 16 Nov 1997 20:04:55 -0500 (EST) From: "John S. Dyson" Message-Id: <199711170104.UAA26711@dyson.iquest.net> Subject: Re: Is fork() copy-on-write ? In-Reply-To: from Charles Mott at "Nov 16, 97 05:19:07 pm" To: cmott@srv.net (Charles Mott) Date: Sun, 16 Nov 1997 20:04:54 -0500 (EST) Cc: hackers@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL31 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk Charles Mott said: > I was curious to know when a process is forked, are the new vm pages which > are created copy-on-write? > > [I know, I know I should just go look at the source code, but I haven't > quite got up the nerve to start looking at that area. It is sort of like > peering over a cliff into an infinite abyss.] > In the FreeBSD kernel, ALL pages that can be COW are COW -- if anyone finds the contrary PLEASE tell me ASAP (and I'll fix it.) One of the original problems in the BSD 4.4VM, fixed in FreeBSD, was that originally, during a fork, as many as three (3) pages would exist for every page COW after a fork. We have reduced that to two (2) in the normal case. Of course, that is what is expected, but when figuring out what that code does, expect the unexpected!!! :-). (Note that many versions of UNIX don't bother COW on modified .data actually performing explicit copies for .data pages, but the FreeBSD/Mach VM doesn't do any unnecessary copies.) -- John dyson@freebsd.org jdyson@nc.com