@@ -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
@@ -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