Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/814161/?format=api
{ "id": 814161, "url": "http://patchwork.ozlabs.org/api/patches/814161/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170915084030.40988-6-aik@ozlabs.ru/", "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": "<20170915084030.40988-6-aik@ozlabs.ru>", "list_archive_url": null, "date": "2017-09-15T08:40:22", "name": "[qemu,v2,05/13] memory: Move AddressSpaceDispatch from AddressSpace to FlatView", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "c38d31f5d1bd6af791d7c2f90d5bcc7f9a2481fe", "submitter": { "id": 7621, "url": "http://patchwork.ozlabs.org/api/people/7621/?format=api", "name": "Alexey Kardashevskiy", "email": "aik@ozlabs.ru" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170915084030.40988-6-aik@ozlabs.ru/mbox/", "series": [ { "id": 3250, "url": "http://patchwork.ozlabs.org/api/series/3250/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=3250", "date": "2017-09-15T08:40:21", "name": "memory: Reduce memory use", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/3250/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/814161/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/814161/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>)", "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 3xtpzS3pJcz9sPr\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 15 Sep 2017 18:51:32 +1000 (AEST)", "from localhost ([::1]:52000 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 1dsmLS-000132-Ip\n\tfor incoming@patchwork.ozlabs.org; Fri, 15 Sep 2017 04:51:30 -0400", "from eggs.gnu.org ([2001:4830:134:3::10]:38450)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <aik@ozlabs.ru>) id 1dsmBV-0007LM-Ce\n\tfor qemu-devel@nongnu.org; Fri, 15 Sep 2017 04:41:14 -0400", "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <aik@ozlabs.ru>) id 1dsmBT-0002gt-Ok\n\tfor qemu-devel@nongnu.org; Fri, 15 Sep 2017 04:41:13 -0400", "from ozlabs.ru ([107.173.13.209]:45038)\n\tby eggs.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <aik@ozlabs.ru>) id 1dsmBT-0002gc-AX\n\tfor qemu-devel@nongnu.org; Fri, 15 Sep 2017 04:41:11 -0400", "from vpl1.ozlabs.ibm.com (localhost [IPv6:::1])\n\tby ozlabs.ru (Postfix) with ESMTP id 4F67F3A60057;\n\tFri, 15 Sep 2017 04:41:54 -0400 (EDT)" ], "From": "Alexey Kardashevskiy <aik@ozlabs.ru>", "To": "qemu-devel@nongnu.org", "Date": "Fri, 15 Sep 2017 18:40:22 +1000", "Message-Id": "<20170915084030.40988-6-aik@ozlabs.ru>", "X-Mailer": "git-send-email 2.11.0", "In-Reply-To": "<20170915084030.40988-1-aik@ozlabs.ru>", "References": "<20170915084030.40988-1-aik@ozlabs.ru>", "X-detected-operating-system": "by eggs.gnu.org: GNU/Linux 3.x [fuzzy]", "X-Received-From": "107.173.13.209", "Subject": "[Qemu-devel] [PATCH qemu v2 05/13] memory: Move\n\tAddressSpaceDispatch from AddressSpace to FlatView", "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": "Alexey Kardashevskiy <aik@ozlabs.ru>, Paolo Bonzini <pbonzini@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>" }, "content": "As we are going to share FlatView's between AddressSpace's,\nand AddressSpaceDispatch is a structure to perform quick lookup\nin FlatView, this moves ASD to FlatView.\n\nAfter previosly open coded ASD rendering, we can also remove\nas->next_dispatch as the new FlatView pointer is stored\non a stack and set to an AS atomically.\n\nflatview_destroy() is executed under RCU instead of\naddress_space_dispatch_free() now.\n\nThis makes mem_begin/mem_commit to work with ASD and mem_add with FV\nas later on mem_add will be taking FV as an argument anyway.\n\nSigned-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>\n---\n include/exec/memory-internal.h | 13 ++++++++-----\n include/exec/memory.h | 2 --\n exec.c | 41 +++++++++++------------------------------\n memory.c | 31 ++++++++++++++++++++++++-------\n 4 files changed, 43 insertions(+), 44 deletions(-)", "diff": "diff --git a/include/exec/memory-internal.h b/include/exec/memory-internal.h\nindex 9abde2f11c..08b7e01047 100644\n--- a/include/exec/memory-internal.h\n+++ b/include/exec/memory-internal.h\n@@ -21,17 +21,20 @@\n \n #ifndef CONFIG_USER_ONLY\n typedef struct AddressSpaceDispatch AddressSpaceDispatch;\n-\n-void address_space_destroy_dispatch(AddressSpace *as);\n+typedef struct FlatView FlatView;\n \n extern const MemoryRegionOps unassigned_mem_ops;\n \n bool memory_region_access_valid(MemoryRegion *mr, hwaddr addr,\n unsigned size, bool is_write);\n \n-void mem_add(AddressSpace *as, MemoryRegionSection *section);\n-void mem_begin(AddressSpace *as);\n-void mem_commit(AddressSpace *as);\n+void mem_add(AddressSpace *as, FlatView *fv, MemoryRegionSection *section);\n+AddressSpaceDispatch *mem_begin(AddressSpace *as);\n+void mem_commit(AddressSpaceDispatch *d);\n+\n+AddressSpaceDispatch *address_space_to_dispatch(AddressSpace *as);\n+AddressSpaceDispatch *flatview_to_dispatch(FlatView *fv);\n+void address_space_dispatch_free(AddressSpaceDispatch *d);\n \n #endif\n #endif\ndiff --git a/include/exec/memory.h b/include/exec/memory.h\nindex 9581f7a7db..2346f8b863 100644\n--- a/include/exec/memory.h\n+++ b/include/exec/memory.h\n@@ -316,8 +316,6 @@ struct AddressSpace {\n \n int ioeventfd_nb;\n struct MemoryRegionIoeventfd *ioeventfds;\n- struct AddressSpaceDispatch *dispatch;\n- struct AddressSpaceDispatch *next_dispatch;\n QTAILQ_HEAD(memory_listeners_as, MemoryListener) listeners;\n QTAILQ_ENTRY(AddressSpace) address_spaces_link;\n };\ndiff --git a/exec.c b/exec.c\nindex 3ed3718dea..6b0211bafc 100644\n--- a/exec.c\n+++ b/exec.c\n@@ -188,8 +188,6 @@ typedef struct PhysPageMap {\n } PhysPageMap;\n \n struct AddressSpaceDispatch {\n- struct rcu_head rcu;\n-\n MemoryRegionSection *mru_section;\n /* This is a multi-level map on the physical address space.\n * The bottom level has pointers to MemoryRegionSections.\n@@ -486,7 +484,7 @@ static MemoryRegionSection address_space_do_translate(AddressSpace *as,\n IOMMUMemoryRegionClass *imrc;\n \n for (;;) {\n- AddressSpaceDispatch *d = atomic_rcu_read(&as->dispatch);\n+ AddressSpaceDispatch *d = address_space_to_dispatch(as);\n section = address_space_translate_internal(d, addr, &addr, plen, is_mmio);\n \n iommu_mr = memory_region_get_iommu(section->mr);\n@@ -1223,7 +1221,7 @@ hwaddr memory_region_section_get_iotlb(CPUState *cpu,\n } else {\n AddressSpaceDispatch *d;\n \n- d = atomic_rcu_read(§ion->address_space->dispatch);\n+ d = address_space_to_dispatch(section->address_space);\n iotlb = section - d->map.sections;\n iotlb += xlat;\n }\n@@ -1348,9 +1346,9 @@ static void register_multipage(AddressSpaceDispatch *d,\n phys_page_set(d, start_addr >> TARGET_PAGE_BITS, num_pages, section_index);\n }\n \n-void mem_add(AddressSpace *as, MemoryRegionSection *section)\n+void mem_add(AddressSpace *as, FlatView *fv, MemoryRegionSection *section)\n {\n- AddressSpaceDispatch *d = as->next_dispatch;\n+ AddressSpaceDispatch *d = flatview_to_dispatch(fv);\n MemoryRegionSection now = *section, remain = *section;\n Int128 page_size = int128_make64(TARGET_PAGE_SIZE);\n \n@@ -2673,7 +2671,7 @@ static void io_mem_init(void)\n NULL, UINT64_MAX);\n }\n \n-void mem_begin(AddressSpace *as)\n+AddressSpaceDispatch *mem_begin(AddressSpace *as)\n {\n AddressSpaceDispatch *d = g_new0(AddressSpaceDispatch, 1);\n uint16_t n;\n@@ -2689,26 +2687,19 @@ void mem_begin(AddressSpace *as)\n \n d->phys_map = (PhysPageEntry) { .ptr = PHYS_MAP_NODE_NIL, .skip = 1 };\n d->as = as;\n- as->next_dispatch = d;\n+\n+ return d;\n }\n \n-static void address_space_dispatch_free(AddressSpaceDispatch *d)\n+void address_space_dispatch_free(AddressSpaceDispatch *d)\n {\n phys_sections_free(&d->map);\n g_free(d);\n }\n \n-void mem_commit(AddressSpace *as)\n+void mem_commit(AddressSpaceDispatch *d)\n {\n- AddressSpaceDispatch *cur = as->dispatch;\n- AddressSpaceDispatch *next = as->next_dispatch;\n-\n- phys_page_compact_all(next, next->map.nodes_nb);\n-\n- atomic_rcu_set(&as->dispatch, next);\n- if (cur) {\n- call_rcu(cur, address_space_dispatch_free, rcu);\n- }\n+ phys_page_compact_all(d, d->map.nodes_nb);\n }\n \n static void tcg_commit(MemoryListener *listener)\n@@ -2724,21 +2715,11 @@ static void tcg_commit(MemoryListener *listener)\n * We reload the dispatch pointer now because cpu_reloading_memory_map()\n * may have split the RCU critical section.\n */\n- d = atomic_rcu_read(&cpuas->as->dispatch);\n+ d = address_space_to_dispatch(cpuas->as);\n atomic_rcu_set(&cpuas->memory_dispatch, d);\n tlb_flush(cpuas->cpu);\n }\n \n-void address_space_destroy_dispatch(AddressSpace *as)\n-{\n- AddressSpaceDispatch *d = as->dispatch;\n-\n- atomic_rcu_set(&as->dispatch, NULL);\n- if (d) {\n- call_rcu(d, address_space_dispatch_free, rcu);\n- }\n-}\n-\n static void memory_map_init(void)\n {\n system_memory = g_malloc(sizeof(*system_memory));\ndiff --git a/memory.c b/memory.c\nindex a8381a8bc2..1d93e4c836 100644\n--- a/memory.c\n+++ b/memory.c\n@@ -229,6 +229,7 @@ struct FlatView {\n FlatRange *ranges;\n unsigned nr;\n unsigned nr_allocated;\n+ struct AddressSpaceDispatch *dispatch;\n };\n \n typedef struct AddressSpaceOps AddressSpaceOps;\n@@ -289,6 +290,9 @@ static void flatview_destroy(FlatView *view)\n {\n int i;\n \n+ if (view->dispatch) {\n+ address_space_dispatch_free(view->dispatch);\n+ }\n for (i = 0; i < view->nr; i++) {\n memory_region_unref(view->ranges[i].mr);\n }\n@@ -304,10 +308,25 @@ static void flatview_ref(FlatView *view)\n static void flatview_unref(FlatView *view)\n {\n if (atomic_fetch_dec(&view->ref) == 1) {\n- flatview_destroy(view);\n+ call_rcu(view, flatview_destroy, rcu);\n }\n }\n \n+static FlatView *address_space_to_flatview(AddressSpace *as)\n+{\n+ return atomic_rcu_read(&as->current_map);\n+}\n+\n+AddressSpaceDispatch *flatview_to_dispatch(FlatView *fv)\n+{\n+ return fv->dispatch;\n+}\n+\n+AddressSpaceDispatch *address_space_to_dispatch(AddressSpace *as)\n+{\n+ return flatview_to_dispatch(address_space_to_flatview(as));\n+}\n+\n static bool can_merge(FlatRange *r1, FlatRange *r2)\n {\n return int128_eq(addrrange_end(r1->addr), r2->addr.start)\n@@ -887,7 +906,7 @@ static void address_space_update_flatview(AddressSpace *as,\n unsigned iold, inew;\n FlatRange *frold, *frnew;\n \n- mem_begin(as);\n+ new_view->dispatch = mem_begin(as);\n /*\n * FIXME: this is cut-n-paste from address_space_update_topology_pass,\n * simplify it\n@@ -915,7 +934,7 @@ static void address_space_update_flatview(AddressSpace *as,\n /* In both and unchanged (except logging may have changed) */\n MemoryRegionSection mrs = section_from_flat_range(frnew, as);\n \n- mem_add(as, &mrs);\n+ mem_add(as, new_view, &mrs);\n \n ++iold;\n ++inew;\n@@ -923,12 +942,12 @@ static void address_space_update_flatview(AddressSpace *as,\n /* In new */\n MemoryRegionSection mrs = section_from_flat_range(frnew, as);\n \n- mem_add(as, &mrs);\n+ mem_add(as, new_view, &mrs);\n \n ++inew;\n }\n }\n- mem_commit(as);\n+ mem_commit(new_view->dispatch);\n }\n \n static void address_space_update_topology(AddressSpace *as)\n@@ -2672,7 +2691,6 @@ void address_space_init(AddressSpace *as, MemoryRegion *root, const char *name)\n QTAILQ_INIT(&as->listeners);\n QTAILQ_INSERT_TAIL(&address_spaces, as, address_spaces_link);\n as->name = g_strdup(name ? name : \"anonymous\");\n- as->dispatch = NULL;\n memory_region_update_pending |= root->enabled;\n memory_region_transaction_commit();\n }\n@@ -2681,7 +2699,6 @@ static void do_address_space_destroy(AddressSpace *as)\n {\n bool do_free = as->malloced;\n \n- address_space_destroy_dispatch(as);\n assert(QTAILQ_EMPTY(&as->listeners));\n \n flatview_unref(as->current_map);\n", "prefixes": [ "qemu", "v2", "05/13" ] }