[{"id":1914791,"web_url":"http://patchwork.ozlabs.org/comment/1914791/","msgid":"<17437758-3b51-72c7-81ba-cb0df0a22c1c@redhat.com>","list_archive_url":null,"date":"2018-05-17T09:46:22","subject":"Re: [Qemu-devel] [PATCH v2 02/10] intel-iommu: remove\n\tIntelIOMMUNotifierNode","submitter":{"id":69187,"url":"http://patchwork.ozlabs.org/api/people/69187/","name":"Eric Auger","email":"eric.auger@redhat.com"},"content":"Hi Peter,\n\nOn 05/04/2018 05:08 AM, Peter Xu wrote:\n> That is not really necessary.  Removing that node struct and put the\n> list entry directly into VTDAddressSpace.  It simplfies the code a lot.\n> \n> Signed-off-by: Peter Xu <peterx@redhat.com>\n> ---\n>  include/hw/i386/intel_iommu.h |  9 ++------\n>  hw/i386/intel_iommu.c         | 41 ++++++++++-------------------------\n>  2 files changed, 14 insertions(+), 36 deletions(-)\n> \n> diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h\n> index 45ec8919b6..220697253f 100644\n> --- a/include/hw/i386/intel_iommu.h\n> +++ b/include/hw/i386/intel_iommu.h\n> @@ -67,7 +67,6 @@ typedef union VTD_IR_TableEntry VTD_IR_TableEntry;\n>  typedef union VTD_IR_MSIAddress VTD_IR_MSIAddress;\n>  typedef struct VTDIrq VTDIrq;\n>  typedef struct VTD_MSIMessage VTD_MSIMessage;\n> -typedef struct IntelIOMMUNotifierNode IntelIOMMUNotifierNode;\n>  \n>  /* Context-Entry */\n>  struct VTDContextEntry {\n> @@ -93,6 +92,7 @@ struct VTDAddressSpace {\n>      MemoryRegion iommu_ir;      /* Interrupt region: 0xfeeXXXXX */\n>      IntelIOMMUState *iommu_state;\n>      VTDContextCacheEntry context_cache_entry;\n> +    QLIST_ENTRY(VTDAddressSpace) next;\n>  };\n>  \n>  struct VTDBus {\n> @@ -253,11 +253,6 @@ struct VTD_MSIMessage {\n>  /* When IR is enabled, all MSI/MSI-X data bits should be zero */\n>  #define VTD_IR_MSI_DATA          (0)\n>  \n> -struct IntelIOMMUNotifierNode {\n> -    VTDAddressSpace *vtd_as;\n> -    QLIST_ENTRY(IntelIOMMUNotifierNode) next;\n> -};\n> -\n>  /* The iommu (DMAR) device state struct */\n>  struct IntelIOMMUState {\n>      X86IOMMUState x86_iommu;\n> @@ -295,7 +290,7 @@ struct IntelIOMMUState {\n>      GHashTable *vtd_as_by_busptr;   /* VTDBus objects indexed by PCIBus* reference */\n>      VTDBus *vtd_as_by_bus_num[VTD_PCI_BUS_MAX]; /* VTDBus objects indexed by bus number */\n>      /* list of registered notifiers */\n> -    QLIST_HEAD(, IntelIOMMUNotifierNode) notifiers_list;\n> +    QLIST_HEAD(, VTDAddressSpace) notifiers_list;\nWouldn't it make sense to rename notifiers_list into something more\nunderstandable like address_spaces?\n>  \n>      /* interrupt remapping */\n>      bool intr_enabled;              /* Whether guest enabled IR */\n> diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c\n> index b359efd6f9..5987b48d43 100644\n> --- a/hw/i386/intel_iommu.c\n> +++ b/hw/i386/intel_iommu.c\n> @@ -1248,10 +1248,10 @@ static void vtd_interrupt_remap_table_setup(IntelIOMMUState *s)\n>  \n>  static void vtd_iommu_replay_all(IntelIOMMUState *s)\n>  {\n> -    IntelIOMMUNotifierNode *node;\n> +    VTDAddressSpace *vtd_as;\n>  \n> -    QLIST_FOREACH(node, &s->notifiers_list, next) {\n> -        memory_region_iommu_replay_all(&node->vtd_as->iommu);\n> +    QLIST_FOREACH(vtd_as, &s->notifiers_list, next) {\n> +        memory_region_iommu_replay_all(&vtd_as->iommu);\n>      }\n>  }\n>  \n> @@ -1372,7 +1372,6 @@ static void vtd_iotlb_global_invalidate(IntelIOMMUState *s)\n>  \n>  static void vtd_iotlb_domain_invalidate(IntelIOMMUState *s, uint16_t domain_id)\n>  {\n> -    IntelIOMMUNotifierNode *node;\n>      VTDContextEntry ce;\n>      VTDAddressSpace *vtd_as;\n>  \n> @@ -1381,8 +1380,7 @@ static void vtd_iotlb_domain_invalidate(IntelIOMMUState *s, uint16_t domain_id)\n>      g_hash_table_foreach_remove(s->iotlb, vtd_hash_remove_by_domain,\n>                                  &domain_id);\n>  \n> -    QLIST_FOREACH(node, &s->notifiers_list, next) {\n> -        vtd_as = node->vtd_as;\n> +    QLIST_FOREACH(vtd_as, &s->notifiers_list, next) {\n>          if (!vtd_dev_to_context_entry(s, pci_bus_num(vtd_as->bus),\n>                                        vtd_as->devfn, &ce) &&\n>              domain_id == VTD_CONTEXT_ENTRY_DID(ce.hi)) {\n> @@ -1402,12 +1400,11 @@ static void vtd_iotlb_page_invalidate_notify(IntelIOMMUState *s,\n>                                             uint16_t domain_id, hwaddr addr,\n>                                             uint8_t am)\n>  {\n> -    IntelIOMMUNotifierNode *node;\n> +    VTDAddressSpace *vtd_as;\n>      VTDContextEntry ce;\n>      int ret;\n>  \n> -    QLIST_FOREACH(node, &(s->notifiers_list), next) {\n> -        VTDAddressSpace *vtd_as = node->vtd_as;\n> +    QLIST_FOREACH(vtd_as, &(s->notifiers_list), next) {\n>          ret = vtd_dev_to_context_entry(s, pci_bus_num(vtd_as->bus),\n>                                         vtd_as->devfn, &ce);\n>          if (!ret && domain_id == VTD_CONTEXT_ENTRY_DID(ce.hi)) {\n> @@ -2344,8 +2341,6 @@ static void vtd_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu,\n>  {\n>      VTDAddressSpace *vtd_as = container_of(iommu, VTDAddressSpace, iommu);\n>      IntelIOMMUState *s = vtd_as->iommu_state;\n> -    IntelIOMMUNotifierNode *node = NULL;\n> -    IntelIOMMUNotifierNode *next_node = NULL;\n>  \n>      if (!s->caching_mode && new & IOMMU_NOTIFIER_MAP) {\n>          error_report(\"We need to set caching-mode=1 for intel-iommu to enable \"\n> @@ -2354,21 +2349,11 @@ static void vtd_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu,\n>      }\n>  \n>      if (old == IOMMU_NOTIFIER_NONE) {\n> -        node = g_malloc0(sizeof(*node));\n> -        node->vtd_as = vtd_as;\n> -        QLIST_INSERT_HEAD(&s->notifiers_list, node, next);\n> -        return;\n> -    }\n> -\n> -    /* update notifier node with new flags */\n> -    QLIST_FOREACH_SAFE(node, &s->notifiers_list, next, next_node) {\n> -        if (node->vtd_as == vtd_as) {\n> -            if (new == IOMMU_NOTIFIER_NONE) {\n> -                QLIST_REMOVE(node, next);\n> -                g_free(node);\n> -            }\n> -            return;\n> -        }\n> +        /* Insert new ones */\ns/ones/one\n\n> +        QLIST_INSERT_HEAD(&s->notifiers_list, vtd_as, next);\n> +    } else if (new == IOMMU_NOTIFIER_NONE) {\n> +        /* Remove old ones */\nsame. Not sure the comments are worth.\n> +        QLIST_REMOVE(vtd_as, next);\n>      }\n>  }\n>  \n> @@ -2838,12 +2823,10 @@ static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n)\n>  \n>  static void vtd_address_space_unmap_all(IntelIOMMUState *s)\n>  {\n> -    IntelIOMMUNotifierNode *node;\n>      VTDAddressSpace *vtd_as;\n>      IOMMUNotifier *n;\n>  \n> -    QLIST_FOREACH(node, &s->notifiers_list, next) {\n> -        vtd_as = node->vtd_as;\n> +    QLIST_FOREACH(vtd_as, &s->notifiers_list, next) {\n>          IOMMU_NOTIFIER_FOREACH(n, &vtd_as->iommu) {\n>              vtd_address_space_unmap(vtd_as, n);\n>          }\n> \nThanks\n\nEric","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdmarc=fail (p=none dis=none) header.from=redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 40mmhF0WVyz9s3B\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 17 May 2018 19:48:13 +1000 (AEST)","from localhost ([::1]:45911 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1fJFW6-0000wq-PZ\n\tfor incoming@patchwork.ozlabs.org; Thu, 17 May 2018 05:48:10 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:41398)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <eric.auger@redhat.com>) id 1fJFUa-0000Mt-PZ\n\tfor qemu-devel@nongnu.org; Thu, 17 May 2018 05:46:37 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <eric.auger@redhat.com>) id 1fJFUW-0007Sy-R0\n\tfor qemu-devel@nongnu.org; Thu, 17 May 2018 05:46:36 -0400","from mx3-rdu2.redhat.com ([66.187.233.73]:59192\n\thelo=mx1.redhat.com)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <eric.auger@redhat.com>)\n\tid 1fJFUW-0007SU-LO\n\tfor qemu-devel@nongnu.org; Thu, 17 May 2018 05:46:32 -0400","from smtp.corp.redhat.com\n\t(int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 2CF9B7D65F;\n\tThu, 17 May 2018 09:46:32 +0000 (UTC)","from localhost.localdomain (ovpn-117-111.ams2.redhat.com\n\t[10.36.117.111])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id 670F27D561;\n\tThu, 17 May 2018 09:46:23 +0000 (UTC)"],"To":"Peter Xu <peterx@redhat.com>, qemu-devel@nongnu.org","References":"<20180504030811.28111-1-peterx@redhat.com>\n\t<20180504030811.28111-3-peterx@redhat.com>","From":"Auger Eric <eric.auger@redhat.com>","Message-ID":"<17437758-3b51-72c7-81ba-cb0df0a22c1c@redhat.com>","Date":"Thu, 17 May 2018 11:46:22 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101\n\tThunderbird/45.4.0","MIME-Version":"1.0","In-Reply-To":"<20180504030811.28111-3-peterx@redhat.com>","Content-Type":"text/plain; charset=windows-1252","Content-Transfer-Encoding":"7bit","X-Scanned-By":"MIMEDefang 2.79 on 10.11.54.5","X-Greylist":["Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.11.55.2]);\n\tThu, 17 May 2018 09:46:32 +0000 (UTC)","inspected by milter-greylist-4.5.16 (mx1.redhat.com\n\t[10.11.55.2]); \n\tThu, 17 May 2018 09:46:32 +0000 (UTC) for IP:'10.11.54.5'\n\tDOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com'\n\tHELO:'smtp.corp.redhat.com' FROM:'eric.auger@redhat.com' RCPT:''"],"X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"66.187.233.73","Subject":"Re: [Qemu-devel] [PATCH v2 02/10] intel-iommu: remove\n\tIntelIOMMUNotifierNode","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Jintack Lim <jintack@cs.columbia.edu>, Tian Kevin <kevin.tian@intel.com>,\n\tAlex Williamson <alex.williamson@redhat.com>,\n\tJason Wang <jasowang@redhat.com>, \"Michael S . Tsirkin\" <mst@redhat.com>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1914822,"web_url":"http://patchwork.ozlabs.org/comment/1914822/","msgid":"<20180517100247.GB26089@xz-mi>","list_archive_url":null,"date":"2018-05-17T10:02:47","subject":"Re: [Qemu-devel] [PATCH v2 02/10] intel-iommu: remove\n\tIntelIOMMUNotifierNode","submitter":{"id":67717,"url":"http://patchwork.ozlabs.org/api/people/67717/","name":"Peter Xu","email":"peterx@redhat.com"},"content":"On Thu, May 17, 2018 at 11:46:22AM +0200, Auger Eric wrote:\n> Hi Peter,\n> \n> On 05/04/2018 05:08 AM, Peter Xu wrote:\n> > That is not really necessary.  Removing that node struct and put the\n> > list entry directly into VTDAddressSpace.  It simplfies the code a lot.\n> > \n> > Signed-off-by: Peter Xu <peterx@redhat.com>\n> > ---\n> >  include/hw/i386/intel_iommu.h |  9 ++------\n> >  hw/i386/intel_iommu.c         | 41 ++++++++++-------------------------\n> >  2 files changed, 14 insertions(+), 36 deletions(-)\n> > \n> > diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h\n> > index 45ec8919b6..220697253f 100644\n> > --- a/include/hw/i386/intel_iommu.h\n> > +++ b/include/hw/i386/intel_iommu.h\n> > @@ -67,7 +67,6 @@ typedef union VTD_IR_TableEntry VTD_IR_TableEntry;\n> >  typedef union VTD_IR_MSIAddress VTD_IR_MSIAddress;\n> >  typedef struct VTDIrq VTDIrq;\n> >  typedef struct VTD_MSIMessage VTD_MSIMessage;\n> > -typedef struct IntelIOMMUNotifierNode IntelIOMMUNotifierNode;\n> >  \n> >  /* Context-Entry */\n> >  struct VTDContextEntry {\n> > @@ -93,6 +92,7 @@ struct VTDAddressSpace {\n> >      MemoryRegion iommu_ir;      /* Interrupt region: 0xfeeXXXXX */\n> >      IntelIOMMUState *iommu_state;\n> >      VTDContextCacheEntry context_cache_entry;\n> > +    QLIST_ENTRY(VTDAddressSpace) next;\n> >  };\n> >  \n> >  struct VTDBus {\n> > @@ -253,11 +253,6 @@ struct VTD_MSIMessage {\n> >  /* When IR is enabled, all MSI/MSI-X data bits should be zero */\n> >  #define VTD_IR_MSI_DATA          (0)\n> >  \n> > -struct IntelIOMMUNotifierNode {\n> > -    VTDAddressSpace *vtd_as;\n> > -    QLIST_ENTRY(IntelIOMMUNotifierNode) next;\n> > -};\n> > -\n> >  /* The iommu (DMAR) device state struct */\n> >  struct IntelIOMMUState {\n> >      X86IOMMUState x86_iommu;\n> > @@ -295,7 +290,7 @@ struct IntelIOMMUState {\n> >      GHashTable *vtd_as_by_busptr;   /* VTDBus objects indexed by PCIBus* reference */\n> >      VTDBus *vtd_as_by_bus_num[VTD_PCI_BUS_MAX]; /* VTDBus objects indexed by bus number */\n> >      /* list of registered notifiers */\n> > -    QLIST_HEAD(, IntelIOMMUNotifierNode) notifiers_list;\n> > +    QLIST_HEAD(, VTDAddressSpace) notifiers_list;\n> Wouldn't it make sense to rename notifiers_list into something more\n> understandable like address_spaces?\n\nBut address_spaces might be a bit confusing too on the other side as\n\"a list of all VT-d address spaces\".  How about something like:\n\n     address_spaces_with_notifiers\n\n?\n\n[...]\n\n> > -    /* update notifier node with new flags */\n> > -    QLIST_FOREACH_SAFE(node, &s->notifiers_list, next, next_node) {\n> > -        if (node->vtd_as == vtd_as) {\n> > -            if (new == IOMMU_NOTIFIER_NONE) {\n> > -                QLIST_REMOVE(node, next);\n> > -                g_free(node);\n> > -            }\n> > -            return;\n> > -        }\n> > +        /* Insert new ones */\n> s/ones/one\n> \n> > +        QLIST_INSERT_HEAD(&s->notifiers_list, vtd_as, next);\n> > +    } else if (new == IOMMU_NOTIFIER_NONE) {\n> > +        /* Remove old ones */\n> same. Not sure the comments are worth.\n\nWill remove two \"s\"s there.  Thanks,","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdmarc=fail (p=none dis=none) header.from=redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 40mn4f1FVJz9s1B\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 17 May 2018 20:05:54 +1000 (AEST)","from localhost ([::1]:46682 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1fJFnD-0002WL-Sm\n\tfor incoming@patchwork.ozlabs.org; Thu, 17 May 2018 06:05:51 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:44910)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <peterx@redhat.com>) id 1fJFkO-0000Md-Gv\n\tfor qemu-devel@nongnu.org; Thu, 17 May 2018 06:02:59 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <peterx@redhat.com>) id 1fJFkL-0008To-Ss\n\tfor qemu-devel@nongnu.org; Thu, 17 May 2018 06:02:56 -0400","from mx3-rdu2.redhat.com ([66.187.233.73]:57878\n\thelo=mx1.redhat.com)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <peterx@redhat.com>) id 1fJFkL-0008TQ-FH\n\tfor qemu-devel@nongnu.org; Thu, 17 May 2018 06:02:53 -0400","from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 0284B81663C0;\n\tThu, 17 May 2018 10:02:53 +0000 (UTC)","from xz-mi (ovpn-12-109.pek2.redhat.com [10.72.12.109])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id 340BC2026990;\n\tThu, 17 May 2018 10:02:49 +0000 (UTC)"],"Date":"Thu, 17 May 2018 18:02:47 +0800","From":"Peter Xu <peterx@redhat.com>","To":"Auger Eric <eric.auger@redhat.com>","Message-ID":"<20180517100247.GB26089@xz-mi>","References":"<20180504030811.28111-1-peterx@redhat.com>\n\t<20180504030811.28111-3-peterx@redhat.com>\n\t<17437758-3b51-72c7-81ba-cb0df0a22c1c@redhat.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<17437758-3b51-72c7-81ba-cb0df0a22c1c@redhat.com>","User-Agent":"Mutt/1.9.3 (2018-01-21)","X-Scanned-By":"MIMEDefang 2.78 on 10.11.54.4","X-Greylist":["Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.11.55.8]);\n\tThu, 17 May 2018 10:02:53 +0000 (UTC)","inspected by milter-greylist-4.5.16 (mx1.redhat.com\n\t[10.11.55.8]); \n\tThu, 17 May 2018 10:02:53 +0000 (UTC) for IP:'10.11.54.4'\n\tDOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com'\n\tHELO:'smtp.corp.redhat.com' FROM:'peterx@redhat.com' RCPT:''"],"X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"66.187.233.73","Subject":"Re: [Qemu-devel] [PATCH v2 02/10] intel-iommu: remove\n\tIntelIOMMUNotifierNode","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Tian Kevin <kevin.tian@intel.com>, \"Michael S . Tsirkin\" <mst@redhat.com>,\n\tJason Wang <jasowang@redhat.com>, qemu-devel@nongnu.org,\n\tAlex Williamson <alex.williamson@redhat.com>,\n\tJintack Lim <jintack@cs.columbia.edu>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1914830,"web_url":"http://patchwork.ozlabs.org/comment/1914830/","msgid":"<68c29b90-0cec-91c3-f2f3-b0e58fc40d5e@redhat.com>","list_archive_url":null,"date":"2018-05-17T10:10:41","subject":"Re: [Qemu-devel] [PATCH v2 02/10] intel-iommu: remove\n\tIntelIOMMUNotifierNode","submitter":{"id":69187,"url":"http://patchwork.ozlabs.org/api/people/69187/","name":"Eric Auger","email":"eric.auger@redhat.com"},"content":"Hi Peter,\n\nOn 05/17/2018 12:02 PM, Peter Xu wrote:\n> On Thu, May 17, 2018 at 11:46:22AM +0200, Auger Eric wrote:\n>> Hi Peter,\n>>\n>> On 05/04/2018 05:08 AM, Peter Xu wrote:\n>>> That is not really necessary.  Removing that node struct and put the\n>>> list entry directly into VTDAddressSpace.  It simplfies the code a lot.\n>>>\n>>> Signed-off-by: Peter Xu <peterx@redhat.com>\n>>> ---\n>>>  include/hw/i386/intel_iommu.h |  9 ++------\n>>>  hw/i386/intel_iommu.c         | 41 ++++++++++-------------------------\n>>>  2 files changed, 14 insertions(+), 36 deletions(-)\n>>>\n>>> diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h\n>>> index 45ec8919b6..220697253f 100644\n>>> --- a/include/hw/i386/intel_iommu.h\n>>> +++ b/include/hw/i386/intel_iommu.h\n>>> @@ -67,7 +67,6 @@ typedef union VTD_IR_TableEntry VTD_IR_TableEntry;\n>>>  typedef union VTD_IR_MSIAddress VTD_IR_MSIAddress;\n>>>  typedef struct VTDIrq VTDIrq;\n>>>  typedef struct VTD_MSIMessage VTD_MSIMessage;\n>>> -typedef struct IntelIOMMUNotifierNode IntelIOMMUNotifierNode;\n>>>  \n>>>  /* Context-Entry */\n>>>  struct VTDContextEntry {\n>>> @@ -93,6 +92,7 @@ struct VTDAddressSpace {\n>>>      MemoryRegion iommu_ir;      /* Interrupt region: 0xfeeXXXXX */\n>>>      IntelIOMMUState *iommu_state;\n>>>      VTDContextCacheEntry context_cache_entry;\n>>> +    QLIST_ENTRY(VTDAddressSpace) next;\n>>>  };\n>>>  \n>>>  struct VTDBus {\n>>> @@ -253,11 +253,6 @@ struct VTD_MSIMessage {\n>>>  /* When IR is enabled, all MSI/MSI-X data bits should be zero */\n>>>  #define VTD_IR_MSI_DATA          (0)\n>>>  \n>>> -struct IntelIOMMUNotifierNode {\n>>> -    VTDAddressSpace *vtd_as;\n>>> -    QLIST_ENTRY(IntelIOMMUNotifierNode) next;\n>>> -};\n>>> -\n>>>  /* The iommu (DMAR) device state struct */\n>>>  struct IntelIOMMUState {\n>>>      X86IOMMUState x86_iommu;\n>>> @@ -295,7 +290,7 @@ struct IntelIOMMUState {\n>>>      GHashTable *vtd_as_by_busptr;   /* VTDBus objects indexed by PCIBus* reference */\n>>>      VTDBus *vtd_as_by_bus_num[VTD_PCI_BUS_MAX]; /* VTDBus objects indexed by bus number */\n>>>      /* list of registered notifiers */\n>>> -    QLIST_HEAD(, IntelIOMMUNotifierNode) notifiers_list;\n>>> +    QLIST_HEAD(, VTDAddressSpace) notifiers_list;\n>> Wouldn't it make sense to rename notifiers_list into something more\n>> understandable like address_spaces?\n> \n> But address_spaces might be a bit confusing too on the other side as\n> \"a list of all VT-d address spaces\".  How about something like:\n> \n>      address_spaces_with_notifiers\nHum I missed not all of them belonged to that list. a bit long now?\nvtd_as_with_notifiers?\n\nThanks\n\nEric\n> \n> ?\n> \n> [...]\n> \n>>> -    /* update notifier node with new flags */\n>>> -    QLIST_FOREACH_SAFE(node, &s->notifiers_list, next, next_node) {\n>>> -        if (node->vtd_as == vtd_as) {\n>>> -            if (new == IOMMU_NOTIFIER_NONE) {\n>>> -                QLIST_REMOVE(node, next);\n>>> -                g_free(node);\n>>> -            }\n>>> -            return;\n>>> -        }\n>>> +        /* Insert new ones */\n>> s/ones/one\n>>\n>>> +        QLIST_INSERT_HEAD(&s->notifiers_list, vtd_as, next);\n>>> +    } else if (new == IOMMU_NOTIFIER_NONE) {\n>>> +        /* Remove old ones */\n>> same. Not sure the comments are worth.\n> \n> Will remove two \"s\"s there.  Thanks,\n>","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdmarc=fail (p=none dis=none) header.from=redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 40mnBx5Lp2z9s3M\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 17 May 2018 20:11:21 +1000 (AEST)","from localhost ([::1]:46938 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1fJFsU-00060M-Qb\n\tfor incoming@patchwork.ozlabs.org; Thu, 17 May 2018 06:11:18 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:46274)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <eric.auger@redhat.com>) id 1fJFs1-0005zE-Px\n\tfor qemu-devel@nongnu.org; Thu, 17 May 2018 06:10:50 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <eric.auger@redhat.com>) id 1fJFrw-0000JV-MS\n\tfor qemu-devel@nongnu.org; Thu, 17 May 2018 06:10:49 -0400","from mx3-rdu2.redhat.com ([66.187.233.73]:54040\n\thelo=mx1.redhat.com)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <eric.auger@redhat.com>)\n\tid 1fJFrw-0000IV-Fv\n\tfor qemu-devel@nongnu.org; Thu, 17 May 2018 06:10:44 -0400","from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id F3C62407577A;\n\tThu, 17 May 2018 10:10:43 +0000 (UTC)","from localhost.localdomain (ovpn-117-111.ams2.redhat.com\n\t[10.36.117.111])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id C2D13215ADE2;\n\tThu, 17 May 2018 10:10:42 +0000 (UTC)"],"To":"Peter Xu <peterx@redhat.com>","References":"<20180504030811.28111-1-peterx@redhat.com>\n\t<20180504030811.28111-3-peterx@redhat.com>\n\t<17437758-3b51-72c7-81ba-cb0df0a22c1c@redhat.com>\n\t<20180517100247.GB26089@xz-mi>","From":"Auger Eric <eric.auger@redhat.com>","Message-ID":"<68c29b90-0cec-91c3-f2f3-b0e58fc40d5e@redhat.com>","Date":"Thu, 17 May 2018 12:10:41 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101\n\tThunderbird/45.4.0","MIME-Version":"1.0","In-Reply-To":"<20180517100247.GB26089@xz-mi>","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"7bit","X-Scanned-By":"MIMEDefang 2.78 on 10.11.54.4","X-Greylist":["Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.11.55.7]);\n\tThu, 17 May 2018 10:10:44 +0000 (UTC)","inspected by milter-greylist-4.5.16 (mx1.redhat.com\n\t[10.11.55.7]); \n\tThu, 17 May 2018 10:10:44 +0000 (UTC) for IP:'10.11.54.4'\n\tDOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com'\n\tHELO:'smtp.corp.redhat.com' FROM:'eric.auger@redhat.com' RCPT:''"],"X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"66.187.233.73","Subject":"Re: [Qemu-devel] [PATCH v2 02/10] intel-iommu: remove\n\tIntelIOMMUNotifierNode","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Tian Kevin <kevin.tian@intel.com>, \"Michael S . Tsirkin\" <mst@redhat.com>,\n\tJason Wang <jasowang@redhat.com>, qemu-devel@nongnu.org,\n\tAlex Williamson <alex.williamson@redhat.com>,\n\tJintack Lim <jintack@cs.columbia.edu>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1914834,"web_url":"http://patchwork.ozlabs.org/comment/1914834/","msgid":"<20180517101413.GA28805@xz-mi>","list_archive_url":null,"date":"2018-05-17T10:14:14","subject":"Re: [Qemu-devel] [PATCH v2 02/10] intel-iommu: remove\n\tIntelIOMMUNotifierNode","submitter":{"id":67717,"url":"http://patchwork.ozlabs.org/api/people/67717/","name":"Peter Xu","email":"peterx@redhat.com"},"content":"On Thu, May 17, 2018 at 12:10:41PM +0200, Auger Eric wrote:\n> Hi Peter,\n> \n> On 05/17/2018 12:02 PM, Peter Xu wrote:\n> > On Thu, May 17, 2018 at 11:46:22AM +0200, Auger Eric wrote:\n> >> Hi Peter,\n> >>\n> >> On 05/04/2018 05:08 AM, Peter Xu wrote:\n> >>> That is not really necessary.  Removing that node struct and put the\n> >>> list entry directly into VTDAddressSpace.  It simplfies the code a lot.\n> >>>\n> >>> Signed-off-by: Peter Xu <peterx@redhat.com>\n> >>> ---\n> >>>  include/hw/i386/intel_iommu.h |  9 ++------\n> >>>  hw/i386/intel_iommu.c         | 41 ++++++++++-------------------------\n> >>>  2 files changed, 14 insertions(+), 36 deletions(-)\n> >>>\n> >>> diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h\n> >>> index 45ec8919b6..220697253f 100644\n> >>> --- a/include/hw/i386/intel_iommu.h\n> >>> +++ b/include/hw/i386/intel_iommu.h\n> >>> @@ -67,7 +67,6 @@ typedef union VTD_IR_TableEntry VTD_IR_TableEntry;\n> >>>  typedef union VTD_IR_MSIAddress VTD_IR_MSIAddress;\n> >>>  typedef struct VTDIrq VTDIrq;\n> >>>  typedef struct VTD_MSIMessage VTD_MSIMessage;\n> >>> -typedef struct IntelIOMMUNotifierNode IntelIOMMUNotifierNode;\n> >>>  \n> >>>  /* Context-Entry */\n> >>>  struct VTDContextEntry {\n> >>> @@ -93,6 +92,7 @@ struct VTDAddressSpace {\n> >>>      MemoryRegion iommu_ir;      /* Interrupt region: 0xfeeXXXXX */\n> >>>      IntelIOMMUState *iommu_state;\n> >>>      VTDContextCacheEntry context_cache_entry;\n> >>> +    QLIST_ENTRY(VTDAddressSpace) next;\n> >>>  };\n> >>>  \n> >>>  struct VTDBus {\n> >>> @@ -253,11 +253,6 @@ struct VTD_MSIMessage {\n> >>>  /* When IR is enabled, all MSI/MSI-X data bits should be zero */\n> >>>  #define VTD_IR_MSI_DATA          (0)\n> >>>  \n> >>> -struct IntelIOMMUNotifierNode {\n> >>> -    VTDAddressSpace *vtd_as;\n> >>> -    QLIST_ENTRY(IntelIOMMUNotifierNode) next;\n> >>> -};\n> >>> -\n> >>>  /* The iommu (DMAR) device state struct */\n> >>>  struct IntelIOMMUState {\n> >>>      X86IOMMUState x86_iommu;\n> >>> @@ -295,7 +290,7 @@ struct IntelIOMMUState {\n> >>>      GHashTable *vtd_as_by_busptr;   /* VTDBus objects indexed by PCIBus* reference */\n> >>>      VTDBus *vtd_as_by_bus_num[VTD_PCI_BUS_MAX]; /* VTDBus objects indexed by bus number */\n> >>>      /* list of registered notifiers */\n> >>> -    QLIST_HEAD(, IntelIOMMUNotifierNode) notifiers_list;\n> >>> +    QLIST_HEAD(, VTDAddressSpace) notifiers_list;\n> >> Wouldn't it make sense to rename notifiers_list into something more\n> >> understandable like address_spaces?\n> > \n> > But address_spaces might be a bit confusing too on the other side as\n> > \"a list of all VT-d address spaces\".  How about something like:\n> > \n> >      address_spaces_with_notifiers\n> Hum I missed not all of them belonged to that list. a bit long now?\n> vtd_as_with_notifiers?\n\nOkay I can use that.  Regarding to the other \"s\"s issues - I think\nI'll just drop those comments since they aren't really helpful after\nall.  Thanks,","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdmarc=fail (p=none dis=none) header.from=redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 40mnGy0MGsz9s3G\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 17 May 2018 20:14:48 +1000 (AEST)","from localhost ([::1]:47070 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1fJFvq-0007bL-1B\n\tfor incoming@patchwork.ozlabs.org; Thu, 17 May 2018 06:14:46 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:47630)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <peterx@redhat.com>) id 1fJFvU-0007Zl-OR\n\tfor qemu-devel@nongnu.org; Thu, 17 May 2018 06:14:25 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <peterx@redhat.com>) id 1fJFvP-0001fl-Pg\n\tfor qemu-devel@nongnu.org; Thu, 17 May 2018 06:14:24 -0400","from mx3-rdu2.redhat.com ([66.187.233.73]:60396\n\thelo=mx1.redhat.com)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <peterx@redhat.com>) id 1fJFvP-0001fK-L7\n\tfor qemu-devel@nongnu.org; Thu, 17 May 2018 06:14:19 -0400","from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 4DC3E6F596;\n\tThu, 17 May 2018 10:14:19 +0000 (UTC)","from xz-mi (ovpn-12-109.pek2.redhat.com [10.72.12.109])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id 916AE2026990;\n\tThu, 17 May 2018 10:14:16 +0000 (UTC)"],"Date":"Thu, 17 May 2018 18:14:14 +0800","From":"Peter Xu <peterx@redhat.com>","To":"Auger Eric <eric.auger@redhat.com>","Message-ID":"<20180517101413.GA28805@xz-mi>","References":"<20180504030811.28111-1-peterx@redhat.com>\n\t<20180504030811.28111-3-peterx@redhat.com>\n\t<17437758-3b51-72c7-81ba-cb0df0a22c1c@redhat.com>\n\t<20180517100247.GB26089@xz-mi>\n\t<68c29b90-0cec-91c3-f2f3-b0e58fc40d5e@redhat.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<68c29b90-0cec-91c3-f2f3-b0e58fc40d5e@redhat.com>","User-Agent":"Mutt/1.9.3 (2018-01-21)","X-Scanned-By":"MIMEDefang 2.78 on 10.11.54.4","X-Greylist":["Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.11.55.2]);\n\tThu, 17 May 2018 10:14:19 +0000 (UTC)","inspected by milter-greylist-4.5.16 (mx1.redhat.com\n\t[10.11.55.2]); \n\tThu, 17 May 2018 10:14:19 +0000 (UTC) for IP:'10.11.54.4'\n\tDOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com'\n\tHELO:'smtp.corp.redhat.com' FROM:'peterx@redhat.com' RCPT:''"],"X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"66.187.233.73","Subject":"Re: [Qemu-devel] [PATCH v2 02/10] intel-iommu: remove\n\tIntelIOMMUNotifierNode","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Tian Kevin <kevin.tian@intel.com>, \"Michael S . Tsirkin\" <mst@redhat.com>,\n\tJason Wang <jasowang@redhat.com>, qemu-devel@nongnu.org,\n\tAlex Williamson <alex.williamson@redhat.com>,\n\tJintack Lim <jintack@cs.columbia.edu>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}}]