From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50705) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCOYC-0006BL-9M for qemu-devel@nongnu.org; Mon, 13 Jun 2016 05:52:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bCOYA-0004Ox-9S for qemu-devel@nongnu.org; Mon, 13 Jun 2016 05:52:55 -0400 References: <1465808915-4887-1-git-send-email-vijayak@caviumnetworks.com> <1465808915-4887-3-git-send-email-vijayak@caviumnetworks.com> From: Paolo Bonzini Message-ID: Date: Mon, 13 Jun 2016 11:52:42 +0200 MIME-Version: 1.0 In-Reply-To: <1465808915-4887-3-git-send-email-vijayak@caviumnetworks.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [RFC PATCH v1 2/4] exec.c: Remove static allocation of sub_section of sub_page List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: vijayak@caviumnetworks.com, qemu-arm@nongnu.org, peter.maydell@linaro.org, quintela@redhat.com Cc: qemu-devel@nongnu.org, Prasun.Kapoor@caviumnetworks.com, vijay.kilari@gmail.com, Vijaya Kumar K , Vijaya Kumar K On 13/06/2016 11:08, vijayak@caviumnetworks.com wrote: > From: Vijaya Kumar K >=20 > Allocate sub_section dynamically. Remove dependency > on TARGET_PAGE_SIZE to make run-time page size detection > for arm platforms. >=20 > Signed-off-by: Vijaya Kumar K > --- > exec.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) >=20 > diff --git a/exec.c b/exec.c > index a9d465b..e803a41 100644 > --- a/exec.c > +++ b/exec.c > @@ -154,7 +154,7 @@ typedef struct subpage_t { > MemoryRegion iomem; > AddressSpace *as; > hwaddr base; > - uint16_t sub_section[TARGET_PAGE_SIZE]; > + uint16_t *sub_section; Please make this a flexible array member instead, so that you can avoid the extra pointer dereference. Thanks, Paolo > } subpage_t; > =20 > #define PHYS_SECTION_UNASSIGNED 0 > @@ -1151,6 +1151,7 @@ static void phys_section_destroy(MemoryRegion *mr= ) > if (have_sub_page) { > subpage_t *subpage =3D container_of(mr, subpage_t, iomem); > object_unref(OBJECT(&subpage->iomem)); > + g_free(subpage->sub_section); > g_free(subpage); > } > } > @@ -2272,7 +2273,7 @@ static subpage_t *subpage_init(AddressSpace *as, = hwaddr base) > subpage_t *mmio; > =20 > mmio =3D g_malloc0(sizeof(subpage_t)); > - > + mmio->sub_section =3D g_malloc0(TARGET_PAGE_SIZE * sizeof(uint16_t= )); > mmio->as =3D as; > mmio->base =3D base; > memory_region_init_io(&mmio->iomem, NULL, &subpage_ops, mmio, >=20