From owner-freebsd-hackers Sun Nov 11 1:39:52 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by hub.freebsd.org (Postfix) with ESMTP id 50B9C37B41A for ; Sun, 11 Nov 2001 01:39:49 -0800 (PST) Received: (from dillon@localhost) by apollo.backplane.com (8.11.6/8.9.1) id fAB9dmU45444; Sun, 11 Nov 2001 01:39:48 -0800 (PST) (envelope-from dillon) Date: Sun, 11 Nov 2001 01:39:48 -0800 (PST) From: Matthew Dillon Message-Id: <200111110939.fAB9dmU45444@apollo.backplane.com> To: David Xu Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: Found some unnecessary code References: <20011111075324.72482.qmail@web20906.mail.yahoo.com> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG :Found some unnecessary code in FreeBSD 4.4-stable VM. : :File vm_page.c, in function vm_page_startup(), vm_page :bucket is :zeroed two times, this is unnecessary. : :--- vm_page.c Sun Nov 11 15:34:41 2001 :+++ vm_page.c.orig Sun Nov 11 15:34:21 2001 :@@ -265,6 +265,11 @@ : vaddr = round_page(vaddr); : bzero((caddr_t) mapped, vaddr - mapped); : :+ for (i = 0; i < vm_page_bucket_count; i++) { :+ *bucket = NULL; :+ bucket++; :+ } :+ Hmm. That code has been through a lot. The buckets were originally a doubly-linked list requiring initialization, but I turned them into a singly-linked list in early 1999. It's somewhat of a fluke that the bzero even covers the proper area, because 'mapped' just happens to be equal to 'vaddr' due to the fact that vaddr has already been rounded up. But it isn't explicit. We could probably cleanup the code but we'd have to make the mapped/vaddr matchup explicit to really be able to depend on the bzero() (or some programmer might come along later and break it). : * Compute the number of pages of memory that will :be available for : * use (taking into account the overhead of a page :structure per : : : :File vm_object.c, function vm_object_backing_scan() :calling :vm_page_deactivate() is unnecessary, this is already :done in :vm_page_rename(). : : :--- vm_object.c.orig Sun Nov 11 15:35:22 2001 :+++ vm_object.c Sun Nov 11 15:35:42 2001 :@@ -1159,9 +1159,6 @@ : * If the page was mapped to a process, it can :remain : * mapped through the rename. : */ :- if ((p->queue - p->pc) == PQ_CACHE) :- vm_page_deactivate(p); :- : vm_page_rename(p, object, new_pindex); : /* page automatically made dirty by rename */ : } : :-- :David Xu This looks reasonable. This is also left-over cruft from older versions of the code. A bunch of stuff was collapsed into vm_page_rename(). -Matt Matthew Dillon To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message