Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/813337/?format=api
{ "id": 813337, "url": "http://patchwork.ozlabs.org/api/patches/813337/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/150529956916.10902.377591821566438337.stgit@frigg.lan/", "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": "<150529956916.10902.377591821566438337.stgit@frigg.lan>", "list_archive_url": null, "date": "2017-09-13T10:46:09", "name": "[v6,13/22] instrument: Support synchronous modification of vCPU state", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "4441e23e7b06c36c38578d5879c15d83830104eb", "submitter": { "id": 9099, "url": "http://patchwork.ozlabs.org/api/people/9099/?format=api", "name": "Lluís Vilanova", "email": "vilanova@ac.upc.edu" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/150529956916.10902.377591821566438337.stgit@frigg.lan/mbox/", "series": [ { "id": 2857, "url": "http://patchwork.ozlabs.org/api/series/2857/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=2857", "date": "2017-09-13T09:53:43", "name": "instrument: Add basic event instrumentation", "version": 6, "mbox": "http://patchwork.ozlabs.org/series/2857/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/813337/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/813337/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 3xsddd1TNhz9s4s\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 13 Sep 2017 20:47:01 +1000 (AEST)", "from localhost ([::1]:41498 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 1ds5C7-0004il-8o\n\tfor incoming@patchwork.ozlabs.org; Wed, 13 Sep 2017 06:46:59 -0400", "from eggs.gnu.org ([2001:4830:134:3::10]:33813)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <vilanova@ac.upc.edu>) id 1ds5Bc-0004hX-Sm\n\tfor qemu-devel@nongnu.org; Wed, 13 Sep 2017 06:46:30 -0400", "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <vilanova@ac.upc.edu>) id 1ds5BY-0000f9-Tj\n\tfor qemu-devel@nongnu.org; Wed, 13 Sep 2017 06:46:28 -0400", "from roura.ac.upc.es ([147.83.33.10]:59429)\n\tby eggs.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <vilanova@ac.upc.edu>) id 1ds5BY-0000eT-I2\n\tfor qemu-devel@nongnu.org; Wed, 13 Sep 2017 06:46:24 -0400", "from correu-2.ac.upc.es (correu-2.ac.upc.es [147.83.30.92])\n\tby roura.ac.upc.es (8.13.8/8.13.8) with ESMTP id v8DAkKZ9009218;\n\tWed, 13 Sep 2017 12:46:20 +0200", "from localhost (unknown [132.68.137.204])\n\tby correu-2.ac.upc.es (Postfix) with ESMTPSA id 29F3A39C;\n\tWed, 13 Sep 2017 12:46:14 +0200 (CEST)" ], "From": "=?utf-8?b?TGx1w61z?= Vilanova <vilanova@ac.upc.edu>", "To": "qemu-devel@nongnu.org", "Date": "Wed, 13 Sep 2017 13:46:09 +0300", "Message-Id": "<150529956916.10902.377591821566438337.stgit@frigg.lan>", "X-Mailer": "git-send-email 2.14.1", "In-Reply-To": "<150529642278.10902.18234057937634437857.stgit@frigg.lan>", "References": "<150529642278.10902.18234057937634437857.stgit@frigg.lan>", "User-Agent": "StGit/0.18", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "quoted-printable", "X-MIME-Autoconverted": "from 8bit to quoted-printable by roura.ac.upc.es id\n\tv8DAkKZ9009218", "X-detected-operating-system": "by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy]", "X-Received-From": "147.83.33.10", "Subject": "[Qemu-devel] [PATCH v6 13/22] instrument: Support synchronous\n\tmodification of vCPU state", "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": "\"Emilio G. Cota\" <cota@braap.org>, Markus Armbruster <armbru@redhat.com>,\n\tStefan Hajnoczi <stefanha@redhat.com>, =?utf-8?q?Llu=C3=ADs_Vilanova?=\n\t<vilanova@ac.upc.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": "Stops all vCPUs to allow performing management operations like TB\ninvalidations. These are later necessary to ensure translated code does not\nreference unloaded instrumentation libraries.\n\nSigned-off-by: Lluís Vilanova <vilanova@ac.upc.edu>\n---\n instrument/control.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++\n instrument/control.h | 26 ++++++++++++++++++\n instrument/control.inc.h | 11 ++++++++\n 3 files changed, 104 insertions(+)", "diff": "diff --git a/instrument/control.c b/instrument/control.c\nindex c4b3ca0440..4f9c138ccf 100644\n--- a/instrument/control.c\n+++ b/instrument/control.c\n@@ -13,6 +13,7 @@\n #include \"instrument/load.h\"\n #include \"instrument/qemu-instr/control.h\"\n #include \"qemu/compiler.h\"\n+#include \"qemu/main-loop.h\"\n #include \"qom/cpu.h\"\n \n \n@@ -40,6 +41,72 @@ void instr_cpu_remove(CPUState *vcpu)\n }\n \n \n+static void instr_cpu_stop_all__cb(CPUState *cpu, run_on_cpu_data data)\n+{\n+ InstrCPUStop *info = data.host_ptr;\n+ /* run posted function */\n+ if (info->fun) {\n+ info->fun(cpu, info->data);\n+ }\n+#if !defined(CONFIG_USER_ONLY)\n+ /* signal we're out of the main vCPU loop */\n+ unsigned int count = atomic_load_acquire(&info->count);\n+ atomic_store_release(&info->count, count + 1);\n+ atomic_store_release(&info->stopped, true);\n+ /* wait until we're good to go again */\n+ qemu_cond_wait(&info->cond, &info->mutex);\n+ count = atomic_load_acquire(&info->count);\n+ atomic_store_release(&info->count, count - 1);\n+ qemu_mutex_unlock(&info->mutex);\n+#endif\n+}\n+\n+void instr_cpu_stop_all_begin(InstrCPUStop *info,\n+ instr_cpu_stop_fun fun, void *data)\n+{\n+ CPUState *cpu;\n+\n+ info->fun = fun;\n+ info->data = data;\n+\n+#if !defined(CONFIG_USER_ONLY)\n+ info->count = 0;\n+ qemu_cond_init(&info->cond);\n+ qemu_mutex_init(&info->mutex);\n+\n+ /* main dispatch loop and run_on_cpu() lock the BQL */\n+ qemu_mutex_unlock_iothread();\n+#endif\n+\n+ CPU_FOREACH(cpu) {\n+#if !defined(CONFIG_USER_ONLY)\n+ atomic_store_release(&info->stopped, false);\n+ qemu_mutex_lock(&info->mutex);\n+ async_run_on_cpu(cpu, instr_cpu_stop_all__cb,\n+ RUN_ON_CPU_HOST_PTR(info));\n+ while (!atomic_load_acquire(&info->stopped)) {\n+ /* wait for vCPU to signal it's stopped */\n+ }\n+#else\n+ instr_cpu_stop_all__cb(cpu, RUN_ON_CPU_HOST_PTR(info));\n+#endif\n+ }\n+}\n+\n+void instr_cpu_stop_all_end(InstrCPUStop *info)\n+{\n+#if !defined(CONFIG_USER_ONLY)\n+ qemu_cond_broadcast(&info->cond);\n+ while (atomic_load_acquire(&info->count)) {\n+ /* wait for all vCPUs to continue before we can destroy info */\n+ }\n+ qemu_cond_destroy(&info->cond);\n+ qemu_mutex_destroy(&info->mutex);\n+ qemu_mutex_lock_iothread();\n+#endif\n+}\n+\n+\n qi_fini_fn instr_event__fini_fn;\n void *instr_event__fini_data;\n \ndiff --git a/instrument/control.h b/instrument/control.h\nindex 57cea07fa7..03e87b2b8f 100644\n--- a/instrument/control.h\n+++ b/instrument/control.h\n@@ -46,6 +46,32 @@ static inline QICPU instr_cpu_to_qicpu(CPUState *vcpu);\n */\n static inline CPUState *instr_cpu_from_qicpu(QICPU vcpu);\n \n+typedef struct InstrCPUStop InstrCPUStop;\n+typedef void (*instr_cpu_stop_fun)(CPUState *cpu, void *data);\n+\n+/**\n+ * instr_cpu_stop_all_begin:\n+ * @info: Opaque structure describing the operation.\n+ * @fun: Function to run on the context of each vCPU once stopped.\n+ * @data: Pointer to pass to @fun.\n+ *\n+ * Ensure all vCPUs stop executing guest code, and execute @fun on their context\n+ * in turn. Returns with all vCPUs still stopped.\n+ *\n+ * Assumes cpu_list_lock() and that the QBL is locked before calling.\n+ */\n+void instr_cpu_stop_all_begin(InstrCPUStop *info,\n+ instr_cpu_stop_fun fun, void *data);\n+\n+/**\n+ * instr_cpu_stop_all_end:\n+ * @info: Opaque structure passed to a previous instr_cpu_stop_all_begin()\n+ * call.\n+ *\n+ * Resume execution on all vCPUs stopped by instr_cpu_stop_all_begin().\n+ */\n+void instr_cpu_stop_all_end(InstrCPUStop *info);\n+\n \n /**\n * InstrState:\ndiff --git a/instrument/control.inc.h b/instrument/control.inc.h\nindex 45daae7d1d..6d65b23ead 100644\n--- a/instrument/control.inc.h\n+++ b/instrument/control.inc.h\n@@ -15,6 +15,17 @@\n #include <stdint.h>\n \n \n+struct InstrCPUStop {\n+ instr_cpu_stop_fun fun;\n+ void *data;\n+#if !defined(CONFIG_USER_ONLY)\n+ bool stopped;\n+ unsigned int count;\n+ QemuCond cond;\n+ QemuMutex mutex;\n+#endif\n+};\n+\n extern unsigned int instr_cpus_count;\n extern CPUState **instr_cpus;\n \n", "prefixes": [ "v6", "13/22" ] }