accel/tcg: Support jit profiling with VTune

This commit is contained in:
Matt Borgerson 2023-08-01 02:37:58 -07:00 committed by mborgerson
parent 1d3c7c05d4
commit edecb41b97
5 changed files with 38 additions and 0 deletions

View File

@ -12,6 +12,8 @@ tcg_ss.add(files(
tcg_ss.add(when: 'CONFIG_USER_ONLY', if_true: files('user-exec.c'))
tcg_ss.add(when: 'CONFIG_SOFTMMU', if_false: files('user-exec-stub.c'))
tcg_ss.add(when: 'CONFIG_PLUGIN', if_true: [files('plugin-gen.c')])
tcg_ss.add(when: 'CONFIG_VTUNE_JITPROFILING', if_true: [vtune_jitprofiling])
specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_ss)
specific_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_TCG'], if_true: files(

View File

@ -63,6 +63,10 @@
#include "tb-context.h"
#include "internal.h"
#if defined(CONFIG_VTUNE_JITPROFILING)
#include <jitprofiling.h>
#endif
/* make various TB consistency checks */
/**
@ -1035,6 +1039,21 @@ recycle_tb:
tcg_tb_remove(tb);
return existing_tb;
}
#if defined(CONFIG_VTUNE_JITPROFILING)
if (iJIT_IsProfilingActive() == iJIT_SAMPLING_ON && !recycled) {
iJIT_Method_Load *jmethod = g_malloc0(sizeof(iJIT_Method_Load));
jmethod->method_id = iJIT_GetNewMethodID();
jmethod->method_name = g_strdup_printf("G@0x%x", pc);
jmethod->class_file_name = NULL;
jmethod->source_file_name = NULL;
jmethod->method_load_address = (void*)tb->tc.ptr;
jmethod->method_size = tb->tc.size;
iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, (void*)jmethod);
}
#endif
return tb;
}

View File

@ -1786,6 +1786,18 @@ if have_system and get_option('renderdoc').enabled()
have_renderdoc = true
endif
have_vtune = false
vtune_path = get_option('vtune')
if vtune_path != ''
have_vtune = true
vtune_jitprofiling = declare_dependency(
dependencies: cc.find_library('jitprofiling', dirs: [vtune_path + '/lib64']),
include_directories: include_directories(vtune_path + '/include'))
config_host += { 'CONFIG_VTUNE_JITPROFILING': 'y' }
else
vtune_jitprofiling = not_found
endif
dbus_display = get_option('dbus_display') \
.require(gio.version().version_compare('>=2.64'),
error_message: '-display dbus requires glib>=2.64') \
@ -4060,6 +4072,7 @@ summary_info += {'libudev': libudev}
# Dummy dependency, keep .found()
summary_info += {'FUSE lseek': fuse_lseek.found()}
summary_info += {'selinux': selinux}
summary_info += {'vtune': have_vtune ? vtune_path : false}
summary(summary_info, bool_yn: true, section: 'Dependencies')
if not supported_cpus.contains(cpu)

View File

@ -33,6 +33,8 @@ option('fuzzing_engine', type : 'string', value : '',
description: 'fuzzing engine library for OSS-Fuzz')
option('trace_file', type: 'string', value: 'trace',
description: 'Trace file prefix for simple backend')
option('vtune', type : 'string', value : '',
description: 'Path to VTune directory for profiling')
# Everything else can be set via --enable/--disable-* option
# on the configure script command line. After adding an option

View File

@ -55,6 +55,7 @@ meson_options_help() {
printf "%s\n" ' --sysconfdir=VALUE Sysconf data directory [etc]'
printf "%s\n" ' --tls-priority=VALUE Default TLS protocol/cipher priority string'
printf "%s\n" ' [NORMAL]'
printf "%s\n" ' --vtune=VALUE Path to VTune directory for profiling'
printf "%s\n" ' --with-pkgversion=VALUE use specified string as sub-version of the'
printf "%s\n" ' package'
printf "%s\n" ' --with-trace-file=VALUE Trace file prefix for simple backend [trace]'
@ -462,6 +463,7 @@ _meson_option_parse() {
--disable-vnc-sasl) printf "%s" -Dvnc_sasl=disabled ;;
--enable-vte) printf "%s" -Dvte=enabled ;;
--disable-vte) printf "%s" -Dvte=disabled ;;
--vtune=*) quote_sh "-Dvtune=$2" ;;
--enable-vvfat) printf "%s" -Dvvfat=enabled ;;
--disable-vvfat) printf "%s" -Dvvfat=disabled ;;
--enable-whpx) printf "%s" -Dwhpx=enabled ;;