diff mbox

[igt,v3] lib: Update intel_require_memory to handle +4GB cases

Message ID 1435337161-31125-1-git-send-email-michel.thierry@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michel Thierry June 26, 2015, 4:46 p.m. UTC
Changed size from u32 to u64 to support +4GB.
48-bit PPGTT test cases may need extra memory available.

v2: Use thousands separator (Chris)
v3: Moved igt_skip_on_simulation() to the start (Chris)
    Include Chris' usage hint in the gtk-doc section (Daniel)

Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> (v2)
Signed-off-by: Michel Thierry <michel.thierry@intel.com>
---
 lib/igt_aux.h  |  2 +-
 lib/intel_os.c | 34 +++++++++++++++++++++++++++++-----
 2 files changed, 30 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index 9ea50de..139e5da 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -86,7 +86,7 @@  uint64_t intel_get_avail_ram_mb(void);
 uint64_t intel_get_total_ram_mb(void);
 uint64_t intel_get_total_swap_mb(void);
 
-void intel_require_memory(uint32_t count, uint32_t size, unsigned mode);
+void intel_require_memory(uint32_t count, uint64_t size, unsigned mode);
 #define CHECK_RAM 0x1
 #define CHECK_SWAP 0x2
 
diff --git a/lib/intel_os.c b/lib/intel_os.c
index f82847f..3e3b9ec 100644
--- a/lib/intel_os.c
+++ b/lib/intel_os.c
@@ -214,19 +214,45 @@  intel_get_total_swap_mb(void)
  * also causes the test to be skipped automatically on simulation under the
  * assumption that any test that needs to check for memory requirements is a
  * thrashing test unsuitable for slow simulated systems.
+ *
+ * We use intel_require_memory() to detect tests that are designed to run with
+ * large working sets to stress boundaries such as aperture, and/or memory
+ * exhaustion. Functional tests that also require large working sets should be
+ * split into two, a small subtest to verify the operation with the absolute
+ * minimum working set, and the full subtest to verify the interesting corner
+ * cases. The former test doesn't require the memory check and so judicious
+ * use of intel_require_memory() helps segregate such functional tests from
+ * the broader tests, useful for slow verification systems such as the
+ * simulator.
+ *
+ * To recap, lay out behaviour tests like:
+ * |[<!-- language="C" -->
+ *    igt_subtest("small") {
+ *       run_test({.num_surfaces = 2 });
+ *    }
+ *    igt_subtest("full") {
+ *      intel_require_memory(NUM_SURFACES, SURFACE_SIZE, CHECK_RAM);
+ *      run_test({.num_surfaces = NUM_SURFACES});
+ *    }
+ * ]|
+ * so that we have a simple check that is run anywhere and everywhere,
+ * useful to prove the test itself works as expected, and the full
+ * slow check that needs to be run on real hardware.
  */
-void intel_require_memory(uint32_t count, uint32_t size, unsigned mode)
+void intel_require_memory(uint32_t count, uint64_t size, unsigned mode)
 {
 /* rough estimate of how many bytes the kernel requires to track each object */
 #define KERNEL_BO_OVERHEAD 512
 	uint64_t required, total;
 
+	igt_skip_on_simulation();
+
 	required = count;
 	required *= size + KERNEL_BO_OVERHEAD;
 	required = ALIGN(required, 4096);
 
-	igt_debug("Checking %u surfaces of size %u bytes (total %'llu) against %s%s\n",
-		  count, size, (long long)required,
+	igt_debug("Checking %u surfaces of size %'llu bytes (total %'llu) against %s%s\n",
+		  count, (long long)size, (long long)required,
 		  mode & (CHECK_RAM | CHECK_SWAP) ? "RAM" : "",
 		  mode & CHECK_SWAP ? " + swap": "");
 
@@ -242,8 +268,6 @@  void intel_require_memory(uint32_t count, uint32_t size, unsigned mode)
 		      (long long)required, (long long)total,
 		      mode & (CHECK_RAM | CHECK_SWAP) ? "RAM" : "",
 		      mode & CHECK_SWAP ? " + swap": "");
-
-	igt_skip_on_simulation();
 }
 
 void