From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KLTXI-0004lX-1V for qemu-devel@nongnu.org; Tue, 22 Jul 2008 21:53:00 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KLTXG-0004lK-JK for qemu-devel@nongnu.org; Tue, 22 Jul 2008 21:52:59 -0400 Received: from [199.232.76.173] (port=56531 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KLTXG-0004lH-Gn for qemu-devel@nongnu.org; Tue, 22 Jul 2008 21:52:58 -0400 Received: from an-out-0708.google.com ([209.85.132.240]:56114) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KLTXG-0002yM-31 for qemu-devel@nongnu.org; Tue, 22 Jul 2008 21:52:58 -0400 Received: by an-out-0708.google.com with SMTP id d18so851243and.130 for ; Tue, 22 Jul 2008 18:52:57 -0700 (PDT) Message-ID: <48868EDB.7010809@codemonkey.ws> Date: Tue, 22 Jul 2008 20:52:27 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] Save 3MB ioport table memory References: <20080721120211.GD4501@implementation.uk.xensource.com> In-Reply-To: <20080721120211.GD4501@implementation.uk.xensource.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit 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 Cc: Samuel Thibault Samuel Thibault wrote: > Hello, > > On 64bit machines, qemu uses 3MB of memory for the ioport tables, while > the actual use of them is quite sparse. The patch below saves that > memory by leaving them zeroed and just test for that and use the default > pointer. > I really like the idea of this patch. You have some whitespace damage (tabs instead of 8 spaces) and it needs a Signed-off-by: if you'd like me to apply it. > Samuel > > Index: vl.c > =================================================================== > --- vl.c (révision 4917) > +++ vl.c (copie de travail) > @@ -279,17 +279,29 @@ > static uint32_t default_ioport_readw(void *opaque, uint32_t address) > { > uint32_t data; > - data = ioport_read_table[0][address](ioport_opaque[address], address); > + IOPortReadFunc *func = ioport_read_table[0][address]; > + if (!func) > + func = default_ioport_readb; > Perhaps you can introduce an accessor? Something like: static uint32_t ioport_read_defaults(void *opaque, int index, uint32_t address) { static IOPortReadFunc *default_funcs[3] = {default_ioport_readb, default_ioport_readw, default_ioport_readl}; IOPortReadFunc *func = ioport_read_table[index][address]; if (!func) func = default_funcs[index]; return func(opaque, address); } That would simplify the rest of the changes significantly. Regards, Anthony Liguori