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=-17.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,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 356BFC4338F for ; Thu, 19 Aug 2021 14:37:36 +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 D5B006112E for ; Thu, 19 Aug 2021 14:37:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D5B006112E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:42152 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGjAl-0001iH-3B for qemu-devel@archiver.kernel.org; Thu, 19 Aug 2021 10:37:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58480) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGjA1-0000Hv-Ka for qemu-devel@nongnu.org; Thu, 19 Aug 2021 10:36:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:27830) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGj9z-0002zc-VC for qemu-devel@nongnu.org; Thu, 19 Aug 2021 10:36:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629383807; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GnvmcR9nr2c0K4VyZDFjDiNXdISt6DLhK5k4CQjqItg=; b=GCL60cV14axgILeHn5Kzcqp2Yj6A23IXCY5yMtQwm9+mp6v0Hx1XwDT1Vb6HFO7Q+1fhzw N9nBlp6cVQs3Uip1YRh2MG/SXENhqO+s6JqaLsIwYHxOFi4tJuhY+zWsrykiAxXV8p8kMz 0lRH0pFM9vhvTKN/ynU9mZVADempQoA= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-131-GJG-TsF7OkiBCt3cWrrpGg-1; Thu, 19 Aug 2021 10:36:22 -0400 X-MC-Unique: GJG-TsF7OkiBCt3cWrrpGg-1 Received: by mail-wm1-f70.google.com with SMTP id w25-20020a1cf6190000b0290252505ddd56so1388854wmc.3 for ; Thu, 19 Aug 2021 07:36:22 -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=GnvmcR9nr2c0K4VyZDFjDiNXdISt6DLhK5k4CQjqItg=; b=h4sW/IUKBd++dY2S+wx4V+UtVv5bU/gt82b/HJQpIPmVjdm1Z68DbODaBczo64DHBD w+KyPQuzJaZsF7JNKofhhERgDcgSO5G6707dkLan2qkcb1nCamD4qMIgluVwx6JuTw0o yGmAQzKfLLqQsN0cBjUcIu9chbXah7DhckMVDikoW3Gom4aTGV7H+Nbfsu5uQgVABw6y dTChSEQtbliGz+Rp+/rlZD3hTkTjVVqriR1eAaMeYYtdHiA6QY+HK7KPC8uDAVdT+Bv1 8T63ogxG+0DLqy9HRoyFEzcGDe4TLgdTvKILyIrKalH4lFYqrMdoNr3MC0PwLVkue8MA Zf3w== X-Gm-Message-State: AOAM533O6Do6xwhyc3tu9Am9OqqSLZWX0I/ToVxmkiMtwS8BmyYFw9s6 rMJTsYpErKslYeDUO9mXwOPIn7chXrUwb4nzXoFs+kjI9/FjqY92XS/8z8EAh6V+AlveL+oguoj qx5XN52Y0HyyXbJk= X-Received: by 2002:a05:6000:1186:: with SMTP id g6mr4285993wrx.147.1629383781390; Thu, 19 Aug 2021 07:36:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz64NCWiWLLpTu5/xjyfbudxlx0ECkIwgsOR9cQygKorGm3dpvbJ+g7xMBcLhbg/hDQVnk6ug== X-Received: by 2002:a05:6000:1186:: with SMTP id g6mr4285975wrx.147.1629383781256; Thu, 19 Aug 2021 07:36:21 -0700 (PDT) Received: from [192.168.1.36] (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id d18sm3272562wrb.16.2021.08.19.07.36.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 19 Aug 2021 07:36:20 -0700 (PDT) Subject: Re: [PATCH 2/6] memory: Introduce address_space_create() To: Peter Maydell References: <20210819142039.2825366-1-philmd@redhat.com> <20210819142039.2825366-3-philmd@redhat.com> From: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= Message-ID: Date: Thu, 19 Aug 2021 16:36:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -60 X-Spam_score: -6.1 X-Spam_bar: ------ X-Spam_report: (-6.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-2.591, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: David Hildenbrand , Mark Cave-Ayland , Alistair Francis , Jianxian Wen , QEMU Developers , Peter Xu , qemu-arm , Gerd Hoffmann , "Edgar E. Iglesias" , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On 8/19/21 4:24 PM, Peter Maydell wrote: > On Thu, 19 Aug 2021 at 15:20, Philippe Mathieu-Daudé wrote: >> >> Introduce address_space_create(). In is similar to >> address_space_init() but returns a pointer to a heap >> allocated AddressSpace. >> >> Signed-off-by: Philippe Mathieu-Daudé >> --- >> include/exec/memory.h | 14 ++++++++++++++ >> softmmu/memory.c | 10 ++++++++++ >> 2 files changed, 24 insertions(+) >> >> diff --git a/include/exec/memory.h b/include/exec/memory.h >> index c3d417d317f..b353a48c25f 100644 >> --- a/include/exec/memory.h >> +++ b/include/exec/memory.h >> @@ -2418,6 +2418,20 @@ MemTxResult memory_region_dispatch_write(MemoryRegion *mr, >> */ >> void address_space_init(AddressSpace *as, MemoryRegion *root, const char *name); >> >> +/** >> + * address_space_create: Create and initializes an address space >> + * >> + * @root: a #MemoryRegion that routes addresses for the address space >> + * @name: an address space name. The name is only used for debugging >> + * output. >> + * >> + * Returns pointer to initialized #AddressSpace. >> + * >> + * The caller is responsible for releasing the pointer returned >> + * with address_space_destroy() after use. >> + */ >> +AddressSpace *address_space_create(MemoryRegion *root, const char *name); >> + > > I'm not really a fan of this as an API -- almost always I think > devices would do better to have an AddressSpace foo field in > their device struct and call address_space_init() on that. > Hiding the heap allocation inside this function makes it harder > to notice it during code review, I think. So I understand you rather I discard this (simple) approach and rather modify 'info mtree' "was designed on the assumption that there's really only one or two interesting address spaces." [*] [*] https://www.mail-archive.com/qemu-devel@nongnu.org/msg829821.html