* [Qemu-devel] [PATCH v0 1/4] accel: split the tcg accelerator from accel.c file
2017-05-19 5:09 [Qemu-devel] [PATCH v0 0/4] split the tcg code and separate tcg files Yang Zhong
@ 2017-05-19 5:09 ` Yang Zhong
2017-05-19 5:09 ` [Qemu-devel] [PATCH v0 2/4] move cputlb.c Yang Zhong
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Yang Zhong @ 2017-05-19 5:09 UTC (permalink / raw)
To: eblake; +Cc: qemu-devel, pbonzini, anthony.xu, Yang Zhong
there are two accelerators in qemu, kvm and tcg. kvm
accelerator is defined in kvm-all.c, but tcg accelerator
is defined in accel.c file. we split tcg accelerator from
accel.c file and create one new accel directory, which
will include kvm and tcg accel files.
Signed-off-by: Yang Zhong <yang.zhong@intel.com>
---
Makefile.objs | 1 -
Makefile.target | 1 +
accel/Makefile.objs | 2 ++
accel.c => accel/accel.c | 27 ---------------------
accel/tcg/Makefile.objs | 1 +
accel/tcg/tcg-all.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 65 insertions(+), 28 deletions(-)
create mode 100644 accel/Makefile.objs
rename accel.c => accel/accel.c (87%)
create mode 100644 accel/tcg/Makefile.objs
create mode 100644 accel/tcg/tcg-all.c
diff --git a/Makefile.objs b/Makefile.objs
index 6167e7b..2a8de77 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -55,7 +55,6 @@ common-obj-$(CONFIG_SPICE) += spice-qemu-char.o
common-obj-y += audio/
common-obj-y += hw/
-common-obj-y += accel.o
common-obj-y += replay/
diff --git a/Makefile.target b/Makefile.target
index 465a633..ba893a8 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -143,6 +143,7 @@ obj-y += arch_init.o cpus.o monitor.o gdbstub.o balloon.o ioport.o numa.o
obj-y += qtest.o bootdevice.o
obj-y += hw/
obj-$(CONFIG_KVM) += kvm-all.o
+obj-y += accel/
obj-y += memory.o cputlb.o
obj-y += memory_mapping.o
obj-y += dump.o
diff --git a/accel/Makefile.objs b/accel/Makefile.objs
new file mode 100644
index 0000000..11ad823
--- /dev/null
+++ b/accel/Makefile.objs
@@ -0,0 +1,2 @@
+obj-$(CONFIG_SOFTMMU) += accel.o
+obj-y += tcg/
diff --git a/accel.c b/accel/accel.c
similarity index 87%
rename from accel.c
rename to accel/accel.c
index 664bb88..7c079a5 100644
--- a/accel.c
+++ b/accel/accel.c
@@ -34,15 +34,6 @@
#include "hw/xen/xen.h"
#include "qom/object.h"
-int tcg_tb_size;
-static bool tcg_allowed = true;
-
-static int tcg_init(MachineState *ms)
-{
- tcg_exec_init(tcg_tb_size * 1024 * 1024);
- return 0;
-}
-
static const TypeInfo accel_type = {
.name = TYPE_ACCEL,
.parent = TYPE_OBJECT,
@@ -129,27 +120,9 @@ void configure_accelerator(MachineState *ms)
}
}
-
-static void tcg_accel_class_init(ObjectClass *oc, void *data)
-{
- AccelClass *ac = ACCEL_CLASS(oc);
- ac->name = "tcg";
- ac->init_machine = tcg_init;
- ac->allowed = &tcg_allowed;
-}
-
-#define TYPE_TCG_ACCEL ACCEL_CLASS_NAME("tcg")
-
-static const TypeInfo tcg_accel_type = {
- .name = TYPE_TCG_ACCEL,
- .parent = TYPE_ACCEL,
- .class_init = tcg_accel_class_init,
-};
-
static void register_accel_types(void)
{
type_register_static(&accel_type);
- type_register_static(&tcg_accel_type);
}
type_init(register_accel_types);
diff --git a/accel/tcg/Makefile.objs b/accel/tcg/Makefile.objs
new file mode 100644
index 0000000..6e3211a
--- /dev/null
+++ b/accel/tcg/Makefile.objs
@@ -0,0 +1 @@
+obj-$(CONFIG_SOFTMMU) += tcg-all.o
diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
new file mode 100644
index 0000000..dba9931
--- /dev/null
+++ b/accel/tcg/tcg-all.c
@@ -0,0 +1,61 @@
+/*
+ * QEMU System Emulator, accelerator interfaces
+ *
+ * Copyright (c) 2003-2008 Fabrice Bellard
+ * Copyright (c) 2014 Red Hat Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "qemu/osdep.h"
+#include "sysemu/accel.h"
+#include "sysemu/sysemu.h"
+#include "qom/object.h"
+
+int tcg_tb_size;
+static bool tcg_allowed = true;
+
+static int tcg_init(MachineState *ms)
+{
+ tcg_exec_init(tcg_tb_size * 1024 * 1024);
+ return 0;
+}
+
+static void tcg_accel_class_init(ObjectClass *oc, void *data)
+{
+ AccelClass *ac = ACCEL_CLASS(oc);
+ ac->name = "tcg";
+ ac->init_machine = tcg_init;
+ ac->allowed = &tcg_allowed;
+}
+
+#define TYPE_TCG_ACCEL ACCEL_CLASS_NAME("tcg")
+
+static const TypeInfo tcg_accel_type = {
+ .name = TYPE_TCG_ACCEL,
+ .parent = TYPE_ACCEL,
+ .class_init = tcg_accel_class_init,
+};
+
+static void register_accel_types(void)
+{
+ type_register_static(&tcg_accel_type);
+}
+
+type_init(register_accel_types);
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH v0 2/4] move cputlb.c
2017-05-19 5:09 [Qemu-devel] [PATCH v0 0/4] split the tcg code and separate tcg files Yang Zhong
2017-05-19 5:09 ` [Qemu-devel] [PATCH v0 1/4] accel: split the tcg accelerator from accel.c file Yang Zhong
@ 2017-05-19 5:09 ` Yang Zhong
2017-05-19 5:09 ` [Qemu-devel] [PATCH v0 3/4] move cpu-exec.c Yang Zhong
2017-05-19 5:09 ` [Qemu-devel] [PATCH v0 4/4] move cpu-exec-common.c Yang Zhong
3 siblings, 0 replies; 5+ messages in thread
From: Yang Zhong @ 2017-05-19 5:09 UTC (permalink / raw)
To: eblake; +Cc: qemu-devel, pbonzini, anthony.xu, Yang Zhong
move cputlb.c to accel/tcg/
Signed-off-by: Yang Zhong <yang.zhong@intel.com>
---
Makefile.target | 2 +-
accel/tcg/Makefile.objs | 1 +
cputlb.c => accel/tcg/cputlb.c | 0
3 files changed, 2 insertions(+), 1 deletion(-)
rename cputlb.c => accel/tcg/cputlb.c (100%)
diff --git a/Makefile.target b/Makefile.target
index ba893a8..3e19fe9 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -144,7 +144,7 @@ obj-y += qtest.o bootdevice.o
obj-y += hw/
obj-$(CONFIG_KVM) += kvm-all.o
obj-y += accel/
-obj-y += memory.o cputlb.o
+obj-y += memory.o
obj-y += memory_mapping.o
obj-y += dump.o
obj-y += migration/ram.o migration/savevm.o
diff --git a/accel/tcg/Makefile.objs b/accel/tcg/Makefile.objs
index 6e3211a..487570f 100644
--- a/accel/tcg/Makefile.objs
+++ b/accel/tcg/Makefile.objs
@@ -1 +1,2 @@
obj-$(CONFIG_SOFTMMU) += tcg-all.o
+obj-$(CONFIG_SOFTMMU) += cputlb.o
diff --git a/cputlb.c b/accel/tcg/cputlb.c
similarity index 100%
rename from cputlb.c
rename to accel/tcg/cputlb.c
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH v0 3/4] move cpu-exec.c
2017-05-19 5:09 [Qemu-devel] [PATCH v0 0/4] split the tcg code and separate tcg files Yang Zhong
2017-05-19 5:09 ` [Qemu-devel] [PATCH v0 1/4] accel: split the tcg accelerator from accel.c file Yang Zhong
2017-05-19 5:09 ` [Qemu-devel] [PATCH v0 2/4] move cputlb.c Yang Zhong
@ 2017-05-19 5:09 ` Yang Zhong
2017-05-19 5:09 ` [Qemu-devel] [PATCH v0 4/4] move cpu-exec-common.c Yang Zhong
3 siblings, 0 replies; 5+ messages in thread
From: Yang Zhong @ 2017-05-19 5:09 UTC (permalink / raw)
To: eblake; +Cc: qemu-devel, pbonzini, anthony.xu, Yang Zhong
move cpu-exec.c to ./accel/tcg/
Signed-off-by: Yang Zhong <yang.zhong@intel.com>
---
Makefile.objs | 1 +
Makefile.target | 4 ++--
accel/tcg/Makefile.objs | 1 +
cpu-exec.c => accel/tcg/cpu-exec.c | 5 +++--
accel/tcg/trace-events | 7 +++++++
trace-events | 5 -----
6 files changed, 14 insertions(+), 9 deletions(-)
rename cpu-exec.c => accel/tcg/cpu-exec.c (99%)
create mode 100644 accel/tcg/trace-events
diff --git a/Makefile.objs b/Makefile.objs
index 2a8de77..6a33874 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -163,6 +163,7 @@ trace-events-subdirs += target/ppc
trace-events-subdirs += qom
trace-events-subdirs += linux-user
trace-events-subdirs += qapi
+trace-events-subdirs += accel/tcg
trace-events-files = $(SRC_PATH)/trace-events $(trace-events-subdirs:%=$(SRC_PATH)/%/trace-events)
diff --git a/Makefile.target b/Makefile.target
index 3e19fe9..709d07a 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -88,7 +88,8 @@ all: $(PROGS) stap
#########################################################
# cpu emulator library
-obj-y = exec.o translate-all.o cpu-exec.o
+obj-y = exec.o translate-all.o
+obj-y += accel/
obj-y += translate-common.o
obj-y += cpu-exec-common.o
obj-y += tcg/tcg.o tcg/tcg-op.o tcg/optimize.o
@@ -143,7 +144,6 @@ obj-y += arch_init.o cpus.o monitor.o gdbstub.o balloon.o ioport.o numa.o
obj-y += qtest.o bootdevice.o
obj-y += hw/
obj-$(CONFIG_KVM) += kvm-all.o
-obj-y += accel/
obj-y += memory.o
obj-y += memory_mapping.o
obj-y += dump.o
diff --git a/accel/tcg/Makefile.objs b/accel/tcg/Makefile.objs
index 487570f..6b75a31 100644
--- a/accel/tcg/Makefile.objs
+++ b/accel/tcg/Makefile.objs
@@ -1,2 +1,3 @@
obj-$(CONFIG_SOFTMMU) += tcg-all.o
obj-$(CONFIG_SOFTMMU) += cputlb.o
+obj-y += cpu-exec.o
diff --git a/cpu-exec.c b/accel/tcg/cpu-exec.c
similarity index 99%
rename from cpu-exec.c
rename to accel/tcg/cpu-exec.c
index 63a56d0..2019160 100644
--- a/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -18,7 +18,7 @@
*/
#include "qemu/osdep.h"
#include "cpu.h"
-#include "trace-root.h"
+#include "trace.h"
#include "disas/disas.h"
#include "exec/exec-all.h"
#include "tcg.h"
@@ -200,8 +200,9 @@ static void cpu_exec_nocache(CPUState *cpu, int max_cycles,
/* Should never happen.
We only end up here when an existing TB is too long. */
- if (max_cycles > CF_COUNT_MASK)
+ if (max_cycles > CF_COUNT_MASK) {
max_cycles = CF_COUNT_MASK;
+ }
tb_lock();
tb = tb_gen_code(cpu, orig_tb->pc, orig_tb->cs_base, orig_tb->flags,
diff --git a/accel/tcg/trace-events b/accel/tcg/trace-events
new file mode 100644
index 0000000..f2db388
--- /dev/null
+++ b/accel/tcg/trace-events
@@ -0,0 +1,7 @@
+# Trace events for debugging and performance instrumentation
+
+# TCG related tracing (mostly disabled by default)
+# cpu-exec.c
+disable exec_tb(void *tb, uintptr_t pc) "tb:%p pc=0x%"PRIxPTR
+disable exec_tb_nocache(void *tb, uintptr_t pc) "tb:%p pc=0x%"PRIxPTR
+disable exec_tb_exit(void *last_tb, unsigned int flags) "tb:%p flags=%x"
diff --git a/trace-events b/trace-events
index e582d63..153942d 100644
--- a/trace-events
+++ b/trace-events
@@ -73,11 +73,6 @@ kvm_irqchip_add_msi_route(int virq) "Adding MSI route virq=%d"
kvm_irqchip_update_msi_route(int virq) "Updating MSI route virq=%d"
# TCG related tracing (mostly disabled by default)
-# cpu-exec.c
-disable exec_tb(void *tb, uintptr_t pc) "tb:%p pc=0x%"PRIxPTR
-disable exec_tb_nocache(void *tb, uintptr_t pc) "tb:%p pc=0x%"PRIxPTR
-disable exec_tb_exit(void *last_tb, unsigned int flags) "tb:%p flags=%x"
-
# translate-all.c
translate_block(void *tb, uintptr_t pc, uint8_t *tb_code) "tb:%p, pc:0x%"PRIxPTR", tb_code:%p"
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH v0 4/4] move cpu-exec-common.c
2017-05-19 5:09 [Qemu-devel] [PATCH v0 0/4] split the tcg code and separate tcg files Yang Zhong
` (2 preceding siblings ...)
2017-05-19 5:09 ` [Qemu-devel] [PATCH v0 3/4] move cpu-exec.c Yang Zhong
@ 2017-05-19 5:09 ` Yang Zhong
3 siblings, 0 replies; 5+ messages in thread
From: Yang Zhong @ 2017-05-19 5:09 UTC (permalink / raw)
To: eblake; +Cc: qemu-devel, pbonzini, anthony.xu, Yang Zhong
move cpu-exec-common.c to accel/tcg
Signed-off-by: Yang Zhong <yang.zhong@intel.com>
---
Makefile.target | 1 -
accel/tcg/Makefile.objs | 2 +-
cpu-exec-common.c => accel/tcg/cpu-exec-common.c | 0
3 files changed, 1 insertion(+), 2 deletions(-)
rename cpu-exec-common.c => accel/tcg/cpu-exec-common.c (100%)
diff --git a/Makefile.target b/Makefile.target
index 709d07a..b083a76 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -91,7 +91,6 @@ all: $(PROGS) stap
obj-y = exec.o translate-all.o
obj-y += accel/
obj-y += translate-common.o
-obj-y += cpu-exec-common.o
obj-y += tcg/tcg.o tcg/tcg-op.o tcg/optimize.o
obj-$(CONFIG_TCG_INTERPRETER) += tci.o
obj-y += tcg/tcg-common.o
diff --git a/accel/tcg/Makefile.objs b/accel/tcg/Makefile.objs
index 6b75a31..940379b 100644
--- a/accel/tcg/Makefile.objs
+++ b/accel/tcg/Makefile.objs
@@ -1,3 +1,3 @@
obj-$(CONFIG_SOFTMMU) += tcg-all.o
obj-$(CONFIG_SOFTMMU) += cputlb.o
-obj-y += cpu-exec.o
+obj-y += cpu-exec.o cpu-exec-common.o
diff --git a/cpu-exec-common.c b/accel/tcg/cpu-exec-common.c
similarity index 100%
rename from cpu-exec-common.c
rename to accel/tcg/cpu-exec-common.c
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread