Skip to contentSkip to conversation

New test to stress eviction

PATCH In review Piotr Luc 2 participants 4 messages Mar 22, 2016 – Mar 23, 2016 Library code

lore
Share & tools
lore

Piotr Luc

author
#0 lore raw

cover New test to stress eviction

From: Piotr Luc <[email protected]>

The aim of the test is to stress i915 memory eviction mechanism on Android. It seems that Android systems, which usually don't have a swap file, experience some problems with killing offending processes that use a large amount of GFX memory.
Linux systems seem to be more robust in this case and kill such processes because swap file allows to accept more memory requests, and also they are more distributed in time. However, Linux system with swap disabled behaves similar to Android.

This test was developed to help replicate the OOM situation where system ends up with continuously repeated message:
"Unable to purge GPU memory due lock contention."
This state lasts long time, counted in minutes or hours, and Android systems seems to be unable to recover from it quickly, as it would be expected.
I believe it could be treated as a kind of DoS attack caused by a malicious GFX application and need more investigation, thus this set of patches.

The gem_exec_mem_huge test should be run with enabled low memory killer; the first patch adds a new parameter to prevent disabling LMK.

Piotr Luc (2):
lib/igt_core.c: Add new parameter to prevent disabling LMK tests/gem_exec_mem_huge.c: New test to stress eviction

 lib/igt_core.c            |  15 +++-
 tests/Makefile.sources    |   1 +
 tests/gem_exec_mem_huge.c | 196 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 210 insertions(+), 2 deletions(-)
 create mode 100644 tests/gem_exec_mem_huge.c
Signature · 6 lines
2.5.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
author
#1 lore raw

PATCH 1/2 lib/igt_core.c: Add new parameter to prevent disabling LMK

From: Piotr Luc <[email protected]>

The 'keep-lmk-working' parameter added to prevent disabling the Low Memory Killer.

---
 lib/igt_core.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
lib/igt_core.c +13 -2
index 1f9be7d..734457a 100644
@@ -228,6 +228,7 @@
 
 static unsigned int exit_handler_count;
 const char *igt_interactive_debug;
+static bool igt_disable_memory_killer = true;
 
 /* subtests helpers */
 static bool list_subtests = false;
@@ -257,6 +258,7 @@ enum {
  OPT_DESCRIPTION,
  OPT_DEBUG,
  OPT_INTERACTIVE_DEBUG,
+ OPT_KEEP_LOW_MEM_KILLER_WORKING,
  OPT_HELP = 'h'
 };
 
@@ -514,7 +516,9 @@ bool igt_exit_called;
 static void common_exit_handler(int sig)
 {
 	if (!igt_only_list_subtests()) {
-		low_mem_killer_disable(false);
+		if (igt_disable_memory_killer) {
+			low_mem_killer_disable(false);
+		}
 	}
 
 	/* When not killed by a signal check that igt_exit() has been properly
@@ -551,6 +555,7 @@ static void print_usage(const char *help_str, bool output_on_stderr)
 		   "  --run-subtest <pattern>\n"
 		   "  --debug[=log-domain]\n"
 		   "  --interactive-debug[=domain]\n"
+		   "  --keep-lmk-working\n"
 		   "  --help-description\n"
 		   "  --help\n");
 	if (help_str)
@@ -584,6 +589,7 @@ static int common_init(int *argc, char **argv,
 		{"help-description", 0, 0, OPT_DESCRIPTION},
 		{"debug", optional_argument, 0, OPT_DEBUG},
 		{"interactive-debug", optional_argument, 0, OPT_INTERACTIVE_DEBUG},
+		{"keep-lmk-working", optional_argument, 0, OPT_KEEP_LOW_MEM_KILLER_WORKING},
 		{"help", 0, 0, OPT_HELP},
 		{0, 0, 0, 0}
 	};
@@ -699,6 +705,9 @@ static int common_init(int *argc, char **argv,
 			print_test_description();
 			ret = -1;
 			goto out;
+		case OPT_KEEP_LOW_MEM_KILLER_WORKING:
+			igt_disable_memory_killer = false;
+			break;
 		case OPT_HELP:
 			print_usage(help_str, false);
 			ret = -1;
@@ -738,7 +747,9 @@ out:
 		print_version();
 
 		oom_adjust_for_doom();
-		low_mem_killer_disable(true);
+		if (igt_disable_memory_killer) {
+			low_mem_killer_disable(true);
+		}
 	}
 
 	/* install exit handler, to ensure we clean up */
Signature · 6 lines
2.5.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
author
#2 lore raw

PATCH 2/2 tests/gem_exec_mem_huge.c: New test to stress eviction

In reply to Piotr Luc

From: Piotr Luc <[email protected]>

The aim of the test is to stress i915 memory eviction mechanism. The test runs many processes, each of it executes NOP batch which has attached really big data buffers chain.

While this is unusual use case, rather it doesn't occur in normal games or applications, it possible to imagine that an offending application can use the weakness of low memory handler and i915 buffer eviction mechanism to conduct DoS attack. Note that achieving this goal on standard PC could be difficult, it may be easy in a system with limited capabilities (little memory, lack of swap, a small number of cores).

---
 tests/Makefile.sources    |   1 +
 tests/gem_exec_mem_huge.c | 196 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 197 insertions(+)
 create mode 100644 tests/gem_exec_mem_huge.c
tests/Makefile.sources +1 -0
index 43f232f..b265f19 100644
@@ -137,6 +137,7 @@ TESTS_progs = \
 	gem_ctx_thrash \
 	gem_double_irq_loop \
 	gem_exec_big \
+	gem_exec_mem_huge \
 	gem_exec_blt \
 	gem_exec_lut_handle \
 	gem_fd_exhaustion \
tests/gem_exec_mem_huge.c new file +196 -0

196 lines not on this page · raw message

Signature · 1 line
2.5.0

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

#3 lore raw

Re: [PATCH i-g-t 2/2] tests/gem_exec_mem_huge.c: New test to stress eviction

Quoted 6 lines · Piotr Luc

From: Piotr Luc <[email protected]>

The aim of the test is to stress i915 memory eviction mechanism. The test runs many processes, each of it executes NOP batch which has attached really big data buffers chain.

Quoted 7 lines

While this is unusual use case, rather it doesn't occur in normal games or applications, it possible to imagine that an offending application can use the weakness of low memory handler and i915 buffer eviction mechanism to conduct DoS attack. Note that achieving this goal on standard PC could be difficult, it may be easy in a system with limited capabilities (little memory, lack of swap, a small number of cores).

I had a go at capturing your requirements a little more concisely as igt/gem_shrink. Hopefully that gives you a superset of what you wanted to do here, and prove to be a useful platform to build upon. -Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx