accel/tcg: Move perf and debuginfo support to tcg
v4 cover accel/tcg: Move perf and debuginfo support to tcg
Based-on: [email protected]
v3 -> v4: Rebase on top of Philippe's series.
Move perf.h and debuginfo.h (Richard).
v2: https://patchew.org/QEMU/[email protected]/
v2 -> v3: Rebased.
This series was lost and forgotten until Philippe reminded me about it.
v1: https://lists.gnu.org/archive/html/qemu-devel/2023-06/msg07037.html
v1 -> v2: Move qemu_target_page_mask() hunk to patch 1.
Fix typos.
Hi,
This series is a follow-up to discussion in [1]; the goal is to build perf and debuginfo support only one time.
Best regards,
Ilya
[1] https://lists.gnu.org/archive/html/qemu-devel/2023-06/msg06510.html
Ilya Leoshkevich (4):
accel/tcg: Make use of qemu_target_page_mask() in perf.c
tcg: Make tb_cflags() usable from target-agnostic code accel/tcg: Remove #ifdef TARGET_I386 from perf.c accel/tcg: Move perf and debuginfo support to tcg
accel/tcg/meson.build | 2 --
accel/tcg/translate-all.c | 2 +-
hw/core/loader.c | 2 +-
include/exec/exec-all.h | 6 ------
include/exec/translation-block.h | 6 ++++++
{accel => include}/tcg/debuginfo.h | 4 ++--
{accel => include}/tcg/perf.h | 4 ++--
linux-user/elfload.c | 2 +-
linux-user/exit.c | 2 +-
linux-user/main.c | 2 +-
system/vl.c | 2 +-
{accel/tcg => tcg}/debuginfo.c | 3 +--
tcg/meson.build | 3 +++
{accel/tcg => tcg}/perf.c | 14 +++++---------
tcg/tcg.c | 2 +-
15 files changed, 26 insertions(+), 30 deletions(-)
rename {accel => include}/tcg/debuginfo.h (96%)
rename {accel => include}/tcg/perf.h (95%)
rename {accel/tcg => tcg}/debuginfo.c (98%)
rename {accel/tcg => tcg}/perf.c (97%)Signature · 1 line
2.43.0
PATCH v4 1/4 accel/tcg: Make use of qemu_target_page_mask() in perf.c
Stop using TARGET_PAGE_MASK in order to make perf.c more target-agnostic.
--- accel/tcg/perf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
accel/tcg/perf.c +2 -1
@@ -10,6 +10,7 @@#include "qemu/osdep.h" #include "elf.h" +#include "exec/target_page.h" #include "exec/exec-all.h" #include "qemu/timer.h" #include "tcg/tcg.h"
@@ -335,7 +336,7 @@ void perf_report_code(uint64_t guest_pc, TranslationBlock *tb,/* FIXME: This replicates the restore_state_to_opc() logic. */ q[insn].address = gen_insn_data[insn * start_words +0 ];if (tb_cflags (tb) &CF_PCREL ) { - q[insn].address |= (guest_pc &TARGET_PAGE_MASK ); + q[insn].address |= (guest_pc &qemu_target_page_mask ()); }else {#if defined(TARGET_I386 ) q[insn].address -= tb->cs_base;
Signature · 1 line
2.43.0
Re: [PATCH v4 1/4] accel/tcg: Make use of qemu_target_page_mask() in perf.c
Quoted 7 lines · Ilya Leoshkevich
Stop using
TARGET_PAGE_MASKin order to makeperf.cmore target-agnostic.Signed-off-by Ilya Leoshkevich <[email protected]>--- accel/tcg/perf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Re: [PATCH v4 1/4] accel/tcg: Make use of qemu_target_page_mask() in perf.c
In reply to Ilya LeoshkevichQuoted 4 lines · Ilya Leoshkevich
Stop using
TARGET_PAGE_MASKin order to makeperf.cmore target-agnostic.Signed-off-by Ilya Leoshkevich <[email protected]>
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro
PATCH v4 2/4 tcg: Make tb_cflags() usable from target-agnostic code
In reply to Ilya LeoshkevichCurrently tb_cflags() is defined in exec-all.h, which is not usable from target-agnostic code. Move it to translation-block.h, which is.
--- include/exec/exec-all.h | 6 ------ include/exec/translation-block.h | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-)
include/exec/exec-all.h +0 -6
@@ -460,12 +460,6 @@ int probe_access_full_mmu(CPUArchState *env, vaddr addr, int size,#endif -/* Hide the qatomic_read to make code a little easier on the eyes */ -static inline uint32_t tb_cflags (const TranslationBlock *tb) -{ -return qatomic_read (&tb->cflags); -} -static inline tb_page_addr_t tb_page_addr0 (const TranslationBlock *tb) {#ifdef CONFIG_USER_ONLY
include/exec/translation-block.h +6 -0
@@ -145,4 +145,10 @@ struct TranslationBlock {/* The alignment given to TranslationBlock during allocation. */ #define CODE_GEN_ALIGN 16 +/* Hide the qatomic_read to make code a little easier on the eyes */ +static inline uint32_t tb_cflags (const TranslationBlock *tb) +{ +return qatomic_read (&tb->cflags); +} +#endif /* EXEC_TRANSLATION_BLOCK_H */
Signature · 1 line
2.43.0
PATCH v4 3/4 accel/tcg: Remove #ifdef TARGET_I386 from perf.c
In reply to Ilya LeoshkevichPreparation for moving perf.c to tcg/.
This affects only profiling guest code, which has code in a non-0 based segment, e.g., 16-bit code, which is not particularly important.
--- accel/tcg/perf.c | 4 ---- 1 file changed, 4 deletions(-)
accel/tcg/perf.c +0 -4
@@ -337,10 +337,6 @@ void perf_report_code(uint64_t guest_pc, TranslationBlock *tb, q[insn].address = gen_insn_data[insn * start_words +0 ];if (tb_cflags (tb) &CF_PCREL ) { q[insn].address |= (guest_pc &qemu_target_page_mask ()); - }else { -#if defined(TARGET_I386 ) - q[insn].address -= tb->cs_base; -#endif } q[insn].flags =DEBUGINFO_SYMBOL | (jitdump ?DEBUGINFO_LINE :0 ); }
Signature · 1 line
2.43.0
PATCH v4 4/4 accel/tcg: Move perf and debuginfo support to tcg
In reply to Ilya Leoshkevichtcg/ should not depend on accel/tcg/, but perf and debuginfo support provided by the latter are being used by tcg/tcg.c.
Since that's the only user, move both to tcg/.
---
accel/tcg/meson.build | 2 --
accel/tcg/translate-all.c | 2 +-
hw/core/loader.c | 2 +-
{accel => include}/tcg/debuginfo.h | 4 ++--
{accel => include}/tcg/perf.h | 4 ++--
linux-user/elfload.c | 2 +-
linux-user/exit.c | 2 +-
linux-user/main.c | 2 +-
system/vl.c | 2 +-
{accel/tcg => tcg}/debuginfo.c | 3 +--
tcg/meson.build | 3 +++
{accel/tcg => tcg}/perf.c | 7 +++----
tcg/tcg.c | 2 +-
13 files changed, 18 insertions(+), 19 deletions(-)
rename {accel => include}/tcg/debuginfo.h (96%)
rename {accel => include}/tcg/perf.h (95%)
rename {accel/tcg => tcg}/debuginfo.c (98%)
rename {accel/tcg => tcg}/perf.c (99%)accel/tcg/meson.build +0 -2
@@ -16,8 +16,6 @@ tcg_ss.add(when: 'CONFIG_SYSTEM_ONLY', if_false: files('user-exec-stub.c')) if get_option('plugins') tcg_ss.add(files('plugin-gen.c')) endif -tcg_ss.add(when: libdw, if_true: files('debuginfo.c')) -tcg_ss.add(when: 'CONFIG_LINUX', if_true: files('perf.c')) specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_ss) specific_ss.add(when: ['CONFIG_SYSTEM_ONLY', 'CONFIG_TCG'], if_true: files(
accel/tcg/translate-all.c +1 -1
@@ -63,7 +63,7 @@#include "tb-context.h" #include "internal-common.h" #include "internal-target.h" -#include "perf.h" +#include "tcg/perf.h" #include "tcg/insn-start-words.h" TBContext tb_ctx;
hw/core/loader.c +1 -1
@@ -62,7 +62,7 @@#include "hw/boards.h" #include "qemu/cutils.h" #include "sysemu/runstate.h" -#include "accel/tcg/debuginfo.h" +#include "tcg/debuginfo.h" #include <zlib.h>
include/tcg/debuginfo.h renamed from accel/tcg/debuginfo.h +2 -2
@@ -4,8 +4,8 @@* SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef ACCEL_TCG_DEBUGINFO_H -#define ACCEL_TCG_DEBUGINFO_H +#ifndef TCG_DEBUGINFO_H +#define TCG_DEBUGINFO_H #include "qemu/bitops.h"
include/tcg/perf.h renamed from accel/tcg/perf.h +2 -2
@@ -4,8 +4,8 @@* SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef ACCEL_TCG_PERF_H -#define ACCEL_TCG_PERF_H +#ifndef TCG_PERF_H +#define TCG_PERF_H #if defined(CONFIG_TCG ) && defined(CONFIG_LINUX )/* Start writing perf-<pid>.map. */
linux-user/elfload.c +1 -1
@@ -23,7 +23,7 @@#include "qapi/error.h" #include "qemu/error-report.h" #include "target_signal.h" -#include "accel/tcg/debuginfo.h" +#include "tcg/debuginfo.h" #ifdef TARGET_ARM #include "target/arm/cpu-features.h"
linux-user/exit.c +1 -1
@@ -17,7 +17,7 @@* along with this program; if not, see <http://www.gnu.org/licenses/>. */ #include "qemu/osdep.h" -#include "accel/tcg/perf.h" +#include "tcg/perf.h" #include "gdbstub/syscalls.h" #include "qemu.h" #include "user-internals.h"
linux-user/main.c +1 -1
@@ -55,7 +55,7 @@#include "signal-common.h" #include "loader.h" #include "user-mmap.h" -#include "accel/tcg/perf.h" +#include "tcg/perf.h" #ifdef CONFIG_SEMIHOSTING #include "semihosting/semihost.h"
system/vl.c +1 -1
@@ -96,7 +96,7 @@#endif #include "sysemu/qtest.h" #ifdef CONFIG_TCG -#include "accel/tcg/perf.h" +#include "tcg/perf.h" #endif #include "disas/disas.h"
tcg/debuginfo.c renamed from accel/tcg/debuginfo.c +1 -2
@@ -6,11 +6,10 @@#include "qemu/osdep.h" #include "qemu/lockable.h" +#include "tcg/debuginfo.h" #include <elfutils/libdwfl.h> -#include "debuginfo.h" -static QemuMutex lock;static Dwfl *dwfl;static const Dwfl_Callbacks dwfl_callbacks = {
tcg/meson.build +3 -0
@@ -22,6 +22,9 @@ if get_option('tcg_interpreter') tcg_ss.add(files('tci.c')) endif +tcg_ss.add(when: libdw, if_true: files('debuginfo.c')) +tcg_ss.add(when: 'CONFIG_LINUX', if_true: files('perf.c')) + tcg_ss = tcg_ss.apply(config_targetos, strict: false) libtcg_user = static_library('tcg_user',
tcg/perf.c renamed from accel/tcg/perf.c +3 -4
@@ -11,13 +11,12 @@#include "qemu/osdep.h" #include "elf.h" #include "exec/target_page.h" -#include "exec/exec-all.h" +#include "exec/translation-block.h" #include "qemu/timer.h" +#include "tcg/debuginfo.h" +#include "tcg/perf.h" #include "tcg/tcg.h" -#include "debuginfo.h" -#include "perf.h" -static FILE *safe_fopen_w (const char *path) {int saved_errno;
tcg/tcg.c +1 -1
@@ -55,7 +55,7 @@#include "tcg/tcg-ldst.h" #include "tcg/tcg-temp-internal.h" #include "tcg-internal.h" -#include "accel/tcg/perf.h" +#include "tcg/perf.h" #ifdef CONFIG_USER_ONLY #include "exec/user/guest-base.h" #endif
Signature · 1 line
2.43.0
Hi Ilya,
Quoted 7 lines · Ilya Leoshkevich
Based-on: [email protected]
Ilya Leoshkevich (4):
accel/tcg: Make use ofqemu_target_page_mask()inperf.c
tcg: Maketb_cflags()usable from target-agnostic code accel/tcg: Remove #ifdefTARGET_I386fromperf.caccel/tcg: Move perf and debuginfo support to tcg
I'm queuing your series as part of my accel/tcg/ rework, and will post a PR during the 9.0 dev cycle.
Thanks!
Phil.