From owner-freebsd-hackers@FreeBSD.ORG Sat Dec 10 02:07:38 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 6435216A422 for ; Sat, 10 Dec 2005 02:07:38 +0000 (GMT) (envelope-from keramida@linux.gr) Received: from kane.otenet.gr (kane.otenet.gr [195.170.0.95]) by mx1.FreeBSD.org (Postfix) with ESMTP id 33C1643D4C for ; Sat, 10 Dec 2005 02:07:36 +0000 (GMT) (envelope-from keramida@linux.gr) Received: from flame.pc (patr530-a085.otenet.gr [212.205.215.85]) by kane.otenet.gr (8.13.4/8.13.4/Debian-8) with ESMTP id jBA27XML004622; Sat, 10 Dec 2005 04:07:33 +0200 Received: by flame.pc (Postfix, from userid 1001) id 8487F11551; Sat, 10 Dec 2005 04:06:43 +0200 (EET) Date: Sat, 10 Dec 2005 04:06:43 +0200 From: Giorgos Keramidas To: babkin@users.sourceforge.net Message-ID: <20051210020643.GA6206@flame.pc> References: <10939303.1134158545675.JavaMail.root@vms070.mailsrvcs.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <10939303.1134158545675.JavaMail.root@vms070.mailsrvcs.net> Cc: freebsd-hackers@freebsd.org, Divacky Roman Subject: Re: 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: Sat, 10 Dec 2005 02:07:38 -0000 On 2005-12-09 14:02, Sergey Babkin wrote: >Divacky Roman wrote: >>On Thu, Dec 08, 2005 at 05:06:16PM -0800, Steve Kargl wrote: >>> 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. > >>> In particular, ggc-min-heapsize=4096 is ridiculously small for a >>> system with 12 GB of memory. >> >> the code works here (512M of memory)... dont know about the ifdefs its >> surrounded by.. > > I guess you've confused M and G :-) The point is that > it breaks with over 4G of memory. Can someone with access to a system with more than 4 GB verify that the following works correctly? % flame:/home/keramida/tmp/physmem$ cat -n physmem.c % 1 #include % 2 #include % 3 % 4 #include % 5 #include % 6 #include % 7 #include % 8 % 9 int % 10 main(void) % 11 { % 12 uint64_t physmem; % 13 size_t len = sizeof physmem; % 14 static int mib[] = { CTL_HW, HW_PHYSMEM }; % 15 static size_t miblen = sizeof(mib) / sizeof(mib[0]); % 16 % 17 if (sysctl(mib, miblen, &physmem, &len, NULL, 0) != 0) % 18 err(1, "sysctl hw.physmem"); % 19 printf("Physical memory = %ju bytes\n", (intmax_t)physmem); % 20 return EXIT_SUCCESS; % 21 } % flame:/home/keramida/tmp/physmem$ ./physmem % Physical memory = 526151680 bytes % flame:/home/keramida/tmp/physmem$ Then we can probably try to push a similar change towards the libiberty developers too, unless there are serious problems with supporting uint64_t on some of the platforms that libiberty needs to run on.