From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Iu8dn-0007eZ-B9 for qemu-devel@nongnu.org; Mon, 19 Nov 2007 10:34:27 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Iu8dl-0007eI-BA for qemu-devel@nongnu.org; Mon, 19 Nov 2007 10:34:26 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Iu8dl-0007eD-8g for qemu-devel@nongnu.org; Mon, 19 Nov 2007 10:34:25 -0500 Received: from smtp.citrix.com ([66.165.176.89]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Iu8dk-0004X3-S1 for qemu-devel@nongnu.org; Mon, 19 Nov 2007 10:34:25 -0500 Received: from gw-uk.xensource.com (wiley.uk.xensource.com [172.31.0.37]) by smtp01.ad.xensource.com (8.13.1/8.13.1) with ESMTP id lAJFYL5W003814 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 19 Nov 2007 07:34:23 -0800 Received: from dhcp-16-192.uk.xensource.com ([172.31.16.192] helo=implementation.famille.thibault.fr) by gw-uk.xensource.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.43) id 1Iu8dh-0005bQ-Fk for qemu-devel@nongnu.org; Mon, 19 Nov 2007 15:34:21 +0000 Received: from samy by implementation.famille.thibault.fr with local (Exim 4.68) (envelope-from ) id 1Iu8dh-0004HY-EY for qemu-devel@nongnu.org; Mon, 19 Nov 2007 16:34:21 +0100 Date: Mon, 19 Nov 2007 15:34:21 +0000 From: Samuel Thibault Message-ID: <20071119153421.GH6331@implementation.uk.xensource.com> References: <20071119152016.GE6331@implementation.uk.xensource.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="pWyiEgJYm5f9v55/" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20071119152016.GE6331@implementation.uk.xensource.com> Subject: [Qemu-devel] Re: memory usage and ioports Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --pWyiEgJYm5f9v55/ Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit Samuel Thibault, le Mon 19 Nov 2007 15:20:16 +0000, a écrit : > Qemu currently uses 6 65k tables of pointers for handling ioports, which > makes 3MB on 64bit machines. There's a comment that says "XXX: use a two > level table to limit memory usage". But wouldn't it be more simple and > effective to just allocate them through mmap() and when a NULL pointer > is read, call the default handlers? For the ioport_opaque array (500KB on 64bit), it's much simpler, as the attached patch suggests. Samuel --pWyiEgJYm5f9v55/ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=patch diff -r 6a6eace79e93 tools/ioemu/vl.c --- qemu/vl.c Mon Nov 19 15:04:05 2007 +0000 +++ qemu/vl.c Mon Nov 19 15:31:35 2007 +0000 @@ -139,7 +139,7 @@ const char *bios_dir = CONFIG_QEMU_SHAREDIR; char phys_ram_file[1024]; -void *ioport_opaque[MAX_IOPORTS]; +void **ioport_opaque; IOPortReadFunc *ioport_read_table[3][MAX_IOPORTS]; IOPortWriteFunc *ioport_write_table[3][MAX_IOPORTS]; /* Note: bs_table[MAX_DISKS] is a dummy block driver if none available @@ -265,6 +265,7 @@ void init_ioports(void) { int i; + ioport_opaque = malloc(MAX_IOPORTS * sizeof(*ioport_opaque)); for(i = 0; i < MAX_IOPORTS; i++) { ioport_read_table[0][i] = default_ioport_readb; ioport_write_table[0][i] = default_ioport_writeb; --pWyiEgJYm5f9v55/--