Skip to content

Commit

Permalink
Fix CtsGpuProfilingDataTest fail
Browse files Browse the repository at this point in the history
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-128278
Signed-off-by: ZhuChenyanX <[email protected]>
  • Loading branch information
ZhuChenyanX authored and chenyanxzhu committed Dec 12, 2024
1 parent 20e130e commit 4509da0
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 7 deletions.
7 changes: 3 additions & 4 deletions android/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions android/mesa3d_cross.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 27 additions & 2 deletions android/perfetto/pps-producer.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
extern int pps_main(int argc, const char **argv);
#include <cstdio>
#include <dlfcn.h>

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;
}
5 changes: 5 additions & 0 deletions src/intel/ds/intel_driver_ds.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
9 changes: 9 additions & 0 deletions src/tool/pps/cfg/gpu.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,13 @@ data_sources {
}
}

data_sources {
config {
name: "gpu.counters"
gpu_counter_config {
counter_period_ns: 1000000000
}
}
}

duration_ms: 16000
15 changes: 15 additions & 0 deletions src/tool/pps/cfg/intel.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
15 changes: 15 additions & 0 deletions src/tool/pps/cfg/system.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions src/tool/pps/pps_datasource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
21 changes: 20 additions & 1 deletion src/tool/pps/pps_producer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}

0 comments on commit 4509da0

Please sign in to comment.