get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/810921/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 810921,
    "url": "http://patchwork.ozlabs.org/api/patches/810921/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170907092010.3605-5-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": "<20170907092010.3605-5-aik@ozlabs.ru>",
    "list_archive_url": null,
    "date": "2017-09-07T09:20:10",
    "name": "[RFC,qemu,4/4] memory: Add flat views to HMP \"info mtree\"",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "91652b98b89e7404c4b91e0fc80140687b91cb2a",
    "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/20170907092010.3605-5-aik@ozlabs.ru/mbox/",
    "series": [
        {
            "id": 1955,
            "url": "http://patchwork.ozlabs.org/api/series/1955/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=1955",
            "date": "2017-09-07T09:20:10",
            "name": "memory: Reduce memory use",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/1955/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/810921/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/810921/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 3xnw1N2PMKz9sNV\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu,  7 Sep 2017 19:21:12 +1000 (AEST)",
            "from localhost ([::1]:39509 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 1dpszm-00014C-CN\n\tfor incoming@patchwork.ozlabs.org; Thu, 07 Sep 2017 05:21:10 -0400",
            "from eggs.gnu.org ([2001:4830:134:3::10]:57112)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <aik@ozlabs.ru>) id 1dpszB-00010T-CE\n\tfor qemu-devel@nongnu.org; Thu, 07 Sep 2017 05:20:38 -0400",
            "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <aik@ozlabs.ru>) id 1dpsz7-0007If-03\n\tfor qemu-devel@nongnu.org; Thu, 07 Sep 2017 05:20:33 -0400",
            "from ozlabs.ru ([107.173.13.209]:51158)\n\tby eggs.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <aik@ozlabs.ru>) id 1dpsz6-0007Hc-LT\n\tfor qemu-devel@nongnu.org; Thu, 07 Sep 2017 05:20:28 -0400",
            "from vpl1.ozlabs.ibm.com (localhost [IPv6:::1])\n\tby ozlabs.ru (Postfix) with ESMTP id A8CC23A604D5;\n\tThu,  7 Sep 2017 05:21:37 -0400 (EDT)"
        ],
        "From": "Alexey Kardashevskiy <aik@ozlabs.ru>",
        "To": "qemu-devel@nongnu.org",
        "Date": "Thu,  7 Sep 2017 19:20:10 +1000",
        "Message-Id": "<20170907092010.3605-5-aik@ozlabs.ru>",
        "X-Mailer": "git-send-email 2.11.0",
        "In-Reply-To": "<20170907092010.3605-1-aik@ozlabs.ru>",
        "References": "<20170907092010.3605-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] [RFC PATCH qemu 4/4] memory: Add flat views to HMP\n\t\"info mtree\"",
        "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>,\n\tStefan Hajnoczi <stefanha@gmail.com>,\n\tPeter Maydell <peter.maydell@linaro.org>,\n\tDavid Gibson <david@gibson.dropbear.id.au>",
        "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": "This adds a new switch to \"info mtree\" to print dispatch tree internals.\n\nSigned-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>\n---\n\nExample:\n\naik@fstn1-p1:~$ echo \"info mtree -f -d\" | nc localhost 30000\nQEMU 2.9.94 monitor - type 'help' for more information\n(qemu) info mtree -f -d\nFlatView #0\n AS \"memory\"\n  0000000000000000-000000007fffffff (prio 0, ram): ppc_spapr.ram\n AS \"cpu-memory\"\n  0000000000000000-000000007fffffff (prio 0, ram): ppc_spapr.ram\n AS \"cpu-memory\"\n  0000000000000000-000000007fffffff (prio 0, ram): ppc_spapr.ram\n  Dispatch\n    Physical sections\n      #0 @0000000000000000 root=\"(noname)\" [unassigned]\n      #1 @0000000000000000 root=\"(noname)\" [not dirty]\n      #2 @0000000000000000 root=\"(noname)\" [ROM]\n      #3 @0000000000000000 root=\"(noname)\" [watch]\n      #4 @0000000000000000 root=\"ppc_spapr.ram\"\n    Nodes (9 bits per level, 6 levels) ptr=[3] skip=4\n      [0]\n\t  0       skip=3  ptr=[3]\n\t  1..511  skip=1  ptr=NIL\n      [1]\n\t  0       skip=2  ptr=[3]\n\t  1..511  skip=1  ptr=NIL\n      [2]\n\t  0       skip=1  ptr=[3]\n\t  1..511  skip=1  ptr=NIL\n      [3]\n\t  0..1    skip=0  ptr=#4\n\t  2..511  skip=1  ptr=NIL\n\nFlatView #1\n AS \"I/O\"\n  0000000000000000-000000000000ffff (prio 0, i/o): io\n  Dispatch\n    Physical sections\n      #0 @0000000000000000 root=\"(noname)\" [unassigned]\n      #1 @0000000000000000 root=\"(noname)\" [not dirty]\n      #2 @0000000000000000 root=\"(noname)\" [ROM]\n      #3 @0000000000000000 root=\"(noname)\" [watch]\n      #4 @0000000000000000 root=\"io\"\n    Nodes (9 bits per level, 6 levels) ptr=[5] skip=6\n      [0]\n\t  0       skip=5  ptr=[5]\n\t  1..511  skip=1  ptr=NIL\n      [1]\n\t  0       skip=4  ptr=[5]\n\t  1..511  skip=1  ptr=NIL\n      [2]\n\t  0       skip=3  ptr=[5]\n\t  1..511  skip=1  ptr=NIL\n      [3]\n\t  0       skip=2  ptr=[5]\n\t  1..511  skip=1  ptr=NIL\n      [4]\n\t  0       skip=1  ptr=[5]\n\t  1..511  skip=1  ptr=NIL\n      [5]\n\t  0..15   skip=0  ptr=#4\n\t 16..511  skip=0  ptr=#0\n\nFlatView #2\n AS \"pci@800000020000000\"\n  0000000000000000-000000003fffffff (prio 0, i/o): tce-iommu-80000000\n  0000040000000000-000004000000ffff (prio 0, i/o): msi\n  Dispatch\n    Physical sections\n      #0 @0000000000000000 root=\"(noname)\" [unassigned]\n      #1 @0000000000000000 root=\"(noname)\" [not dirty]\n      #2 @0000000000000000 root=\"(noname)\" [ROM]\n      #3 @0000000000000000 root=\"(noname)\" [watch]\n      #4 @0000000000000000 root=\"tce-iommu-80000000\"\n      #5 @0000040000000000 root=\"msi\"\n    Nodes (9 bits per level, 6 levels) ptr=[2] skip=3\n      [0]\n\t  0       skip=2  ptr=[2]\n\t  1..511  skip=1  ptr=NIL\n      [1]\n\t  0       skip=1  ptr=[2]\n\t  1..511  skip=1  ptr=NIL\n      [2]\n\t  0       skip=0  ptr=#4\n\t  1..7    skip=1  ptr=NIL\n\t  8       skip=3  ptr=[6]\n\t  9..511  skip=1  ptr=NIL\n      [3]\n\t  0       skip=0  ptr=#4\n\t  1..511  skip=1  ptr=NIL\n      [4]\n\t  0       skip=2  ptr=[6]\n\t  1..511  skip=1  ptr=NIL\n      [5]\n\t  0       skip=1  ptr=[6]\n\t  1..511  skip=1  ptr=NIL\n      [6]\n\t  0..15   skip=0  ptr=#5\n\t 16..511  skip=0  ptr=#0\n\n(qemu)\n---\n include/exec/memory.h |  5 +++-\n exec.c                | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++\n memory.c              | 20 ++++++++++++----\n monitor.c             |  3 ++-\n hmp-commands-info.hx  |  7 +++---\n 5 files changed, 92 insertions(+), 9 deletions(-)",
    "diff": "diff --git a/include/exec/memory.h b/include/exec/memory.h\nindex 41ab165302..2a50bbe79f 100644\n--- a/include/exec/memory.h\n+++ b/include/exec/memory.h\n@@ -1527,7 +1527,10 @@ void memory_global_dirty_log_start(void);\n  */\n void memory_global_dirty_log_stop(void);\n \n-void mtree_info(fprintf_function mon_printf, void *f, bool flatview);\n+void mtree_info(fprintf_function mon_printf, void *f, bool flatview,\n+                bool dispatch_tree);\n+void mtree_print_dispatch(fprintf_function mon, void *f,\n+                          struct AddressSpaceDispatch *d);\n \n /**\n  * memory_region_request_mmio_ptr: request a pointer to an mmio\ndiff --git a/exec.c b/exec.c\nindex 51243f57f4..8c565e9102 100644\n--- a/exec.c\n+++ b/exec.c\n@@ -3605,3 +3605,69 @@ void page_size_init(void)\n     }\n     qemu_host_page_mask = -(intptr_t)qemu_host_page_size;\n }\n+\n+static void mtree_print_phys_entries(fprintf_function mon, void *f,\n+                                     int start, int end, int skip, int ptr)\n+{\n+    if (start == end - 1) {\n+        mon(f, \"\\t%3d      \", start);\n+    } else {\n+        mon(f, \"\\t%3d..%-3d \", start, end - 1);\n+    }\n+    mon(f, \" skip=%d \", skip);\n+    if (ptr == PHYS_MAP_NODE_NIL) {\n+        mon(f, \" ptr=NIL\");\n+    } else if (!skip) {\n+        mon(f, \" ptr=#%d\", ptr);\n+    } else {\n+        mon(f, \" ptr=[%d]\", ptr);\n+    }\n+    mon(f, \"\\n\");\n+}\n+\n+void mtree_print_dispatch(fprintf_function mon, void *f,\n+                          AddressSpaceDispatch *d)\n+{\n+    int i;\n+\n+    mon(f, \"  Dispatch\\n\");\n+    mon(f, \"    Physical sections\\n\");\n+\n+    for (i = 0; i < d->map.sections_nb; ++i) {\n+        MemoryRegionSection *s = d->map.sections + i;\n+        const char *names[] = { \"[unassigned]\", \"[not dirty]\",\n+                                \"[ROM]\", \"[watch]\" };\n+\n+        mon(f, \"      #%d @%016lX root=\\\"%s\\\" %s\\n\", i,\n+                   s->offset_within_address_space,\n+                   s->mr->name ? s->mr->name : \"(noname)\",\n+                   i < ARRAY_SIZE(names) ? names[i] : \"\");\n+    }\n+\n+    mon(f, \"    Nodes (%d bits per level, %d levels) ptr=[%d] skip=%d\\n\",\n+               P_L2_BITS, P_L2_LEVELS, d->phys_map.ptr, d->phys_map.skip);\n+    for (i = 0; i < d->map.nodes_nb; ++i) {\n+        int j, jprev;\n+        PhysPageEntry prev;\n+        Node *n = d->map.nodes + i;\n+\n+        mon(f, \"      [%d]\\n\", i);\n+\n+        for (j = 0, jprev = 0, prev = *n[0]; j < ARRAY_SIZE(*n); ++j) {\n+            PhysPageEntry *pe = *n + j;\n+\n+            if (pe->ptr == prev.ptr && pe->skip == prev.skip) {\n+                continue;\n+            }\n+\n+            mtree_print_phys_entries(mon, f, jprev, j, prev.skip, prev.ptr);\n+\n+            jprev = j;\n+            prev = *pe;\n+        }\n+\n+        if (jprev != ARRAY_SIZE(*n)) {\n+            mtree_print_phys_entries(mon, f, jprev, j, prev.skip, prev.ptr);\n+        }\n+    }\n+}\ndiff --git a/memory.c b/memory.c\nindex 385a507511..24938036c8 100644\n--- a/memory.c\n+++ b/memory.c\n@@ -2939,16 +2939,28 @@ static void mtree_print_flatview(fprintf_function p, void *f,\n     flatview_unref(view);\n }\n \n-void mtree_info(fprintf_function mon_printf, void *f, bool flatview)\n+void mtree_info(fprintf_function mon_printf, void *f, bool flatview,\n+                bool dispatch_tree)\n {\n     MemoryRegionListHead ml_head;\n     MemoryRegionList *ml, *ml2;\n     AddressSpace *as;\n+    FlatView *view;\n+    int n;\n \n     if (flatview) {\n-        QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) {\n-            mon_printf(f, \"address-space (flat view): %s\\n\", as->name);\n-            mtree_print_flatview(mon_printf, f, as);\n+        n = 0;\n+        QTAILQ_FOREACH(view, &flat_views, flat_views_link) {\n+            mon_printf(f, \"FlatView #%d\\n\", n);\n+            ++n;\n+\n+            QTAILQ_FOREACH(as, &view->address_spaces, flat_view_link) {\n+                mon_printf(f, \" AS \\\"%s\\\"\\n\", as->name);\n+                mtree_print_flatview(mon_printf, f, as);\n+            }\n+            if (dispatch_tree) {\n+                mtree_print_dispatch(mon_printf, f, view->dispatch);\n+            }\n             mon_printf(f, \"\\n\");\n         }\n         return;\ndiff --git a/monitor.c b/monitor.c\nindex e0f880107f..191c4b016d 100644\n--- a/monitor.c\n+++ b/monitor.c\n@@ -1703,8 +1703,9 @@ static void hmp_boot_set(Monitor *mon, const QDict *qdict)\n static void hmp_info_mtree(Monitor *mon, const QDict *qdict)\n {\n     bool flatview = qdict_get_try_bool(qdict, \"flatview\", false);\n+    bool dispatch_tree = qdict_get_try_bool(qdict, \"dispatch_tree\", false);\n \n-    mtree_info((fprintf_function)monitor_printf, mon, flatview);\n+    mtree_info((fprintf_function)monitor_printf, mon, flatview, dispatch_tree);\n }\n \n static void hmp_info_numa(Monitor *mon, const QDict *qdict)\ndiff --git a/hmp-commands-info.hx b/hmp-commands-info.hx\nindex d9df238a5f..3d2edff940 100644\n--- a/hmp-commands-info.hx\n+++ b/hmp-commands-info.hx\n@@ -249,9 +249,10 @@ ETEXI\n \n     {\n         .name       = \"mtree\",\n-        .args_type  = \"flatview:-f\",\n-        .params     = \"[-f]\",\n-        .help       = \"show memory tree (-f: dump flat view for address spaces)\",\n+        .args_type  = \"flatview:-f,dispatch_tree:-d\",\n+        .params     = \"[-f][-d]\",\n+        .help       = \"show memory tree (-f: dump flat view for address spaces;\"\n+                      \"-d: dump dispatch tree, valid with -f only)\",\n         .cmd        = hmp_info_mtree,\n     },\n \n",
    "prefixes": [
        "RFC",
        "qemu",
        "4/4"
    ]
}