qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org,
	David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [Qemu-devel] [PATCH] memory: give name every AddressSpace
Date: Mon, 29 Apr 2013 10:16:28 +0200	[thread overview]
Message-ID: <517E2C5C.8000700@redhat.com> (raw)
In-Reply-To: <1367201460-28594-1-git-send-email-aik@ozlabs.ru>

Il 29/04/2013 04:11, Alexey Kardashevskiy ha scritto:
> The "info mtree" command in QEMU console prints only "memory" and "I/O"
> address spaces while there are actually a lot more other AddressSpace
> structs created by PCI and VIO devices. Those devices do not normally
> have names and therefore not present in "info qtree" output.
> 
> The patch fixes this.
> 
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
> 
> 
> The number of AddressSpace structs is constantly growing (even without IOMMU)
> and it is getting harder to trace them so this is why I came up with this patch.
> Or there is a reason to hide those AddressSpace structs which I do not see,
> is not it?
> 
> 
> ---
>  exec.c                |    6 ++----
>  hw/pci/pci.c          |    3 ++-
>  hw/ppc/spapr_vio.c    |    2 +-
>  include/exec/memory.h |    2 +-
>  memory.c              |    7 ++++---
>  5 files changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/exec.c b/exec.c
> index 180a345..0091272 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -1839,13 +1839,11 @@ static void memory_map_init(void)
>  {
>      system_memory = g_malloc(sizeof(*system_memory));
>      memory_region_init(system_memory, "system", INT64_MAX);
> -    address_space_init(&address_space_memory, system_memory);
> -    address_space_memory.name = "memory";
> +    address_space_init(&address_space_memory, system_memory, "memory");
>  
>      system_io = g_malloc(sizeof(*system_io));
>      memory_region_init(system_io, "io", 65536);
> -    address_space_init(&address_space_io, system_io);
> -    address_space_io.name = "I/O";
> +    address_space_init(&address_space_io, system_io, "I/O");
>  
>      memory_listener_register(&core_memory_listener, &address_space_memory);
>      memory_listener_register(&io_memory_listener, &address_space_io);
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index fe146dc..0a1acd6 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -823,7 +823,8 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
>      memory_region_init_alias(&pci_dev->bus_master_enable_region, "bus master",
>                               pci_dev->iommu, 0, memory_region_size(pci_dev->iommu));
>      memory_region_set_enabled(&pci_dev->bus_master_enable_region, false);
> -    address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region);
> +    address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region,
> +                       name);
>  
>      pci_dev->devfn = devfn;
>      pstrcpy(pci_dev->name, sizeof(pci_dev->name), name);
> diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c
> index fbcbd6f..fadde20 100644
> --- a/hw/ppc/spapr_vio.c
> +++ b/hw/ppc/spapr_vio.c
> @@ -449,7 +449,7 @@ static int spapr_vio_busdev_init(DeviceState *qdev)
>      if (pc->rtce_window_size) {
>          uint32_t liobn = SPAPR_VIO_BASE_LIOBN | dev->reg;
>          dev->tcet = spapr_tce_new_table(liobn, pc->rtce_window_size);
> -        address_space_init(&dev->as, spapr_tce_get_iommu(dev->tcet));
> +        address_space_init(&dev->as, spapr_tce_get_iommu(dev->tcet), qdev->id);
>      }
>  
>      return pc->init(dev);
> diff --git a/include/exec/memory.h b/include/exec/memory.h
> index 99d51b7..b4f1182 100644
> --- a/include/exec/memory.h
> +++ b/include/exec/memory.h
> @@ -840,7 +840,7 @@ void mtree_info(fprintf_function mon_printf, void *f);
>   * @as: an uninitialized #AddressSpace
>   * @root: a #MemoryRegion that routes addesses for the address space
>   */
> -void address_space_init(AddressSpace *as, MemoryRegion *root);
> +void address_space_init(AddressSpace *as, MemoryRegion *root, const char *name);
>  
>  

Please update the doc comment.

>  /**
> diff --git a/memory.c b/memory.c
> index cee3e59..b50f5e6 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -1002,7 +1002,7 @@ void memory_region_init_iommu(MemoryRegion *mr,
>      mr->terminates = true;  /* then re-forwards */
>      mr->destructor = memory_region_destructor_iommu;
>      mr->iommu_target_as = g_new(AddressSpace, 1);
> -    address_space_init(mr->iommu_target_as, target);
> +    address_space_init(mr->iommu_target_as, target, name);
>  }
>  
>  static uint64_t invalid_read(void *opaque, hwaddr addr,
> @@ -1599,7 +1599,7 @@ void memory_listener_unregister(MemoryListener *listener)
>      QTAILQ_REMOVE(&memory_listeners, listener, link);
>  }
>  
> -void address_space_init(AddressSpace *as, MemoryRegion *root)
> +void address_space_init(AddressSpace *as, MemoryRegion *root, const char *name)
>  {
>      memory_region_transaction_begin();
>      as->root = root;
> @@ -1608,7 +1608,7 @@ void address_space_init(AddressSpace *as, MemoryRegion *root)
>      as->ioeventfd_nb = 0;
>      as->ioeventfds = NULL;
>      QTAILQ_INSERT_TAIL(&address_spaces, as, address_spaces_link);
> -    as->name = NULL;
> +    as->name = g_strdup(name?name:"anonymous");
>      address_space_init_dispatch(as);
>      memory_region_update_pending |= root->enabled;
>      memory_region_transaction_commit();
> @@ -1623,6 +1623,7 @@ void address_space_destroy(AddressSpace *as)
>      QTAILQ_REMOVE(&address_spaces, as, address_spaces_link);
>      address_space_destroy_dispatch(as);
>      flatview_destroy(as->current_map);
> +    g_free((void *)as->name);

No cast here.

Paolo

>      g_free(as->current_map);
>      g_free(as->ioeventfds);
>  }
> 

  reply	other threads:[~2013-04-29  8:16 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-26  6:02 [Qemu-devel] [0/4] RFC: Preparations for VFIO and guest IOMMUs (v2) David Gibson
2013-04-26  6:02 ` [Qemu-devel] [PATCH 1/4] Fix vmw_pvscsi.c for iommu support changes David Gibson
2013-04-26  8:19   ` Paolo Bonzini
2013-04-26 11:04     ` David Gibson
2013-04-26  6:02 ` [Qemu-devel] [PATCH 2/4] vfio: Associate VFIO groups with (guest) IOMMU address spaces David Gibson
2013-04-26  6:02 ` [Qemu-devel] [PATCH 3/4] vfio: Move container list to iommu MemoryRegion David Gibson
2013-04-26  8:23   ` Paolo Bonzini
2013-04-26 11:31     ` David Gibson
2013-04-26 13:40       ` Paolo Bonzini
2013-04-27  9:49         ` David Gibson
2013-04-27 12:17           ` Paolo Bonzini
2013-04-28  1:58             ` David Gibson
2013-04-29  8:11               ` Paolo Bonzini
2013-04-29 11:00                 ` David Gibson
2013-04-29 11:38                   ` Paolo Bonzini
2013-04-29 11:56                     ` David Gibson
2013-04-29 13:44                       ` Paolo Bonzini
2013-04-30  2:05                         ` David Gibson
2013-04-30  2:23                           ` David Gibson
2013-04-30  7:30                             ` Paolo Bonzini
2013-04-30  7:54                               ` David Gibson
2013-04-29  2:11             ` [Qemu-devel] [PATCH] memory: give name every AddressSpace Alexey Kardashevskiy
2013-04-29  8:16               ` Paolo Bonzini [this message]
2013-04-29  8:21                 ` Alexey Kardashevskiy
2013-04-29  9:25                   ` Paolo Bonzini
2013-04-29 11:09                     ` David Gibson
2013-04-30  2:14                     ` Alexey Kardashevskiy
2013-04-26  6:02 ` [Qemu-devel] [PATCH 4/4] vfio: Only use memory listeners when appropriate David Gibson
2013-04-26 15:42 ` [Qemu-devel] [0/4] RFC: Preparations for VFIO and guest IOMMUs (v2) Alex Williamson
2013-04-27  9:51   ` David Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=517E2C5C.8000700@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=aik@ozlabs.ru \
    --cc=david@gibson.dropbear.id.au \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).