Skip to contentSkip to conversation

gem_flink_race/prime_self_import: Improve test reliability

PATCH Superseded Derek Morton 2 participants 7 messages Dec 8, 2015 – Dec 14, 2015

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gem_flink_race/prime_self_import: Improve test reliability

gem_flink_race and prime_self_import have subtests which read the number of open gem objects from debugfs to determine if objects have leaked during the test. However the test can fail sporadically if the number of gem objects changes due to other process activity. This patch introduces a change to check the number of gem objects several times to filter out any fluctuations.

---
 tests/gem_flink_race.c    | 34 +++++++++++++++++++++++++++++-----
 tests/prime_self_import.c | 43 +++++++++++++++++++++++++++++++++----------
 2 files changed, 62 insertions(+), 15 deletions(-)
tests/gem_flink_race.c +29 -5
index b17ef85..0552e12 100644
@@ -44,7 +44,7 @@ IGT_TEST_DESCRIPTION("Check for flink/open vs. gem close races.");
  * in the flink name and corresponding reference getting leaked.
  */
 
-/* We want lockless and I'm to lazy to dig out an atomic libarary. On x86 this
+/* We want lockless and I'm to lazy to dig out an atomic library. On x86 this
  * works, too. */
 volatile int pls_die = 0;
 int fd;
@@ -65,6 +65,32 @@ static int get_object_count(void)
 	return ret;
 }
 
+static int get_stable_obj_count(int driver)
+{
+	/* The test relies on the system being in the same state before and
+	   after the test so any difference in the object count is a result of
+	   leaks during the test. gem_quiescent_gpu() mostly achieves this but
+	   occasionally obj_count can still change. The loop ensures obj_count
+	   has remained stable over several checks */
+	int obj_count, prev_obj_count;
+	int loop_count = 0;
+	gem_quiescent_gpu(driver);
+	prev_obj_count = get_object_count();
+	while (loop_count < 4) {
+		usleep(200000);
+		gem_quiescent_gpu(driver);
+		obj_count = get_object_count();
+		if (obj_count == prev_obj_count) {
+			loop_count++;
+		} else {
+			igt_debug("loop_count=%d, obj_count=%d, prev_obj_count=%d\n", loop_count, obj_count, prev_obj_count);
+			loop_count = 0;
+			prev_obj_count = obj_count;
+		}
+
+	}
+	return obj_count;
+}
 
 static void *thread_fn_flink_name(void *p)
 {
@@ -164,8 +190,7 @@ static void test_flink_close(void)
 	 * up the counts */
 	fake = drm_open_driver(DRIVER_INTEL);
 
-	gem_quiescent_gpu(fake);
-	obj_count = get_object_count();
+	obj_count = get_stable_obj_count(fake);
 
 	num_threads = sysconf(_SC_NPROCESSORS_ONLN);
 
@@ -190,8 +215,7 @@ static void test_flink_close(void)
 
 	close(fd);
 
-	gem_quiescent_gpu(fake);
-	obj_count = get_object_count() - obj_count;
+	obj_count = get_stable_obj_count(fake) - obj_count;
 
 	igt_info("leaked %i objects\n", obj_count);
 
tests/prime_self_import.c +33 -10

85 lines not on this page · raw message

Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw
Quoted 6 lines · Derek Morton

gem_flink_race and prime_self_import have subtests which read the number of open gem objects from debugfs to determine if objects have leaked during the test. However the test can fail sporadically if the number of gem objects changes due to other process activity. This patch introduces a change to check the number of gem objects several times to filter out any fluctuations.

Why exactly does this happen? IGT tests should be run on bare metal, with everything else killed/subdued/shutup. If there's still things going on that create objects, we need to stop them from doing that.

If this only applies to Android, or some special Android deamon them imo check for that at runtime and igt_skip("your setup is invalid, deamon %s running\n"); is the correct fix. After all just because you sampled for a bit doesn't mean that it wont still change right when you start running the test for real, so this is still fragile.

Also would be good to extract get_stable_obj_count to a proper igt library function, if it indeed needs to be this tricky. And then add the explanation for why we need this in the gtkdoc.

Thanks, Daniel

Quoted 176 lines
---
 tests/gem_flink_race.c    | 34 +++++++++++++++++++++++++++++-----
 tests/prime_self_import.c | 43 +++++++++++++++++++++++++++++++++----------
 2 files changed, 62 insertions(+), 15 deletions(-)
tests/gem_flink_race.c +29 -5
index b17ef85..0552e12 100644
@@ -44,7 +44,7 @@ IGT_TEST_DESCRIPTION("Check for flink/open vs. gem close races.");
  * in the flink name and corresponding reference getting leaked.
  */
 
-/* We want lockless and I'm to lazy to dig out an atomic libarary. On x86 this
+/* We want lockless and I'm to lazy to dig out an atomic library. On x86 this
  * works, too. */
 volatile int pls_die = 0;
 int fd;
@@ -65,6 +65,32 @@ static int get_object_count(void)
 	return ret;
 }
 
+static int get_stable_obj_count(int driver)
+{
+	/* The test relies on the system being in the same state before and
+	   after the test so any difference in the object count is a result of
+	   leaks during the test. gem_quiescent_gpu() mostly achieves this but
+	   occasionally obj_count can still change. The loop ensures obj_count
+	   has remained stable over several checks */
+	int obj_count, prev_obj_count;
+	int loop_count = 0;
+	gem_quiescent_gpu(driver);
+	prev_obj_count = get_object_count();
+	while (loop_count < 4) {
+		usleep(200000);
+		gem_quiescent_gpu(driver);
+		obj_count = get_object_count();
+		if (obj_count == prev_obj_count) {
+			loop_count++;
+		} else {
+			igt_debug("loop_count=%d, obj_count=%d, prev_obj_count=%d\n", loop_count, obj_count, prev_obj_count);
+			loop_count = 0;
+			prev_obj_count = obj_count;
+		}
+
+	}
+	return obj_count;
+}
 
 static void *thread_fn_flink_name(void *p)
 {
@@ -164,8 +190,7 @@ static void test_flink_close(void)
 	 * up the counts */
 	fake = drm_open_driver(DRIVER_INTEL);
 
-	gem_quiescent_gpu(fake);
-	obj_count = get_object_count();
+	obj_count = get_stable_obj_count(fake);
 
 	num_threads = sysconf(_SC_NPROCESSORS_ONLN);
 
@@ -190,8 +215,7 @@ static void test_flink_close(void)
 
 	close(fd);
 
-	gem_quiescent_gpu(fake);
-	obj_count = get_object_count() - obj_count;
+	obj_count = get_stable_obj_count(fake) - obj_count;
 
 	igt_info("leaked %i objects\n", obj_count);
 
tests/prime_self_import.c +33 -10
index 91fe231..977c7b2 100644
@@ -47,7 +47,7 @@
 #include "drm.h"
 
 IGT_TEST_DESCRIPTION("Check whether prime import/export works on the same"
-		     " device.");
+		     " device... but with different fds.");
 
 #define BO_SIZE (16*1024)
 
@@ -157,7 +157,7 @@ static void test_with_one_bo_two_files(void)
 	dma_buf_fd2 = prime_handle_to_fd(fd2, handle_open);
 	handle_import = prime_fd_to_handle(fd2, dma_buf_fd2);
 
-	/* dma-buf selfimporting an flink bo should give the same handle */
+	/* dma-buf self importing an flink bo should give the same handle */
 	igt_assert_eq_u32(handle_import, handle_open);
 
 	close(fd1);
@@ -226,6 +226,33 @@ static int get_object_count(void)
 	return ret;
 }
 
+static int get_stable_obj_count(int driver)
+{
+	/* The test relies on the system being in the same state before and
+	   after the test so any difference in the object count is a result of
+	   leaks during the test. gem_quiescent_gpu() mostly achieves this but
+	   occasionally obj_count can still change. The loop ensures obj_count
+	   has remained stable over several checks */
+	int obj_count, prev_obj_count;
+	int loop_count = 0;
+	gem_quiescent_gpu(driver);
+	prev_obj_count = get_object_count();
+	while (loop_count < 4) {
+		usleep(200000);
+		gem_quiescent_gpu(driver);
+		obj_count = get_object_count();
+		if (obj_count == prev_obj_count) {
+			loop_count++;
+		} else {
+			igt_debug("loop_count=%d, obj_count=%d, prev_obj_count=%d\n", loop_count, obj_count, prev_obj_count);
+			loop_count = 0;
+			prev_obj_count = obj_count;
+		}
+
+	}
+	return obj_count;
+}
+
 static void *thread_fn_reimport_vs_close(void *p)
 {
 	struct drm_gem_close close_bo;
@@ -258,8 +285,7 @@ static void test_reimport_close_race(void)
 	 * up the counts */
 	fake = drm_open_driver(DRIVER_INTEL);
 
-	gem_quiescent_gpu(fake);
-	obj_count = get_object_count();
+	obj_count = get_stable_obj_count(fake);
 
 	num_threads = sysconf(_SC_NPROCESSORS_ONLN);
 
@@ -290,8 +316,7 @@ static void test_reimport_close_race(void)
 	close(fds[0]);
 	close(fds[1]);
 
-	gem_quiescent_gpu(fake);
-	obj_count = get_object_count() - obj_count;
+	obj_count = get_stable_obj_count(fake) - obj_count;
 
 	igt_info("leaked %i objects\n", obj_count);
 
@@ -350,8 +375,7 @@ static void test_export_close_race(void)
 	 * up the counts */
 	fake = drm_open_driver(DRIVER_INTEL);
 
-	gem_quiescent_gpu(fake);
-	obj_count = get_object_count();
+	obj_count = get_stable_obj_count(fake);
 
 	fd = drm_open_driver(DRIVER_INTEL);
 
@@ -373,8 +397,7 @@ static void test_export_close_race(void)
 
 	close(fd);
 
-	gem_quiescent_gpu(fake);
-	obj_count = get_object_count() - obj_count;
+	obj_count = get_stable_obj_count(fake) - obj_count;
 
 	igt_info("leaked %i objects\n", obj_count);
 
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw
Quoted 17 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Thursday, December 10, 2015 10:13 AM
To: Morton, Derek J
Cc: [email protected]; Wood, Thomas
Subject: Re: [Intel-gfx] [PATCH i-g-t] gem_flink_race/prime_self_import: Improve test reliability

Quoted 6 lines · Derek Morton

gem_flink_race and prime_self_import have subtests which read the number of open gem objects from debugfs to determine if objects have leaked during the test. However the test can fail sporadically if the number of gem objects changes due to other process activity. This patch introduces a change to check the number of gem objects several times to filter out any fluctuations.

Quoted 3 lines

Why exactly does this happen? IGT tests should be run on bare metal, with everything else killed/subdued/shutup. If there's still things going on that create objects, we need to stop them from doing that.

If this only applies to Android, or some special Android deamon them imo check for that at runtime and igt_skip("your setup is invalid, deamon %s running\n"); is the correct fix. After all just because you sampled for a bit doesn't mean that it wont still change right when you start running the test for real, so this is still fragile.

Before running tests on android we do stop everything possible. I suspect the culprit is coreu getting automatically restarted after it is stopped. I had additional debug while developing this patch and what I saw was the system being mostly quiescent but with some very low level background activity. 1 extra object being created and then deleted occasionally. Depending on whether it occurred at the start or end of the test it was resulting in a reported leak of either 1 or -1 objects. The patch fixes that issue by taking several samples and requiring them to be the same, therefore filtering out the low level background noise. It would not help if something in the background allocated an object and kept it allocated, but I have not seen that happen. I only saw once the object count increasing for 2 consecutive reads hence the count to 4 to give a margin. The test was failing about 10%. With this patch I got 100% pass across 300 runs of each of the tests.

If you are concerned about the behaviour when running the test with a load of background activity I could add code to limit to the reset of the count and fail the test in that instance. That would give a benefit of distinguishing a test fail due to excessive background activity from a detected leak.

I would not want to just have the test skip as that introduces a hole in our test coverage.

Quoted 2 lines

Also would be good to extract get_stable_obj_count to a proper igt library function, if it indeed needs to be this tricky. And then add the explanation for why we need this in the gtkdoc.

I can move the code to an igt library. Which library would you suggest? Igt_debugfs ?

//Derek

Quoted 173 lines

Thanks, Daniel

Quoted 171 lines
---
 tests/gem_flink_race.c    | 34 +++++++++++++++++++++++++++++-----
 tests/prime_self_import.c | 43 
+++++++++++++++++++++++++++++++++----------
 2 files changed, 62 insertions(+), 15 deletions(-)
tests/gem_flink_race.c index renamed from tests/gem_flink_race.c +0 -0

b17ef85..0552e12 100644

tests/gem_flink_race.c +0 -1
@@ -44,7 +44,7 @@ IGT_TEST_DESCRIPTION("Check for flink/open vs. gem close races.");
  * in the flink name and corresponding reference getting leaked.
  */
 
-/* We want lockless and I'm to lazy to dig out an atomic libarary. On 

x86 this

tests/gem_flink_race.c +29 -4
+/* We want lockless and I'm to lazy to dig out an atomic library. On 
+x86 this
  * works, too. */
 volatile int pls_die = 0;
 int fd;
@@ -65,6 +65,32 @@ static int get_object_count(void)
 	return ret;
 }
 
+static int get_stable_obj_count(int driver) {
+	/* The test relies on the system being in the same state before and
+	   after the test so any difference in the object count is a result of
+	   leaks during the test. gem_quiescent_gpu() mostly achieves this but
+	   occasionally obj_count can still change. The loop ensures obj_count
+	   has remained stable over several checks */
+	int obj_count, prev_obj_count;
+	int loop_count = 0;
+	gem_quiescent_gpu(driver);
+	prev_obj_count = get_object_count();
+	while (loop_count < 4) {
+		usleep(200000);
+		gem_quiescent_gpu(driver);
+		obj_count = get_object_count();
+		if (obj_count == prev_obj_count) {
+			loop_count++;
+		} else {
+			igt_debug("loop_count=%d, obj_count=%d, prev_obj_count=%d\n", loop_count, obj_count, prev_obj_count);
+			loop_count = 0;
+			prev_obj_count = obj_count;
+		}
+
+	}
+	return obj_count;
+}
 
 static void *thread_fn_flink_name(void *p)  { @@ -164,8 +190,7 @@ 
 static void test_flink_close(void)
 	 * up the counts */
 	fake = drm_open_driver(DRIVER_INTEL);
 
-	gem_quiescent_gpu(fake);
-	obj_count = get_object_count();
+	obj_count = get_stable_obj_count(fake);
 
 	num_threads = sysconf(_SC_NPROCESSORS_ONLN);
@@ -190,8 +215,7 @@ static void test_flink_close(void)
 
 	close(fd);
 
-	gem_quiescent_gpu(fake);
-	obj_count = get_object_count() - obj_count;
+	obj_count = get_stable_obj_count(fake) - obj_count;
 
 	igt_info("leaked %i objects\n", obj_count);
 
tests/prime_self_import.c +32 -11
index 91fe231..977c7b2 100644
@@ -47,7 +47,7 @@
 #include "drm.h"
 
 IGT_TEST_DESCRIPTION("Check whether prime import/export works on the same"
-		     " device.");
+		     " device... but with different fds.");
 
 #define BO_SIZE (16*1024)
 
@@ -157,7 +157,7 @@ static void test_with_one_bo_two_files(void)
 	dma_buf_fd2 = prime_handle_to_fd(fd2, handle_open);
 	handle_import = prime_fd_to_handle(fd2, dma_buf_fd2);
 
-	/* dma-buf selfimporting an flink bo should give the same handle */
+	/* dma-buf self importing an flink bo should give the same handle */
 	igt_assert_eq_u32(handle_import, handle_open);
 
 	close(fd1);
@@ -226,6 +226,33 @@ static int get_object_count(void)
 	return ret;
 }
 
+static int get_stable_obj_count(int driver) {
+	/* The test relies on the system being in the same state before and
+	   after the test so any difference in the object count is a result of
+	   leaks during the test. gem_quiescent_gpu() mostly achieves this but
+	   occasionally obj_count can still change. The loop ensures obj_count
+	   has remained stable over several checks */
+	int obj_count, prev_obj_count;
+	int loop_count = 0;
+	gem_quiescent_gpu(driver);
+	prev_obj_count = get_object_count();
+	while (loop_count < 4) {
+		usleep(200000);
+		gem_quiescent_gpu(driver);
+		obj_count = get_object_count();
+		if (obj_count == prev_obj_count) {
+			loop_count++;
+		} else {
+			igt_debug("loop_count=%d, obj_count=%d, prev_obj_count=%d\n", loop_count, obj_count, prev_obj_count);
+			loop_count = 0;
+			prev_obj_count = obj_count;
+		}
+
+	}
+	return obj_count;
+}
+
 static void *thread_fn_reimport_vs_close(void *p)  {
 	struct drm_gem_close close_bo;
@@ -258,8 +285,7 @@ static void test_reimport_close_race(void)
 	 * up the counts */
 	fake = drm_open_driver(DRIVER_INTEL);
 
-	gem_quiescent_gpu(fake);
-	obj_count = get_object_count();
+	obj_count = get_stable_obj_count(fake);
 
 	num_threads = sysconf(_SC_NPROCESSORS_ONLN);
 
@@ -290,8 +316,7 @@ static void test_reimport_close_race(void)
 	close(fds[0]);
 	close(fds[1]);
 
-	gem_quiescent_gpu(fake);
-	obj_count = get_object_count() - obj_count;
+	obj_count = get_stable_obj_count(fake) - obj_count;
 
 	igt_info("leaked %i objects\n", obj_count);
 
@@ -350,8 +375,7 @@ static void test_export_close_race(void)
 	 * up the counts */
 	fake = drm_open_driver(DRIVER_INTEL);
 
-	gem_quiescent_gpu(fake);
-	obj_count = get_object_count();
+	obj_count = get_stable_obj_count(fake);
 
 	fd = drm_open_driver(DRIVER_INTEL);
 
@@ -373,8 +397,7 @@ static void test_export_close_race(void)
 
 	close(fd);
 
-	gem_quiescent_gpu(fake);
-	obj_count = get_object_count() - obj_count;
+	obj_count = get_stable_obj_count(fake) - obj_count;
 
 	igt_info("leaked %i objects\n", obj_count);
 
--

1.9.1

Quoted 10 lines
Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw
Quoted 27 lines · Derek J
Quoted 21 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Thursday, December 10, 2015 10:13 AM
To: Morton, Derek J
Cc: [email protected]; Wood, Thomas
Subject: Re: [Intel-gfx] [PATCH i-g-t] gem_flink_race/prime_self_import: Improve test reliability

Quoted 6 lines · Derek Morton

gem_flink_race and prime_self_import have subtests which read the number of open gem objects from debugfs to determine if objects have leaked during the test. However the test can fail sporadically if the number of gem objects changes due to other process activity. This patch introduces a change to check the number of gem objects several times to filter out any fluctuations.

Why exactly does this happen? IGT tests should be run on bare metal, with everything else killed/subdued/shutup. If there's still things going on that create objects, we need to stop them from doing that.

Quoted 5 lines

If this only applies to Android, or some special Android deamon them imo check for that at runtime and igt_skip("your setup is invalid, deamon %s running\n"); is the correct fix. After all just because you sampled for a bit doesn't mean that it wont still change right when you start running the test for real, so this is still fragile.

Quoted 14 lines

Before running tests on android we do stop everything possible. I suspect the culprit is coreu getting automatically restarted after it is stopped. I had additional debug while developing this patch and what I saw was the system being mostly quiescent but with some very low level background activity. 1 extra object being created and then deleted occasionally. Depending on whether it occurred at the start or end of the test it was resulting in a reported leak of either 1 or -1 objects. The patch fixes that issue by taking several samples and requiring them to be the same, therefore filtering out the low level background noise. It would not help if something in the background allocated an object and kept it allocated, but I have not seen that happen. I only saw once the object count increasing for 2 consecutive reads hence the count to 4 to give a margin. The test was failing about 10%. With this patch I got 100% pass across 300 runs of each of the tests.

Hm, piglit checks that there's no other drm clients running. Have you tried re-running that check to zero in on the culprit?

Quoted 5 lines

If you are concerned about the behaviour when running the test with a load of background activity I could add code to limit to the reset of the count and fail the test in that instance. That would give a benefit of distinguishing a test fail due to excessive background activity from a detected leak.

I'm also concerned for the overhead this causes everyone else. If this really is some Android trouble then I think it'd be good to only compile this on Android. But would still be much better if you can get to a reliably clean test environment.

Quoted 8 lines

I would not want to just have the test skip as that introduces a hole in our test coverage.

Quoted 3 lines

Also would be good to extract get_stable_obj_count to a proper igt library function, if it indeed needs to be this tricky. And then add the explanation for why we need this in the gtkdoc.

I can move the code to an igt library. Which library would you suggest? Igt_debugfs ?

Hm yeah, it's a bit the dumping ground for all things debugfs access ;-) -Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw
Quoted 54 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Thursday, December 10, 2015 12:53 PM
To: Morton, Derek J
Cc: Daniel Vetter; [email protected]; Wood, Thomas
Subject: Re: [Intel-gfx] [PATCH i-g-t] gem_flink_race/prime_self_import: Improve test reliability

Quoted 29 lines · Derek J
Quoted 23 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Thursday, December 10, 2015 10:13 AM
To: Morton, Derek J
Cc: [email protected]; Wood, Thomas
Subject: Re: [Intel-gfx] [PATCH i-g-t] gem_flink_race/prime_self_import: Improve test reliability

Quoted 6 lines · Derek Morton

gem_flink_race and prime_self_import have subtests which read the number of open gem objects from debugfs to determine if objects have leaked during the test. However the test can fail sporadically if the number of gem objects changes due to other process activity. This patch introduces a change to check the number of gem objects several times to filter out any fluctuations.

Why exactly does this happen? IGT tests should be run on bare metal, with everything else killed/subdued/shutup. If there's still things going on that create objects, we need to stop them from doing that.

Quoted 5 lines

If this only applies to Android, or some special Android deamon them imo check for that at runtime and igt_skip("your setup is invalid, deamon %s running\n"); is the correct fix. After all just because you sampled for a bit doesn't mean that it wont still change right when you start running the test for real, so this is still fragile.

Quoted 14 lines

Before running tests on android we do stop everything possible. I suspect the culprit is coreu getting automatically restarted after it is stopped. I had additional debug while developing this patch and what I saw was the system being mostly quiescent but with some very low level background activity. 1 extra object being created and then deleted occasionally. Depending on whether it occurred at the start or end of the test it was resulting in a reported leak of either 1 or -1 objects. The patch fixes that issue by taking several samples and requiring them to be the same, therefore filtering out the low level background noise. It would not help if something in the background allocated an object and kept it allocated, but I have not seen that happen. I only saw once the object count increasing for 2 consecutive reads hence the count to 4 to give a margin. The test was failing about 10%. With this patch I got 100% pass across 300 runs of each of the tests.

Quoted 1 line

Hm, piglit checks that there's no other drm clients running. Have you tried re-running that check to zero in on the culprit?

We don't use piglet to run IGT tests on Android. I have had a look at what piglet does and added the same check to our scripts. (It reads a list of clients from /sys/kernel/debug/dri/0/clients)
For CHV it shows a process called 'y', though that seems to be some issue on CHV that all driver clients are called 'y'. I checked on BXT which properly shows the process names and it looks like it is the binder process (which is handling some inter process communication). I don't think this is something we can stop.

Quoted 8 lines
Quoted 6 lines

If you are concerned about the behaviour when running the test with a load of background activity I could add code to limit to the reset of the count and fail the test in that instance. That would give a benefit of distinguishing a test fail due to excessive background activity from a detected leak.

I'm also concerned for the overhead this causes everyone else. If this really is some Android trouble then I think it'd be good to only compile this on Android. But would still be much better if you can get to a reliably clean test environment.

I will make the loop part android specific.

//Derek

Quoted 8 lines
Quoted 8 lines

I would not want to just have the test skip as that introduces a hole in our test coverage.

Quoted 3 lines

Also would be good to extract get_stable_obj_count to a proper igt library function, if it indeed needs to be this tricky. And then add the explanation for why we need this in the gtkdoc.

Quoted 8 lines
Quoted 1 line

I can move the code to an igt library. Which library would you suggest? Igt_debugfs ?

Hm yeah, it's a bit the dumping ground for all things debugfs access ;-) -Daniel --
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#5 lore raw
Quoted 54 lines · Derek J
Quoted 54 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Thursday, December 10, 2015 12:53 PM
To: Morton, Derek J
Cc: Daniel Vetter; [email protected]; Wood, Thomas
Subject: Re: [Intel-gfx] [PATCH i-g-t] gem_flink_race/prime_self_import: Improve test reliability

Quoted 43 lines · Derek J
Quoted 23 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Thursday, December 10, 2015 10:13 AM
To: Morton, Derek J
Cc: [email protected]; Wood, Thomas
Subject: Re: [Intel-gfx] [PATCH i-g-t] gem_flink_race/prime_self_import: Improve test reliability

Quoted 6 lines · Derek Morton

gem_flink_race and prime_self_import have subtests which read the number of open gem objects from debugfs to determine if objects have leaked during the test. However the test can fail sporadically if the number of gem objects changes due to other process activity. This patch introduces a change to check the number of gem objects several times to filter out any fluctuations.

Why exactly does this happen? IGT tests should be run on bare metal, with everything else killed/subdued/shutup. If there's still things going on that create objects, we need to stop them from doing that.

Quoted 5 lines

If this only applies to Android, or some special Android deamon them imo check for that at runtime and igt_skip("your setup is invalid, deamon %s running\n"); is the correct fix. After all just because you sampled for a bit doesn't mean that it wont still change right when you start running the test for real, so this is still fragile.

Before running tests on android we do stop everything possible. I suspect the culprit is coreu getting automatically restarted after it is stopped. I had additional debug while developing this patch and what I saw was the system being mostly quiescent but with some very low level background activity. 1 extra object being created and then deleted occasionally. Depending on whether it occurred at the start or end of the test it was resulting in a reported leak of either 1 or -1 objects. The patch fixes that issue by taking several samples and requiring them to be the same, therefore filtering out the low level background noise. It would not help if something in the background allocated an object and kept it allocated, but I have not seen that happen. I only saw once the object count increasing for 2 consecutive reads hence the count to 4 to give a margin. The test was failing about 10%. With this patch I got 100% pass across 300 runs of each of the tests.

Quoted 4 lines
Quoted 1 line

Hm, piglit checks that there's no other drm clients running. Have you tried re-running that check to zero in on the culprit?

We don't use piglet to run IGT tests on Android. I have had a look at what piglet does and added the same check to our scripts. (It reads a list of clients from /sys/kernel/debug/dri/0/clients)
For CHV it shows a process called 'y', though that seems to be some issue on CHV that all driver clients are called 'y'. I checked on BXT which properly shows the process names and it looks like it is the binder process (which is handling some inter process communication). I don't think this is something we can stop.

Nah, you definitely can't stop binder, won't have an android left after that ;-)

But it is strange that binder owns these buffers. Binder is just IPC, but like unix domain sockets you can also throw around file descriptors. So something on your system is moving open drm fd devices still around. I don't have an idea what kind of audit/debug tooling binder offers, but there should be a way to figure out who really owns that file descriptor. If you're lucky lsof (if android has that, otherwise walk /proc/*/fd/* symlinks manually) should help.

Cheers, Daniel

Quoted 29 lines
Quoted 7 lines
Quoted 5 lines

If you are concerned about the behaviour when running the test with a load of background activity I could add code to limit to the reset of the count and fail the test in that instance. That would give a benefit of distinguishing a test fail due to excessive background activity from a detected leak.

I'm also concerned for the overhead this causes everyone else. If this really is some Android trouble then I think it'd be good to only compile this on Android. But would still be much better if you can get to a reliably clean test environment.

I will make the loop part android specific.

//Derek

Quoted 16 lines
Quoted 9 lines

I would not want to just have the test skip as that introduces a hole in our test coverage.

Quoted 3 lines

Also would be good to extract get_stable_obj_count to a proper igt library function, if it indeed needs to be this tricky. And then add the explanation for why we need this in the gtkdoc.

I can move the code to an igt library. Which library would you suggest? Igt_debugfs ?

Hm yeah, it's a bit the dumping ground for all things debugfs access ;-) -Daniel --
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#6 lore raw
Quoted 71 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Friday, December 11, 2015 5:06 PM
To: Morton, Derek J
Cc: Daniel Vetter; [email protected]; Wood, Thomas
Subject: Re: [Intel-gfx] [PATCH i-g-t] gem_flink_race/prime_self_import: Improve test reliability

Quoted 56 lines · Derek J
Quoted 56 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Thursday, December 10, 2015 12:53 PM
To: Morton, Derek J
Cc: Daniel Vetter; [email protected]; Wood, Thomas
Subject: Re: [Intel-gfx] [PATCH i-g-t] gem_flink_race/prime_self_import: Improve test reliability

Quoted 43 lines · Derek J
Quoted 23 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Thursday, December 10, 2015 10:13 AM
To: Morton, Derek J
Cc: [email protected]; Wood, Thomas
Subject: Re: [Intel-gfx] [PATCH i-g-t] gem_flink_race/prime_self_import: Improve test reliability

Quoted 6 lines · Derek Morton

gem_flink_race and prime_self_import have subtests which read
the number of open gem objects from debugfs to determine if
objects have leaked during the test. However the test can fail sporadically if the number of gem objects changes due to other process activity. This patch introduces a change to check the number of gem
objects several times to filter out any fluctuations.

Why exactly does this happen? IGT tests should be run on bare metal, with everything else killed/subdued/shutup. If there's
still things going on that create objects, we need to stop them from doing that.

Quoted 5 lines

If this only applies to Android, or some special Android deamon them imo check for that at runtime and igt_skip("your setup is invalid, deamon %s running\n"); is the correct fix. After all just because you sampled for a bit doesn't mean that it wont still change right when you start running the test for real, so this is still fragile.

Before running tests on android we do stop everything possible. I
suspect the culprit is coreu getting automatically restarted after
it is stopped. I had additional debug while developing this patch
and what I saw was the system being mostly quiescent but with some
very low level background activity. 1 extra object being created
and then deleted occasionally. Depending on whether it occurred at
the start or end of the test it was resulting in a reported leak of either 1 or -1 objects. The patch fixes that issue by taking several samples and requiring
them to be the same, therefore filtering out the low level background noise. It would not help if something in the background allocated an
object and kept it allocated, but I have not seen that happen. I
only saw once the object count increasing for 2 consecutive reads
hence the count to 4 to give a margin. The test was failing about
10%. With this patch I got 100% pass across 300 runs of each of the tests.

Quoted 4 lines
Quoted 1 line

Hm, piglit checks that there's no other drm clients running. Have you tried re-running that check to zero in on the culprit?

We don't use piglet to run IGT tests on Android. I have had a look at
what piglet does and added the same check to our scripts. (It reads a list of clients from /sys/kernel/debug/dri/0/clients) For CHV it shows a process called 'y', though that seems to be some issue on CHV that all driver clients are called 'y'. I checked on BXT which properly shows the process names and it looks like it is the binder process (which is handling some inter process communication). I don't think this is something we can stop.

Quoted 6 lines

Nah, you definitely can't stop binder, won't have an android left after that ;-)

But it is strange that binder owns these buffers. Binder is just IPC, but like unix domain sockets you can also throw around file descriptors. So something on your system is moving open drm fd devices still around. I don't have an idea what kind of audit/debug tooling binder offers, but there should be a way to figure out who really owns that file descriptor. If you're lucky lsof (if android has that, otherwise walk /proc/*/fd/* symlinks manually) should help.

Cheers, Daniel

I am still suspicious that it is coreu that is the real culprit. I ran the tests Friday and did some reading of i915_gem_objects in parallel to get the full content of what it reported. I once caught coreu being listed as owning an active gem object during the test. Coreu gets stopped explicitly before tests are run but I suspect the init demon is detecting that it is stopped and is restarting it automatically. Something is reporting in logcat when coreu is stopped anyway.

I will address your comments on V2 and submit another patch.

//Derek

Quoted 32 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

If you are concerned about the behaviour when running the test with a load of background activity I could add code to limit to the reset of the count and fail the test in that instance. That would give a benefit of distinguishing a test fail due to excessive background activity from a detected leak.

Quoted 24 lines
Quoted 1 line

I'm also concerned for the overhead this causes everyone else. If this really is some Android trouble then I think it'd be good to only compile this on Android. But would still be much better if you can get to a reliably clean test environment.

I will make the loop part android specific.

//Derek

Quoted 17 lines
Quoted 9 lines

I would not want to just have the test skip as that introduces a hole in our test coverage.

Quoted 3 lines

Also would be good to extract get_stable_obj_count to a proper igt library function, if it indeed needs to be this tricky. And then add the explanation for why we need this in the gtkdoc.

I can move the code to an igt library. Which library would you suggest? Igt_debugfs ?

Hm yeah, it's a bit the dumping ground for all things debugfs access ;-) -Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

Quoted 5 lines

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx