From owner-freebsd-hackers@FreeBSD.ORG Fri Dec 9 20:09:22 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org 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 3567616A41F for ; Fri, 9 Dec 2005 20:09:22 +0000 (GMT) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.208.78.105]) by mx1.FreeBSD.org (Postfix) with ESMTP id B486443D4C for ; Fri, 9 Dec 2005 20:09:21 +0000 (GMT) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.13.4/8.13.4) with ESMTP id jB9K9IX9030296; Fri, 9 Dec 2005 12:09:18 -0800 (PST) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.13.4/8.13.1/Submit) id jB9K9EcI030295; Fri, 9 Dec 2005 12:09:14 -0800 (PST) (envelope-from sgk) Date: Fri, 9 Dec 2005 12:09:14 -0800 From: Steve Kargl To: Dan Nelson Message-ID: <20051209200914.GA30276@troutmask.apl.washington.edu> References: <20051209010616.GA59667@troutmask.apl.washington.edu> <20051209040548.GD95420@dan.emsphone.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20051209040548.GD95420@dan.emsphone.com> User-Agent: Mutt/1.4.2.1i X-Mailman-Approved-At: Fri, 09 Dec 2005 20:39:27 +0000 Cc: freebsd-hackers@freebsd.org Subject: Re: sysctl, HW_PHYSMEM, and crippled gcc X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Dec 2005 20:09:22 -0000 On Thu, Dec 08, 2005 at 10:05:48PM -0600, Dan Nelson wrote: > In the last episode (Dec 08), Steve Kargl said: > > Anyone have any insight into fixing gcc to make better use of system > > memory on systems with more than 4 GB. It appears that > > libiberty/physmem.c tries to use sysctl() to determine the amount of > > physical memory in a system. > > > > { /* This works on *bsd and darwin. */ > > unsigned int physmem; > > size_t len = sizeof physmem; > > static int mib[2] = { CTL_HW, HW_PHYSMEM }; > > > > if (sysctl (mib, ARRAY_SIZE (mib), &physmem, &len, NULL, 0) == 0 > > && len == sizeof (physmem)) > > return (double) physmem; > > } > > > > This works if you have less than 4GB because of the unsigned int > > physmem. I have 12 GB, which of course, when expanded to the number > > of bytes doesn't fit into a unsigned int physmem. > > physmem is actually an unsigned long, not an unsigned int, so on amd64 > that sysctl call should fail anyway (amd64 is LP64, so a long won't fit > into an int). I changed "unsigned int physmem;" to "size_t physmem;". Now, the 12 GB are recognized. > > gcc version 3.4.4 [FreeBSD] 20050518 > > GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 > > > > In particular, ggc-min-heapsize=4096 is ridiculously small for a > > system with 12 GB of memory. > > On all my FreeBSD boxes from 128MB to 1GB of RAM, I get the exact same > heuristic values as you, so I'm not sure whether the code works at all. I forced physmem to be 8196 and recompiled gcc. For whatever reason, ggc-min-heapsize=4096 was still reported, but my compiling problems disappeared. I think you may be right about the code not doing working as the programmer may have thought. -- Steve