From 5e7a91097c0875ce14cb2525f695f588109b8bfa Mon Sep 17 00:00:00 2001 From: ZhuChenyanX Date: Thu, 12 Dec 2024 08:36:12 +0000 Subject: [PATCH] Fix CtsGpuProfilingDataTest fail Rename the perfetto gpu data producer name from libpps-producer to libgpudataproducer to align with AGI/cts. To pass the test, it also need following cmd: 1, echo "0" > /proc/sys/dev/i915/perf_stream_paranoid 2, setenforce 0 3, sysctl dev.i915.perf_stream_paranoid=0 sysctl dev.i915_ag.perf_stream_paranoid=0 When in vm mode, at least 1 gpu needs to be passthoughed. SRIOV mode has no metrics info provided under dir: /sys/dev/char/%d:%d/device/drm Tracked-On: OAM-128560 Signed-off-by: ZhuChenyanX --- android/Android.mk | 7 +++---- android/mesa3d_cross.mk | 1 + android/perfetto/pps-producer.cc | 29 +++++++++++++++++++++++++++-- src/intel/ds/intel_driver_ds.cc | 5 +++++ src/tool/pps/cfg/gpu.cfg | 9 +++++++++ src/tool/pps/cfg/intel.cfg | 15 +++++++++++++++ src/tool/pps/cfg/system.cfg | 15 +++++++++++++++ src/tool/pps/pps_datasource.cc | 5 +++++ src/tool/pps/pps_producer.cc | 21 ++++++++++++++++++++- 9 files changed, 100 insertions(+), 7 deletions(-) diff --git a/android/Android.mk b/android/Android.mk index 864f893ba0f..ee786579a83 100644 --- a/android/Android.mk +++ b/android/Android.mk @@ -197,8 +197,8 @@ ifneq ($(strip $(BOARD_MESA3D_GALLIUM_DRIVERS)),) $(eval $(call mesa3d-lib,libgallium_dri,.so.0,dri,MESA3D_GALLIUM_DRI_BIN)) # Module 'libglapi', produces '/vendor/lib{64}/libglapi.so' $(eval $(call mesa3d-lib,libglapi,.so.0,,MESA3D_LIBGLAPI_BIN)) -# Module 'libpps-producer', produces '/vendor/lib{64}/libpps-producer.so' -$(eval $(call mesa3d-lib,libpps-producer,.so.0,,MESA3D_LIBPPS_PRODUCER)) +# Module 'libgpudataproducer', produces '/vendor/lib{64}/libgpudataproducer.so' +$(eval $(call mesa3d-lib,libgpudataproducer,.so.0,,MESA3D_LIBPPS_PRODUCER)) # Module 'libEGL_mesa', produces '/vendor/lib{64}/egl/libEGL_mesa.so' $(eval $(call mesa3d-lib,libEGL_mesa,.so.1,egl,MESA3D_LIBEGL_BIN)) @@ -220,10 +220,9 @@ endif #------------------------------------------------------------------------------- include $(CLEAR_VARS) -LOCAL_SHARED_LIBRARIES := libpps-producer LOCAL_SRC_FILES := perfetto/pps-producer.cc LOCAL_VENDOR_MODULE := true -LOCAL_MODULE := pps-producer +LOCAL_MODULE := gpudataproducer LOCAL_CPP_EXTENSION := .cc LOCAL_MODULE_TAGS := optional include $(BUILD_EXECUTABLE) diff --git a/android/mesa3d_cross.mk b/android/mesa3d_cross.mk index 244ad815814..ae36cf020db 100644 --- a/android/mesa3d_cross.mk +++ b/android/mesa3d_cross.mk @@ -96,6 +96,7 @@ MESON_GEN_NINJA := \ -Dlmsensors=disabled \ -Dandroid-libbacktrace=disabled \ -Dperfetto=true \ + -Ddatasources=auto \ $(BOARD_MESA3D_MESON_ARGS) \ MESON_BUILD := PATH=/usr/bin:/bin:/sbin:$$PATH ninja -C $(MESON_OUT_DIR)/build diff --git a/android/perfetto/pps-producer.cc b/android/perfetto/pps-producer.cc index e829e0949cb..bec2b60b728 100644 --- a/android/perfetto/pps-producer.cc +++ b/android/perfetto/pps-producer.cc @@ -1,5 +1,30 @@ -extern int pps_main(int argc, const char **argv); +#include +#include + +typedef void (*pps_main_fn_t)(int, const char **); + +#define PPS_LIB "/vendor/lib64/libgpudataproducer.so" int main(int argc, const char **argv) { - return pps_main(argc, argv); + char *error; + + void *handle = dlopen(PPS_LIB, RTLD_GLOBAL); + if ((error = dlerror()) != nullptr || handle == nullptr) { + fprintf(stdout, "Error loading lib: %s\n", error); + return -1; + } + + pps_main_fn_t ppsFn = (pps_main_fn_t)dlsym(handle, "pps_main"); + if (((error = dlerror()) != nullptr) || (ppsFn == nullptr)) { + fprintf(stdout, "Error looking for pps_main symbol: %s\n", error); + dlclose(handle); + return -1; + } + + fprintf(stdout, "start call pps_main\n"); + (*ppsFn)(argc, argv); + fprintf(stdout, "end call pps_main\n"); + + dlclose(handle); + return 0; } diff --git a/src/intel/ds/intel_driver_ds.cc b/src/intel/ds/intel_driver_ds.cc index cc732658a31..843c43f4867 100644 --- a/src/intel/ds/intel_driver_ds.cc +++ b/src/intel/ds/intel_driver_ds.cc @@ -566,7 +566,12 @@ intel_driver_ds_init_once(void) #ifdef HAVE_PERFETTO util_perfetto_init(); perfetto::DataSourceDescriptor dsd; +#ifdef ANDROID + /* AGI requires this name */ + dsd.set_name("gpu.renderstages"); +#else dsd.set_name("gpu.renderstages.intel"); +#endif IntelRenderpassDataSource::Register(dsd); #endif } diff --git a/src/tool/pps/cfg/gpu.cfg b/src/tool/pps/cfg/gpu.cfg index 11cdfa8f82a..7759d655736 100644 --- a/src/tool/pps/cfg/gpu.cfg +++ b/src/tool/pps/cfg/gpu.cfg @@ -21,4 +21,13 @@ data_sources { } } +data_sources { + config { + name: "gpu.counters" + gpu_counter_config { + counter_period_ns: 1000000000 + } + } +} + duration_ms: 16000 diff --git a/src/tool/pps/cfg/intel.cfg b/src/tool/pps/cfg/intel.cfg index bb9e2d22dbc..4b9ce40099a 100644 --- a/src/tool/pps/cfg/intel.cfg +++ b/src/tool/pps/cfg/intel.cfg @@ -58,6 +58,21 @@ data_sources { } } +data_sources { + config { + name: "gpu.counters" + gpu_counter_config { + counter_period_ns: 100000 + } + } +} + +data_sources { + config { + name: "gpu.renderstages" + } +} + data_sources { config { name: "track_event" diff --git a/src/tool/pps/cfg/system.cfg b/src/tool/pps/cfg/system.cfg index f48f5f943a3..87fbaefca80 100644 --- a/src/tool/pps/cfg/system.cfg +++ b/src/tool/pps/cfg/system.cfg @@ -39,6 +39,21 @@ data_sources { } } +data_sources { + config { + name: "gpu.counters" + gpu_counter_config { + counter_period_ns: 100000 + } + } +} + +data_sources { + config { + name: "gpu.renderstages" + } +} + data_sources { config { name: "track_event" diff --git a/src/tool/pps/pps_datasource.cc b/src/tool/pps/pps_datasource.cc index 99ca51d6b7c..92c9453e16d 100644 --- a/src/tool/pps/pps_datasource.cc +++ b/src/tool/pps/pps_datasource.cc @@ -324,7 +324,12 @@ void GpuDataSource::register_data_source(const std::string &_driver_name) { driver_name = _driver_name; static perfetto::DataSourceDescriptor dsd; +#ifdef ANDROID + /* AGI requires this name */ + dsd.set_name("gpu.counters"); +#else dsd.set_name("gpu.counters." + driver_name); +#endif Driver * driver = nullptr; auto drm_devices = DrmDevice::create_all(); diff --git a/src/tool/pps/pps_producer.cc b/src/tool/pps/pps_producer.cc index c84c6806f51..6266b5df56a 100644 --- a/src/tool/pps/pps_producer.cc +++ b/src/tool/pps/pps_producer.cc @@ -11,7 +11,7 @@ #include "pps_datasource.h" -int pps_main(int argc, const char **argv) +extern "C" int pps_main(int argc, const char **argv) { using namespace pps; @@ -35,3 +35,22 @@ int pps_main(int argc, const char **argv) return EXIT_SUCCESS; } + +extern "C" void start() +{ + using namespace pps; + + // Connects to the system tracing service + perfetto::TracingInitArgs args; + args.backends = perfetto::kSystemBackend; + perfetto::Tracing::Initialize(args); + + GpuDataSource::register_data_source(Driver::default_driver_name()); + + while (true) { + GpuDataSource::wait_started(); + GpuDataSource::Trace(GpuDataSource::trace_callback); + } + + return; +} \ No newline at end of file