From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1AE99CA9EB5 for ; Mon, 21 Oct 2019 08:33:21 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D2019214AE for ; Mon, 21 Oct 2019 08:33:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D2019214AE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:35830 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iMT7w-0004nr-3A for qemu-devel@archiver.kernel.org; Mon, 21 Oct 2019 04:33:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54308) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iMT6y-0004Dg-Da for qemu-devel@nongnu.org; Mon, 21 Oct 2019 04:32:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iMT6x-0006bj-6g for qemu-devel@nongnu.org; Mon, 21 Oct 2019 04:32:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35106) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iMT6w-0006bL-VL for qemu-devel@nongnu.org; Mon, 21 Oct 2019 04:32:19 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 63C4A81DF1 for ; Mon, 21 Oct 2019 08:32:17 +0000 (UTC) Received: by mail-wr1-f71.google.com with SMTP id c6so6853493wrp.3 for ; Mon, 21 Oct 2019 01:32:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=22+CB66Y9RaGS1ZyijtNkan4x13wL2aw4SDXEvK9Bb8=; b=ktMpk80B5j79o39MABSNDAXXRevgAOQ90U/CiebtN57csz1fDyZABUluOdpmEDhVAC OY1eJDYfE925n2sOv5xBn9PKclsibo/ASG3LQ8bsXBDdRiLeRgoalhMN3F4sT1yykhtA BiiVfH4kT52DZHy5ezzW14jMEFBcu8uKDSRP2b0Yph2EOctY6RI4syjMvzpIEZVmcFMK O/fQZaJH8EGtDfLXzijHU5rK0P+9eLiKJ1dsmxVyd94Q7bOqwGfRRfXuj9L4kPHcVJLI vsQxSaBvPi18VH4YPI+g2c6jFRxfYqHU9jFbHwbNzw3S+2sIO3PIMonkTAjq/XsuQ73a +yFw== X-Gm-Message-State: APjAAAWD1GeH8lFX/cOs4bg/22P0e+lTZvCg6BSLXWxjVEv1e0EgUusF tYvtqaMSMngA6HHeQs0Y05huQBNS34wfk0O01WiqzmJqcaBRFoigY50XV8XtWKcuf5yW4MYpmNr FsqCI38jPSeCGotE= X-Received: by 2002:a1c:9ecf:: with SMTP id h198mr17766641wme.45.1571646735973; Mon, 21 Oct 2019 01:32:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqxiUgMnKvh05tfMegjr0956v//uObdMr3nrXhSJfSfS7i1kWinKYnb312ScQGxagqQwjl1z3g== X-Received: by 2002:a1c:9ecf:: with SMTP id h198mr17766581wme.45.1571646735627; Mon, 21 Oct 2019 01:32:15 -0700 (PDT) Received: from [192.168.1.41] (129.red-83-57-174.dynamicip.rima-tde.net. [83.57.174.129]) by smtp.gmail.com with ESMTPSA id u68sm17803100wmu.12.2019.10.21.01.32.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 21 Oct 2019 01:32:15 -0700 (PDT) Subject: Re: [PATCH 09/21] hw: Let memory_region_allocate_system_memory take MachineState argument To: Thomas Huth , Paolo Bonzini , Igor Mammedov , qemu-devel@nongnu.org, Markus Armbruster , Eduardo Habkost References: <20191020225650.3671-1-philmd@redhat.com> <20191020225650.3671-10-philmd@redhat.com> From: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= Message-ID: Date: Mon, 21 Oct 2019 10:32:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paul Burton , Peter Maydell , "Michael S. Tsirkin" , Leif Lindholm , Mark Cave-Ayland , KONRAD Frederic , "Edgar E. Iglesias" , Rob Herring , Andrey Smirnov , Helge Deller , =?UTF-8?Q?Herv=c3=a9_Poussineau?= , Joel Stanley , Aleksandar Rikalo , Richard Henderson , Artyom Tarasenko , Antony Pavlov , Alistair Francis , Fabien Chouteau , Beniamino Galvani , qemu-arm@nongnu.org, Peter Chubb , =?UTF-8?Q?C=c3=a9dric_Le_Goater?= , David Gibson , Radoslaw Biernacki , Thomas Huth , Andrew Baumann , Jean-Christophe Dubois , Andrew Jeffery , Michael Walle , qemu-ppc@nongnu.org, Aleksandar Markovic , Jan Kiszka , Aurelien Jarno Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On 10/21/19 9:27 AM, Thomas Huth wrote: > On 21/10/2019 00.56, Philippe Mathieu-Daud=C3=A9 wrote: >> All the codebase calls memory_region_allocate_system_memory() with >> a NULL 'owner' from the board_init() function. >=20 > It's a little bit weird that you first changed the owner to NULL in > patch 7, just to change the type of the parameter here and then change > the parameter back to the machine afterwards. I think I'd rather squash > pash 7 (and the follow-up patches like 14) into this one here - it's > just four files that need to be adapted, so I think that's still fine, > and finally that's less churn to be reviewed. I haven't thought of it and like your suggestion :) >> Let pass a MachineState argument, and enforce the QOM ownership of >> the system memory. >=20 > BTW, good idea! Thanks :) >=20 >> Signed-off-by: Philippe Mathieu-Daud=C3=A9 >> --- >> hw/core/numa.c | 11 +++++++---- >> include/hw/boards.h | 6 ++++-- >> 2 files changed, 11 insertions(+), 6 deletions(-) >> >> diff --git a/hw/core/numa.c b/hw/core/numa.c >> index 038c96d4ab..2e29e4bfe0 100644 >> --- a/hw/core/numa.c >> +++ b/hw/core/numa.c >> @@ -520,21 +520,24 @@ static void allocate_system_memory_nonnuma(Memor= yRegion *mr, Object *owner, >> vmstate_register_ram_global(mr); >> } >> =20 >> -void memory_region_allocate_system_memory(MemoryRegion *mr, Object *o= wner, >> +void memory_region_allocate_system_memory(MemoryRegion *mr, MachineSt= ate *ms, >> const char *name, >> uint64_t ram_size) >> { >> uint64_t addr =3D 0; >> int i; >> - MachineState *ms =3D MACHINE(qdev_get_machine()); >> + >> + if (!ms) { >> + ms =3D MACHINE(qdev_get_machine()); >> + } >> =20 >> if (ms->numa_state =3D=3D NULL || >> ms->numa_state->num_nodes =3D=3D 0 || !have_memdevs) { >> - allocate_system_memory_nonnuma(mr, owner, name, ram_size); >> + allocate_system_memory_nonnuma(mr, OBJECT(ms), name, ram_size= ); >> return; >> } >> =20 >> - memory_region_init(mr, owner, name, ram_size); >> + memory_region_init(mr, OBJECT(ms), name, ram_size); >> for (i =3D 0; i < ms->numa_state->num_nodes; i++) { >> uint64_t size =3D ms->numa_state->nodes[i].node_mem; >> HostMemoryBackend *backend =3D ms->numa_state->nodes[i].node= _memdev; >> diff --git a/include/hw/boards.h b/include/hw/boards.h >> index de45087f34..3b6cb82b6c 100644 >> --- a/include/hw/boards.h >> +++ b/include/hw/boards.h >> @@ -14,7 +14,7 @@ >> /** >> * memory_region_allocate_system_memory - Allocate a board's main me= mory >> * @mr: the #MemoryRegion to be initialized >> - * @owner: the object that tracks the region's reference count >> + * @ms: the #MachineState object that own the system memory >=20 > s/own/owns/ >=20 >> * @name: name of the memory region >> * @ram_size: size of the region in bytes >> * >> @@ -38,8 +38,10 @@ >> * Smaller pieces of memory (display RAM, static RAMs, etc) don't ne= ed >> * to be backed via the -mem-path memory backend and can simply >> * be created via memory_region_init_ram(). >> + * >> + * The #MachineState object will track the region's reference count. >> */ >> -void memory_region_allocate_system_memory(MemoryRegion *mr, Object *o= wner, >> +void memory_region_allocate_system_memory(MemoryRegion *mr, MachineSt= ate *ms, >> const char *name, >> uint64_t ram_size); >> =20 >> >=20 > Thomas >=20