diff mbox

[i-g-t,5/7] tests/perf_pmu: Tests for i915 PMU API

Message ID 20170929125835.n3pbdgz4tupswryq@platvala-desk.ger.corp.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Petri Latvala Sept. 29, 2017, 12:58 p.m. UTC
On Fri, Sep 29, 2017 at 01:39:37PM +0100, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> 
> A bunch of tests for the new i915 PMU feature.
> 
> Parts of the code were initialy sketched by Dmitry Rogozhkin.
> 
> v2: (Most suggestions by Chris Wilson)
>  * Add new class/instance based engine list.
>  * Add gem_has_engine/gem_require_engine to work with class/instance.
>  * Use the above two throughout the test.
>  * Shorten tests to 100ms busy batches, seems enough.
>  * Add queued counter sanity checks.
>  * Use igt_nsec_elapsed.
>  * Skip on perf -ENODEV in some tests instead of embedding knowledge locally.
>  * Fix multi ordering for busy accounting.
>  * Use new guranteed_usleep when sleep time is asserted on.
>  * Check for no queued when idle/busy.
>  * Add queued counter init test.
>  * Add queued tests.
>  * Consolidate and increase multiple busy engines tests to most-busy and
>    all-busy tests.
>  * Guarantte interrupts by using fences.
>  * Test RC6 via forcewake.
> 
> v3:
>  * Tweak assert in interrupts subtest.
>  * Sprinkle of comments.
>  * Fix multi-client test which got broken in v2.
> 
> v4:
>  * Measured instead of guaranteed sleep.
>  * Missing sync in no_sema.
>  * Log busyness before asserts for debug.
>  * access(2) instead of open(2) to determine if cpu0 is hotpluggable.
>  * Test frequency reporting via min/max setting instead assuming.
>    ^^ All above suggested by Chris Wilson. ^^
>  * Drop queued subtests to match i915.
>  * Use long batches with fences to ensure interrupts.
>  * Test render node as well.
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
> ---
>  lib/igt_gt.c           |  50 +++
>  lib/igt_gt.h           |  38 ++
>  lib/igt_perf.h         |   9 +-
>  tests/Makefile.am      |   1 +
>  tests/Makefile.sources |   1 +
>  tests/perf_pmu.c       | 957 +++++++++++++++++++++++++++++++++++++++++++++++++
>  6 files changed, 1048 insertions(+), 8 deletions(-)
>  create mode 100644 tests/perf_pmu.c
> 
> diff --git a/lib/igt_gt.c b/lib/igt_gt.c
> index b3f3b3809eee..4c75811fb1b3 100644
> --- a/lib/igt_gt.c
> +++ b/lib/igt_gt.c
> @@ -568,3 +568,53 @@ bool gem_can_store_dword(int fd, unsigned int engine)
>  
>  	return true;
>  }
> +
> +const struct intel_execution_engine2 intel_execution_engines2[] = {
> +	{ "rcs0", I915_ENGINE_CLASS_RENDER, 0 },
> +	{ "bcs0", I915_ENGINE_CLASS_COPY, 0 },
> +	{ "vcs0", I915_ENGINE_CLASS_VIDEO, 0 },
> +	{ "vcs1", I915_ENGINE_CLASS_VIDEO, 1 },
> +	{ "vecs0", I915_ENGINE_CLASS_VIDEO_ENHANCE, 0 },
> +};
> +
> +unsigned int
> +gem_class_instance_to_eb_flags(int gem_fd,
> +			       enum drm_i915_gem_engine_class class,
> +			       unsigned int instance)
> +{
> +	if (class != I915_ENGINE_CLASS_VIDEO)
> +		igt_assert(instance == 0);
> +	else
> +		igt_assert(instance >= 0 && instance <= 1);
> +
> +	switch (class) {
> +	case I915_ENGINE_CLASS_RENDER:
> +		return I915_EXEC_RENDER;
> +	case I915_ENGINE_CLASS_COPY:
> +		return I915_EXEC_BLT;
> +	case I915_ENGINE_CLASS_VIDEO:
> +		if (instance == 0) {
> +			if (gem_has_bsd2(gem_fd))
> +				return I915_EXEC_BSD | I915_EXEC_BSD_RING1;
> +			else
> +				return I915_EXEC_BSD;
> +
> +		} else {
> +			return I915_EXEC_BSD | I915_EXEC_BSD_RING2;
> +		}
> +	case I915_ENGINE_CLASS_VIDEO_ENHANCE:
> +		return I915_EXEC_VEBOX;
> +	case I915_ENGINE_CLASS_OTHER:
> +	default:
> +		igt_assert(0);
> +	};
> +}
> +
> +bool gem_has_engine(int gem_fd,
> +		    enum drm_i915_gem_engine_class class,
> +		    unsigned int instance)
> +{
> +	return gem_has_ring(gem_fd,
> +			    gem_class_instance_to_eb_flags(gem_fd, class,
> +							   instance));
> +}
> diff --git a/lib/igt_gt.h b/lib/igt_gt.h
> index 2579cbd37be7..fb67ae1a7d1f 100644
> --- a/lib/igt_gt.h
> +++ b/lib/igt_gt.h
> @@ -25,6 +25,7 @@
>  #define IGT_GT_H
>  
>  #include "igt_debugfs.h"
> +#include "igt_core.h"
>  
>  void igt_require_hang_ring(int fd, int ring);
>  
> @@ -80,4 +81,41 @@ extern const struct intel_execution_engine {
>  
>  bool gem_can_store_dword(int fd, unsigned int engine);
>  
> +extern const struct intel_execution_engine2 {
> +	const char *name;
> +	int class;
> +	int instance;
> +} intel_execution_engines2[];
> +
> +#define for_each_engine_class_instance(fd__, e__) \
> +	for ((e__) = intel_execution_engines2;\
> +	     (e__)->name; \
> +	     (e__)++)
> +
> +enum drm_i915_gem_engine_class {
> +	I915_ENGINE_CLASS_OTHER = 0,
> +	I915_ENGINE_CLASS_RENDER = 1,
> +	I915_ENGINE_CLASS_COPY = 2,
> +	I915_ENGINE_CLASS_VIDEO = 3,
> +	I915_ENGINE_CLASS_VIDEO_ENHANCE = 4,
> +	I915_ENGINE_CLASS_MAX /* non-ABI */
> +};
> +
> +unsigned int
> +gem_class_instance_to_eb_flags(int gem_fd,
> +			       enum drm_i915_gem_engine_class class,
> +			       unsigned int instance);
> +
> +bool gem_has_engine(int gem_fd,
> +		    enum drm_i915_gem_engine_class class,
> +		    unsigned int instance);
> +
> +static inline
> +void gem_require_engine(int gem_fd,
> +			enum drm_i915_gem_engine_class class,
> +			unsigned int instance)
> +{
> +	igt_require(gem_has_engine(gem_fd, class, instance));
> +}
> +
>  #endif /* IGT_GT_H */
> diff --git a/lib/igt_perf.h b/lib/igt_perf.h
> index e38171da5261..dc4df760f531 100644
> --- a/lib/igt_perf.h
> +++ b/lib/igt_perf.h
> @@ -29,14 +29,7 @@
>  
>  #include <linux/perf_event.h>
>  
> -enum drm_i915_gem_engine_class {
> -	I915_ENGINE_CLASS_OTHER = 0,
> -	I915_ENGINE_CLASS_RENDER = 1,
> -	I915_ENGINE_CLASS_COPY = 2,
> -	I915_ENGINE_CLASS_VIDEO = 3,
> -	I915_ENGINE_CLASS_VIDEO_ENHANCE = 4,
> -	I915_ENGINE_CLASS_MAX /* non-ABI */
> -};
> +#include "igt_gt.h"
>  
>  enum drm_i915_pmu_engine_sample {
>  	I915_SAMPLE_BUSY = 0,
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index 1cea4036d00f..2819df381df7 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -126,6 +126,7 @@ gen7_forcewake_mt_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
>  gen7_forcewake_mt_LDADD = $(LDADD) -lpthread
>  gem_userptr_blits_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
>  gem_userptr_blits_LDADD = $(LDADD) -lpthread
> +perf_pmu_LDADD = $(LDADD) $(top_builddir)/lib/libigt_perf.la
>  
>  gem_wait_LDADD = $(LDADD) -lrt
>  kms_flip_LDADD = $(LDADD) -lrt -lpthread
> diff --git a/tests/Makefile.sources b/tests/Makefile.sources
> index 0adc28a014d2..7d1fdf16892d 100644
> --- a/tests/Makefile.sources
> +++ b/tests/Makefile.sources
> @@ -217,6 +217,7 @@ TESTS_progs = \
>  	kms_vblank \
>  	meta_test \
>  	perf \
> +	perf_pmu \
>  	pm_backlight \
>  	pm_lpsp \
>  	pm_rc6_residency \



For meson:

#  patchwork please this is not a new revision
#      diff --git a/tests/meson.build b/tests/meson.build
index 53d02d13..50a97785 100644
diff mbox

Patch

--- a/tests/meson.build
+++ b/tests/meson.build
@@ -197,6 +197,7 @@  test_progs = [
 	'kms_vblank',
 	'meta_test',
 	'perf',
+	'perf_pmu',
 	'pm_backlight',
 	'pm_lpsp',
 	'pm_rc6_residency',