Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/908462/?format=api
{ "id": 908462, "url": "http://patchwork.ozlabs.org/api/patches/908462/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20180504030811.28111-5-peterx@redhat.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20180504030811.28111-5-peterx@redhat.com>", "list_archive_url": null, "date": "2018-05-04T03:08:05", "name": "[v2,04/10] intel-iommu: only do page walk for MAP notifiers", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "a59509a04a2ce7a7b3c1c7226fee1294f4d08e97", "submitter": { "id": 67717, "url": "http://patchwork.ozlabs.org/api/people/67717/?format=api", "name": "Peter Xu", "email": "peterx@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20180504030811.28111-5-peterx@redhat.com/mbox/", "series": [ { "id": 42502, "url": "http://patchwork.ozlabs.org/api/series/42502/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=42502", "date": "2018-05-04T03:08:01", "name": "intel-iommu: nested vIOMMU, cleanups, bug fixes", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/42502/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/908462/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/908462/checks/", "tags": {}, "related": [], "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 40ccST2NYYz9s35\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 4 May 2018 13:09:45 +1000 (AEST)", "from localhost ([::1]:60164 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 1fER6M-0001jw-W4\n\tfor incoming@patchwork.ozlabs.org; Thu, 03 May 2018 23:09:43 -0400", "from eggs.gnu.org ([2001:4830:134:3::10]:33271)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <peterx@redhat.com>) id 1fER5W-0001iD-9c\n\tfor qemu-devel@nongnu.org; Thu, 03 May 2018 23:08:51 -0400", "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <peterx@redhat.com>) id 1fER5V-0005YP-3o\n\tfor qemu-devel@nongnu.org; Thu, 03 May 2018 23:08:50 -0400", "from mx3-rdu2.redhat.com ([66.187.233.73]:48264\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 1fER5U-0005Xj-UX\n\tfor qemu-devel@nongnu.org; Thu, 03 May 2018 23:08:49 -0400", "from smtp.corp.redhat.com\n\t(int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3])\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 9DFB240858C9;\n\tFri, 4 May 2018 03:08:48 +0000 (UTC)", "from xz-mi.redhat.com (ovpn-12-46.pek2.redhat.com [10.72.12.46])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 49CCD11166E0;\n\tFri, 4 May 2018 03:08:44 +0000 (UTC)" ], "From": "Peter Xu <peterx@redhat.com>", "To": "qemu-devel@nongnu.org", "Date": "Fri, 4 May 2018 11:08:05 +0800", "Message-Id": "<20180504030811.28111-5-peterx@redhat.com>", "In-Reply-To": "<20180504030811.28111-1-peterx@redhat.com>", "References": "<20180504030811.28111-1-peterx@redhat.com>", "X-Scanned-By": "MIMEDefang 2.78 on 10.11.54.3", "X-Greylist": [ "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.11.55.5]);\n\tFri, 04 May 2018 03:08:48 +0000 (UTC)", "inspected by milter-greylist-4.5.16 (mx1.redhat.com\n\t[10.11.55.5]); \n\tFri, 04 May 2018 03:08:48 +0000 (UTC) for IP:'10.11.54.3'\n\tDOMAIN:'int-mx03.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": "[Qemu-devel] [PATCH v2 04/10] intel-iommu: only do page walk for\n\tMAP notifiers", "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>, peterx@redhat.com,\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>" }, "content": "For UNMAP-only IOMMU notifiers, we don't really need to walk the page\ntables. Fasten that procedure by skipping the page table walk. That\nshould boost performance for UNMAP-only notifiers like vhost.\n\nSigned-off-by: Peter Xu <peterx@redhat.com>\n---\n include/hw/i386/intel_iommu.h | 2 ++\n hw/i386/intel_iommu.c | 43 +++++++++++++++++++++++++++++++----\n 2 files changed, 40 insertions(+), 5 deletions(-)", "diff": "diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h\nindex ee517704e7..9e0a6c1c6a 100644\n--- a/include/hw/i386/intel_iommu.h\n+++ b/include/hw/i386/intel_iommu.h\n@@ -93,6 +93,8 @@ struct VTDAddressSpace {\n IntelIOMMUState *iommu_state;\n VTDContextCacheEntry context_cache_entry;\n QLIST_ENTRY(VTDAddressSpace) next;\n+ /* Superset of notifier flags that this address space has */\n+ IOMMUNotifierFlag notifier_flags;\n };\n \n struct VTDBus {\ndiff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c\nindex 112971638d..9a418abfb6 100644\n--- a/hw/i386/intel_iommu.c\n+++ b/hw/i386/intel_iommu.c\n@@ -138,6 +138,12 @@ static inline void vtd_iommu_unlock(IntelIOMMUState *s)\n qemu_mutex_unlock(&s->iommu_lock);\n }\n \n+/* Whether the address space needs to notify new mappings */\n+static inline gboolean vtd_as_notify_mappings(VTDAddressSpace *as)\n+{\n+ return as->notifier_flags & IOMMU_NOTIFIER_MAP;\n+}\n+\n /* GHashTable functions */\n static gboolean vtd_uint64_equal(gconstpointer v1, gconstpointer v2)\n {\n@@ -1433,14 +1439,35 @@ static void vtd_iotlb_page_invalidate_notify(IntelIOMMUState *s,\n VTDAddressSpace *vtd_as;\n VTDContextEntry ce;\n int ret;\n+ hwaddr size = (1 << am) * VTD_PAGE_SIZE;\n \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- vtd_page_walk(&ce, addr, addr + (1 << am) * VTD_PAGE_SIZE,\n- vtd_page_invalidate_notify_hook,\n- (void *)&vtd_as->iommu, true, s->aw_bits);\n+ if (vtd_as_notify_mappings(vtd_as)) {\n+ /*\n+ * For MAP-inclusive notifiers, we need to walk the\n+ * page table to sync the shadow page table.\n+ */\n+ vtd_page_walk(&ce, addr, addr + size,\n+ vtd_page_invalidate_notify_hook,\n+ (void *)&vtd_as->iommu, true, s->aw_bits);\n+ } else {\n+ /*\n+ * For UNMAP-only notifiers, we don't need to walk the\n+ * page tables. We just deliver the PSI down to\n+ * invalidate caches.\n+ */\n+ IOMMUTLBEntry entry = {\n+ .target_as = &address_space_memory,\n+ .iova = addr,\n+ .translated_addr = 0,\n+ .addr_mask = size - 1,\n+ .perm = IOMMU_NONE,\n+ };\n+ memory_region_notify_iommu(&vtd_as->iommu, entry);\n+ }\n }\n }\n }\n@@ -2380,6 +2407,9 @@ static void vtd_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu,\n exit(1);\n }\n \n+ /* Update per-address-space notifier flags */\n+ vtd_as->notifier_flags = new;\n+\n if (old == IOMMU_NOTIFIER_NONE) {\n /* Insert new ones */\n QLIST_INSERT_HEAD(&s->notifiers_list, vtd_as, next);\n@@ -2890,8 +2920,11 @@ static void vtd_iommu_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier *n)\n PCI_FUNC(vtd_as->devfn),\n VTD_CONTEXT_ENTRY_DID(ce.hi),\n ce.hi, ce.lo);\n- vtd_page_walk(&ce, 0, ~0ULL, vtd_replay_hook, (void *)n, false,\n- s->aw_bits);\n+ if (vtd_as_notify_mappings(vtd_as)) {\n+ /* This is required only for MAP typed notifiers */\n+ vtd_page_walk(&ce, 0, ~0ULL, vtd_replay_hook, (void *)n, false,\n+ s->aw_bits);\n+ }\n } else {\n trace_vtd_replay_ce_invalid(bus_n, PCI_SLOT(vtd_as->devfn),\n PCI_FUNC(vtd_as->devfn));\n", "prefixes": [ "v2", "04/10" ] }