Skip to contentSkip to conversation

lib/intel_batchbuffer: reset allocator before subtest

PATCH Superseded Kamil Konieczny 3 participants 4 messages Feb 1, 2022 Library code

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover lib/intel_batchbuffer: reset allocator before subtest

igt_core inits intel_allocator before next subtest and this makes allocator handle keeped in intel_batchbuffer invalid. Moreover any call to intel_allocator can result in fail as there are no allocators until first allocator_open.

Reset allocator in intel_batchbuffer and recreate its offsets before next subtest run.

Add flag for turn on tracking with default off and helper for turning it on/off. It will not change behaviour of already used tests.

v2: add flag for tracking with default off (Zbigniew review)

Kamil Konieczny (1):
lib/intel_batchbuffer: add tracking and reset for allocator

 lib/igt_core.c          |  2 ++
 lib/intel_batchbuffer.c | 61 +++++++++++++++++++++++++++++++++++++++++
 lib/intel_batchbuffer.h |  7 +++++
 3 files changed, 70 insertions(+)
Signature · 1 line
2.32.0
#1 lore raw

PATCH v2 1/1 lib/intel_batchbuffer: add tracking and reset for allocator

After subtest ends, due to normal flow or after fail by igt_assert, igt_core inits intel_allocator before next subtest, and this makes allocator handle keeped in intel_batchbuffer invalid. Moreover any call to intel_allocator can result in fail as there are no allocators until first allocator_open.

Add tracking intel_butchbuffer if it is using allocator and recreate its allocator handle and offsets from igt_core before next subtest.

Add flag for turn on tracking and a helper function for it. It will not change behaviour of already used tests. Use case is for standalone runs with many subtests like gem_concurrent_blit.

v2: add tracking flag with default off (Zbigniew)

Cc Zbigniew Kempczyński <[email protected]>
---
 lib/igt_core.c          |  2 ++
 lib/intel_batchbuffer.c | 61 +++++++++++++++++++++++++++++++++++++++++
 lib/intel_batchbuffer.h |  7 +++++
 3 files changed, 70 insertions(+)
lib/igt_core.c +2 -0
index 7c906675..ab27a24d 100644
@@ -59,6 +59,7 @@
 
 #include "drmtest.h"
 #include "intel_allocator.h"
+#include "intel_batchbuffer.h"
 #include "intel_chipset.h"
 #include "intel_io.h"
 #include "igt_debugfs.h"
@@ -1426,6 +1427,7 @@ __noreturn static void exit_subtest(const char *result)
 	 * remnants from previous allocator run (if any).
 	 */
 	intel_allocator_init();
+	intel_bb_reinit_allocator();
 
 	if (!in_dynamic_subtest)
 		_igt_dynamic_tests_executed = -1;
lib/intel_batchbuffer.c +61 -0

88 lines not on this page · raw message

lib/intel_batchbuffer.h +7 -0
index e7606307..15413b34 100644
@@ -456,7 +456,10 @@ struct igt_pxp {
  * Batchbuffer without libdrm dependency
  */
 struct intel_bb {
+	struct igt_list_head link;
+
 	uint64_t allocator_handle;
+	uint64_t allocator_start, allocator_end;
 	uint8_t allocator_type;
 	enum allocator_strategy allocator_strategy;
 
@@ -524,6 +527,10 @@ struct intel_bb *
 intel_bb_create_with_relocs_and_context(int i915, uint32_t ctx, uint32_t size);
 void intel_bb_destroy(struct intel_bb *ibb);
 
+// make it safe to use intel_allocator after failed test
+void intel_bb_reinit_allocator(void);
+void intel_bb_track(bool do_tracking);
+
 static inline void intel_bb_ref(struct intel_bb *ibb)
 {
 	ibb->refcount++;
Signature · 1 line
2.32.0
#2 lore raw

Re: [igt-dev] [PATCH i-g-t v2 1/1] lib/intel_batchbuffer: add tracking and reset for allocator

Quoted 10 lines · Kamil Konieczny

After subtest ends, due to normal flow or after fail by igt_assert, igt_core inits intel_allocator before next subtest, and this makes allocator handle keeped in intel_batchbuffer invalid. Moreover any call to intel_allocator can result in fail as there are no allocators until first allocator_open.

Add tracking intel_butchbuffer if it is using allocator and recreate its allocator handle and offsets from igt_core before next subtest.

Quoted 8 lines

Add flag for turn on tracking and a helper function for it. It will not change behaviour of already used tests. Use case is for standalone runs with many subtests like gem_concurrent_blit.

v2: add tracking flag with default off (Zbigniew)

Cc Zbigniew Kempczyński <[email protected]>

You've missed my two comments, scroll down:

Quoted 78 lines
---
 lib/igt_core.c          |  2 ++
 lib/intel_batchbuffer.c | 61 +++++++++++++++++++++++++++++++++++++++++
 lib/intel_batchbuffer.h |  7 +++++
 3 files changed, 70 insertions(+)
lib/igt_core.c +2 -0
index 7c906675..ab27a24d 100644
@@ -59,6 +59,7 @@
 
 #include "drmtest.h"
 #include "intel_allocator.h"
+#include "intel_batchbuffer.h"
 #include "intel_chipset.h"
 #include "intel_io.h"
 #include "igt_debugfs.h"
@@ -1426,6 +1427,7 @@ __noreturn static void exit_subtest(const char *result)
 	 * remnants from previous allocator run (if any).
 	 */
 	intel_allocator_init();
+	intel_bb_reinit_allocator();
 
 	if (!in_dynamic_subtest)
 		_igt_dynamic_tests_executed = -1;
lib/intel_batchbuffer.c +19 -0
index 10d8a6e0..7870e5a4 100644
@@ -80,6 +80,10 @@
  * library as a dependency.
  */
 
+static bool intel_bb_do_tracking;
+static IGT_LIST_HEAD(intel_bb_list);
+static pthread_mutex_t intel_bb_list_lock = PTHREAD_MUTEX_INITIALIZER;
+
 /**
  * intel_batchbuffer_align:
  * @batch: batchbuffer object
@@ -1359,6 +1363,9 @@ __intel_bb_create(int i915, uint32_t ctx, uint32_t size, bool do_relocs,
 								  strategy);
 	ibb->allocator_type = allocator_type;
 	ibb->allocator_strategy = strategy;
+	ibb->allocator_start = start;
+	ibb->allocator_end = end;
+
 	ibb->i915 = i915;
 	ibb->enforce_relocs = do_relocs;
 	ibb->handle = gem_create(i915, size);
@@ -1384,6 +1391,12 @@ __intel_bb_create(int i915, uint32_t ctx, uint32_t size, bool do_relocs,
 
 	ibb->refcount = 1;
 
+	if (intel_bb_do_tracking && ibb->allocator_type != INTEL_ALLOCATOR_NONE) {
+		pthread_mutex_lock(&intel_bb_list_lock);
+		igt_list_add(&ibb->link, &intel_bb_list);
+		pthread_mutex_unlock(&intel_bb_list_lock);
+	}
+
 	return ibb;
 }
 
@@ -1600,6 +1613,12 @@ void intel_bb_destroy(struct intel_bb *ibb)
 	__intel_bb_destroy_cache(ibb);
 
 	if (ibb->allocator_type != INTEL_ALLOCATOR_NONE) {
+		if (intel_bb_do_tracking) {
+			pthread_mutex_lock(&intel_bb_list_lock);
+			igt_list_del(&ibb->link);
+			pthread_mutex_unlock(&intel_bb_list_lock);
+		}
+
 		intel_allocator_free(ibb->allocator_handle, ibb->handle);
 		intel_allocator_close(ibb->allocator_handle);
 	}

lib/intel_batchbuffer.c igt_huc_copyfunc_t igt_get_huc_copyfunc(int devid) · line 2981

Quoted 4 lines
lib/intel_batchbuffer.c +1 -0
@@ -2959,3 +2978,45 @@ igt_huc_copyfunc_t igt_get_huc_copyfunc(int devid)
 
 	return copy;
 }
+

Add documentation to public functions.

Quoted 19 lines
lib/intel_batchbuffer.c +19 -0
+void intel_bb_track(bool do_tracking)
+{
+	if (intel_bb_do_tracking == do_tracking)
+		return;
+
+	if (intel_bb_do_tracking) {
+		struct intel_bb *entry, *tmp;
+
+		pthread_mutex_lock(&intel_bb_list_lock);
+		igt_list_for_each_entry_safe(entry, tmp, &intel_bb_list, link)
+			igt_list_del(&entry->link);
+		pthread_mutex_unlock(&intel_bb_list_lock);
+	}
+
+	intel_bb_do_tracking = do_tracking;
+}
+
+void __intel_bb_reinit_alloc(struct intel_bb *ibb)
+{

lib/intel_batchbuffer.c igt_huc_copyfunc_t igt_get_huc_copyfunc(int devid) · line 3010

Quoted 10 lines
lib/intel_batchbuffer.c +10 -0
+	if (ibb->allocator_type == INTEL_ALLOCATOR_NONE)
+		return;
+
+	ibb->allocator_handle = intel_allocator_open_full(ibb->i915, ibb->ctx,
+							  ibb->allocator_start, ibb->allocator_end,
+							  ibb->allocator_type,
+							  ibb->allocator_strategy);
+	intel_bb_reset(ibb, true);
+}
+

Same here.

Quoted 28 lines
lib/intel_batchbuffer.c +12 -0
+void intel_bb_reinit_allocator(void)
+{
+	struct intel_bb *iter;
+
+	if (!intel_bb_do_tracking)
+		return;
+
+	pthread_mutex_lock(&intel_bb_list_lock);
+	igt_list_for_each_entry(iter, &intel_bb_list, link)
+		__intel_bb_reinit_alloc(iter);
+	pthread_mutex_unlock(&intel_bb_list_lock);
+}
lib/intel_batchbuffer.h +3 -0
index e7606307..15413b34 100644
@@ -456,7 +456,10 @@ struct igt_pxp {
  * Batchbuffer without libdrm dependency
  */
 struct intel_bb {
+	struct igt_list_head link;
+
 	uint64_t allocator_handle;
+	uint64_t allocator_start, allocator_end;
 	uint8_t allocator_type;
 	enum allocator_strategy allocator_strategy;
 

lib/intel_batchbuffer.h struct intel_bb * · line 530

Quoted 4 lines
lib/intel_batchbuffer.h +1 -0
@@ -524,6 +527,10 @@ struct intel_bb *
 intel_bb_create_with_relocs_and_context(int i915, uint32_t ctx, uint32_t size);
 void intel_bb_destroy(struct intel_bb *ibb);
 
+// make it safe to use intel_allocator after failed test

We've previously agreed we use C style comments only in IGT so use /* and */

--
Zbigniew

Quoted 9 lines
lib/intel_batchbuffer.h +3 -0
+void intel_bb_reinit_allocator(void);
+void intel_bb_track(bool do_tracking);
+
 static inline void intel_bb_ref(struct intel_bb *ibb)
 {
 	ibb->refcount++;
Signature · 1 line
2.32.0
#3 lore raw

[igt-dev] ✗ Fi.CI.BAT: failure for lib/intel_batchbuffer: reset allocator before subtest (rev3)

In reply to Kamil Konieczny
== Series Details ==

== Series Details ==

Series: lib/intel_batchbuffer: reset allocator before subtest (rev3)
URL : https://patchwork.freedesktop.org/series/99478/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_11173 -> IGTPW_6591
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with IGTPW_6591 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in IGTPW_6591, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6591/index.html

Participating hosts (43 -> 44)
------------------------------

Additional (2): fi-icl-u2 fi-pnv-d510
Missing (1): fi-bdw-samus

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in IGTPW_6591:

### IGT changes ###

#### Possible regressions ####

* igt@i915_selftest@live@gt_lrc:
- fi-rkl-guc: [PASS][1] -> [INCOMPLETE][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11173/fi-rkl-guc/igt@i915_selftest@live@gt_lrc.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6591/fi-rkl-guc/igt@i915_selftest@live@gt_lrc.html

Known issues
------------

Here are the changes found in IGTPW_6591 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@amdgpu/amd_cs_nop@fork-gfx0:
- fi-icl-u2: NOTRUN -> [SKIP][3] ([fdo#109315]) +17 similar issues
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6591/fi-icl-u2/igt@amdgpu/[email protected]

* igt@gem_huc_copy@huc-copy:
- fi-skl-6600u: NOTRUN -> [SKIP][4] ([fdo#109271] / [i915#2190])
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6591/fi-skl-6600u/igt@[email protected]
- fi-icl-u2: NOTRUN -> [SKIP][5] ([i915#2190])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6591/fi-icl-u2/igt@[email protected]

* igt@gem_lmem_swapping@parallel-random-engines:
- fi-icl-u2: NOTRUN -> [SKIP][6] ([i915#4613]) +3 similar issues
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6591/fi-icl-u2/igt@[email protected]

* igt@gem_lmem_swapping@verify-random:
- fi-skl-6600u: NOTRUN -> [SKIP][7] ([fdo#109271] / [i915#4613]) +3 similar issues
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6591/fi-skl-6600u/igt@[email protected]

* igt@kms_chamelium@hdmi-hpd-fast:
- fi-icl-u2: NOTRUN -> [SKIP][8] ([fdo#111827]) +8 similar issues
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6591/fi-icl-u2/igt@[email protected]

* igt@kms_chamelium@vga-edid-read:
- fi-skl-6600u: NOTRUN -> [SKIP][9] ([fdo#109271] / [fdo#111827]) +8 similar issues
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6591/fi-skl-6600u/igt@[email protected]

* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy:
- fi-icl-u2: NOTRUN -> [SKIP][10] ([fdo#109278]) +2 similar issues
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6591/fi-icl-u2/igt@[email protected]
- fi-skl-6600u: NOTRUN -> [SKIP][11] ([fdo#109271]) +2 similar issues
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6591/fi-skl-6600u/igt@[email protected]

* igt@kms_force_connector_basic@force-load-detect:
- fi-icl-u2: NOTRUN -> [SKIP][12] ([fdo#109285])
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6591/fi-icl-u2/igt@[email protected]

* igt@kms_pipe_crc_basic@compare-crc-sanitycheck-pipe-d:
- fi-skl-6600u: NOTRUN -> [SKIP][13] ([fdo#109271] / [i915#533])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6591/fi-skl-6600u/igt@[email protected]

* igt@kms_psr@primary_page_flip:
- fi-skl-6600u: NOTRUN -> [INCOMPLETE][14] ([i915#4547] / [i915#4838])
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6591/fi-skl-6600u/igt@kms_psr@primary_page_flip.html

* igt@prime_vgem@basic-userptr:
- fi-pnv-d510: NOTRUN -> [SKIP][15] ([fdo#109271]) +57 similar issues
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6591/fi-pnv-d510/igt@[email protected]
- fi-icl-u2: NOTRUN -> [SKIP][16] ([i915#3301])
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6591/fi-icl-u2/igt@[email protected]

* igt@runner@aborted:
- fi-skl-6600u: NOTRUN -> [FAIL][17] ([i915#2722] / [i915#4312])
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6591/fi-skl-6600u/igt@[email protected]

#### Possible fixes ####

* igt@gem_exec_suspend@basic-s3@smem:
- fi-skl-6600u: [INCOMPLETE][18] ([i915#4547]) -> [PASS][19]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11173/fi-skl-6600u/igt@gem_exec_suspend@[email protected]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6591/fi-skl-6600u/igt@gem_exec_suspend@[email protected]

* igt@kms_frontbuffer_tracking@basic:
- fi-cml-u2: [DMESG-WARN][20] ([i915#4269]) -> [PASS][21]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11173/fi-cml-u2/igt@[email protected]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6591/fi-cml-u2/igt@[email protected]

[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[fdo#109315]: https://bugs.freedesktop.org/show_bug.cgi?id=109315
[fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
[i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190
[i915#2722]: https://gitlab.freedesktop.org/drm/intel/issues/2722
[i915#3301]: https://gitlab.freedesktop.org/drm/intel/issues/3301
[i915#4269]: https://gitlab.freedesktop.org/drm/intel/issues/4269
[i915#4312]: https://gitlab.freedesktop.org/drm/intel/issues/4312
[i915#4547]: https://gitlab.freedesktop.org/drm/intel/issues/4547
[i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
[i915#4838]: https://gitlab.freedesktop.org/drm/intel/issues/4838
[i915#533]: https://gitlab.freedesktop.org/drm/intel/issues/533

Build changes
-------------

* CI: CI-20190529 -> None
* IGT: IGT_6337 -> IGTPW_6591

CI-20190529: 20190529
CI_DRM_11173: 519df8ed94419812cc3999abc4a023d0e4df2cd0 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_6591: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6591/index.html
IGT_6337: 7c9c034619ef9dbfbfe041fbf3973a1cf1ac7a22 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6591/index.html