From patchwork Fri Jun 26 16:46:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michel Thierry X-Patchwork-Id: 6682551 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8F56E9F380 for ; Fri, 26 Jun 2015 16:46:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9BBC8206A9 for ; Fri, 26 Jun 2015 16:46:06 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id A79DA20553 for ; Fri, 26 Jun 2015 16:46:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 22AA16EE2C; Fri, 26 Jun 2015 09:46:05 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTP id 884A86EE2C for ; Fri, 26 Jun 2015 09:46:04 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP; 26 Jun 2015 09:46:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,686,1427785200"; d="scan'208";a="595371931" Received: from michelth-linux2.isw.intel.com ([10.102.226.189]) by orsmga003.jf.intel.com with ESMTP; 26 Jun 2015 09:46:02 -0700 From: Michel Thierry To: intel-gfx@lists.freedesktop.org Date: Fri, 26 Jun 2015 17:46:01 +0100 Message-Id: <1435337161-31125-1-git-send-email-michel.thierry@intel.com> X-Mailer: git-send-email 2.4.5 In-Reply-To: <1435153231-19606-1-git-send-email-michel.thierry@intel.com> References: <1435153231-19606-1-git-send-email-michel.thierry@intel.com> Cc: Daniel Vetter Subject: [Intel-gfx] [PATCH igt v3] lib: Update intel_require_memory to handle +4GB cases X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Chris Wilson (v2) Signed-off-by: Michel Thierry --- lib/igt_aux.h | 2 +- lib/intel_os.c | 34 +++++++++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 6 deletions(-) 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: + * |[ + * 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