Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/810748/?format=api
{ "id": 810748, "url": "http://patchwork.ozlabs.org/api/patches/810748/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/150472122675.24907.11597641982841030964.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": "<150472122675.24907.11597641982841030964.stgit@frigg.lan>", "list_archive_url": null, "date": "2017-09-06T18:07:06", "name": "[v4,11/20] instrument: Track vCPUs", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "46038e740da76c84d99f461fa01578283cec3b2f", "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/150472122675.24907.11597641982841030964.stgit@frigg.lan/mbox/", "series": [ { "id": 1859, "url": "http://patchwork.ozlabs.org/api/series/1859/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=1859", "date": "2017-09-06T17:22:41", "name": "instrument: Add basic event instrumentation", "version": 4, "mbox": "http://patchwork.ozlabs.org/series/1859/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/810748/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/810748/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 3xnWm93nHsz9rxl\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 7 Sep 2017 04:08:25 +1000 (AEST)", "from localhost ([::1]:37371 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 1dpekR-00078x-K8\n\tfor incoming@patchwork.ozlabs.org; Wed, 06 Sep 2017 14:08:23 -0400", "from eggs.gnu.org ([2001:4830:134:3::10]:46714)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <vilanova@ac.upc.edu>) id 1dpejT-0006gd-OV\n\tfor qemu-devel@nongnu.org; Wed, 06 Sep 2017 14:07:28 -0400", "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <vilanova@ac.upc.edu>) id 1dpejP-0008Sg-Fb\n\tfor qemu-devel@nongnu.org; Wed, 06 Sep 2017 14:07:23 -0400", "from roura.ac.upc.es ([147.83.33.10]:56132)\n\tby eggs.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <vilanova@ac.upc.edu>) id 1dpejP-0008PE-4n\n\tfor qemu-devel@nongnu.org; Wed, 06 Sep 2017 14:07:19 -0400", "from correu-1.ac.upc.es (correu-1.ac.upc.es [147.83.30.91])\n\tby roura.ac.upc.es (8.13.8/8.13.8) with ESMTP id v86I7Dur004766;\n\tWed, 6 Sep 2017 20:07:13 +0200", "from localhost (unknown [31.210.187.58])\n\tby correu-1.ac.upc.es (Postfix) with ESMTPSA id 2F70A8AF;\n\tWed, 6 Sep 2017 20:07:08 +0200 (CEST)" ], "From": "=?utf-8?b?TGx1w61z?= Vilanova <vilanova@ac.upc.edu>", "To": "qemu-devel@nongnu.org", "Date": "Wed, 6 Sep 2017 21:07:06 +0300", "Message-Id": "<150472122675.24907.11597641982841030964.stgit@frigg.lan>", "X-Mailer": "git-send-email 2.14.1", "In-Reply-To": "<150471856141.24907.274176769201097378.stgit@frigg.lan>", "References": "<150471856141.24907.274176769201097378.stgit@frigg.lan>", "User-Agent": "StGit/0.17.1-dirty", "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\tv86I7Dur004766", "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 v4 11/20] instrument: Track vCPUs", "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>, =?utf-8?q?Llu=C3=ADs_Vilanova?=\n\t<vilanova@ac.upc.edu>, \tStefan Hajnoczi <stefanha@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": "Keep a translation between instrumentation's QICPU and CPUState objects to avoid\nexposing QEMU's internals to instrumentation clients.\n\nSigned-off-by: Lluís Vilanova <vilanova@ac.upc.edu>\n---\n cpus-common.c | 9 +++++++++\n instrument/control.c | 22 ++++++++++++++++++++++\n instrument/control.h | 32 ++++++++++++++++++++++++++++++++\n instrument/control.inc.h | 23 +++++++++++++++++++++++\n 4 files changed, 86 insertions(+)", "diff": "diff --git a/cpus-common.c b/cpus-common.c\nindex 59f751ecf9..ec5f46cc3d 100644\n--- a/cpus-common.c\n+++ b/cpus-common.c\n@@ -22,6 +22,9 @@\n #include \"exec/cpu-common.h\"\n #include \"qom/cpu.h\"\n #include \"sysemu/cpus.h\"\n+#if defined(CONFIG_INSTRUMENT)\n+#include \"instrument/control.h\"\n+#endif\n \n static QemuMutex qemu_cpu_list_lock;\n static QemuCond exclusive_cond;\n@@ -84,6 +87,9 @@ void cpu_list_add(CPUState *cpu)\n } else {\n assert(!cpu_index_auto_assigned);\n }\n+#if defined(CONFIG_INSTRUMENT)\n+ instr_cpu_add(cpu);\n+#endif\n QTAILQ_INSERT_TAIL(&cpus, cpu, node);\n qemu_mutex_unlock(&qemu_cpu_list_lock);\n \n@@ -102,6 +108,9 @@ void cpu_list_remove(CPUState *cpu)\n assert(!(cpu_index_auto_assigned && cpu != QTAILQ_LAST(&cpus, CPUTailQ)));\n \n QTAILQ_REMOVE(&cpus, cpu, node);\n+#if defined(CONFIG_INSTRUMENT)\n+ instr_cpu_remove(cpu);\n+#endif\n cpu->cpu_index = UNASSIGNED_CPU_INDEX;\n qemu_mutex_unlock(&qemu_cpu_list_lock);\n }\ndiff --git a/instrument/control.c b/instrument/control.c\nindex 2c2781beeb..83453ea561 100644\n--- a/instrument/control.c\n+++ b/instrument/control.c\n@@ -13,10 +13,32 @@\n #include \"instrument/load.h\"\n #include \"instrument/qemu-instr/control.h\"\n #include \"instrument/qemu-instr/visibility.h\"\n+#include \"qom/cpu.h\"\n+\n \n __thread InstrState instr_cur_state;\n \n \n+unsigned int instr_cpus_count;\n+CPUState **instr_cpus;\n+\n+void instr_cpu_add(CPUState *vcpu)\n+{\n+ unsigned int idx = vcpu->cpu_index;\n+ if (idx >= instr_cpus_count) {\n+ instr_cpus_count = idx + 1;\n+ instr_cpus = realloc(instr_cpus, sizeof(*instr_cpus) * instr_cpus_count);\n+ }\n+ instr_cpus[idx] = vcpu;\n+}\n+\n+void instr_cpu_remove(CPUState *vcpu)\n+{\n+ unsigned int idx = vcpu->cpu_index;\n+ instr_cpus[idx] = NULL;\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 f2b085f69b..0c37692465 100644\n--- a/instrument/control.h\n+++ b/instrument/control.h\n@@ -10,6 +10,38 @@\n #ifndef INSTRUMENT__CONTROL_H\n #define INSTRUMENT__CONTROL_H\n \n+#include \"qemu/typedefs.h\"\n+#include \"instrument/qemu-instr/types.h\"\n+\n+\n+/**\n+ * instr_cpu_add:\n+ *\n+ * Make @vcpu available to instrumentation clients.\n+ */\n+void instr_cpu_add(CPUState *vcpu);\n+\n+/**\n+ * instr_cpu_remove:\n+ *\n+ * Make @vcpu unavailable to instrumentation clients.\n+ */\n+void instr_cpu_remove(CPUState *vcpu);\n+\n+/**\n+ * instr_cpu_get:\n+ *\n+ * Get the #CPUState corresponding to the given #QICPU.\n+ */\n+static inline CPUState *instr_cpu_get(QICPU vcpu);\n+\n+/**\n+ * instr_cpu_set:\n+ *\n+ * Get the #QICPU corresponding to the given #CPUState.\n+ */\n+static inline QICPU instr_cpu_set(CPUState *vcpu);\n+\n \n /**\n * InstrState:\ndiff --git a/instrument/control.inc.h b/instrument/control.inc.h\nindex 0f649f4caa..18ae6a34cc 100644\n--- a/instrument/control.inc.h\n+++ b/instrument/control.inc.h\n@@ -7,9 +7,12 @@\n * See the COPYING file in the top-level directory.\n */\n \n+#include \"qemu/osdep.h\"\n #include \"qemu/atomic.h\"\n #include \"qemu/compiler.h\"\n+#include \"qom/cpu.h\"\n #include <stdbool.h>\n+#include <stdint.h>\n \n \n extern __thread InstrState instr_cur_state;\n@@ -23,3 +26,23 @@ static inline InstrState instr_get_state(void)\n {\n return atomic_load_acquire(&instr_cur_state);\n }\n+\n+\n+extern unsigned int instr_cpus_count;\n+extern CPUState **instr_cpus;\n+\n+static inline CPUState *instr_cpu_get(QICPU vcpu)\n+{\n+ unsigned int idx = (uintptr_t)vcpu;\n+ if (idx >= instr_cpus_count) {\n+ return NULL;\n+ } else {\n+ return instr_cpus[idx];\n+ }\n+}\n+\n+static inline QICPU instr_cpu_set(CPUState *vcpu)\n+{\n+ uintptr_t idx = vcpu->cpu_index;\n+ return (QICPU )idx;\n+}\n", "prefixes": [ "v4", "11/20" ] }