From patchwork Tue Mar 3 10:23:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tim.gore@intel.com X-Patchwork-Id: 5920991 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D2360BF440 for ; Tue, 3 Mar 2015 10:23:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BC6C520125 for ; Tue, 3 Mar 2015 10:23:08 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id C208B2026C for ; Tue, 3 Mar 2015 10:23:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 845456E20F; Tue, 3 Mar 2015 02:23:06 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id B14D06E20F for ; Tue, 3 Mar 2015 02:23:04 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP; 03 Mar 2015 02:21:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,681,1418112000"; d="scan'208";a="686073607" Received: from tgore-linux.isw.intel.com ([10.102.226.47]) by fmsmga002.fm.intel.com with ESMTP; 03 Mar 2015 02:23:02 -0800 From: tim.gore@intel.com To: intel-gfx@lists.freedesktop.org Date: Tue, 3 Mar 2015 10:23:00 +0000 Message-Id: <1425378180-16577-1-git-send-email-tim.gore@intel.com> X-Mailer: git-send-email 2.3.0 Cc: daniel.vetter@ffwll.ch, thomas.wood@intel.com Subject: [Intel-gfx] [PATCH i-g-t v4] tests/gem_render_linear_blits: split into two subtests 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=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 From: Tim Gore The gem_render_linear_blits test tends to get oom killed on low memory (< 4GB) Android systems. This is because the test tries to allocate (sysinfo.totalram * 9 / 10) in buffer objects and the remaining 10% of memory is not always enough for the Android system. After a discussion with Chris Wilson I have split this test into a "basic" and an "apperture-thrash" subtest, in the same way as gem_linear_blits. The basic test uses just two buffer objects and the apperture-thrash test is skipped if there is insuffiecient memory. v2: Following comment from Chris Wilson: a) Remove the command line option for count. b) Add a third subtest to ensure swap is tested v3: Replace some leading spaces with tabs v4: Follwing comment from Daniel Vetter: a) Use igt_main macro instead of "open coding", and b) cull some more leading spaces Signed-off-by: Tim Gore --- tests/gem_render_linear_blits.c | 74 +++++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 29 deletions(-) diff --git a/tests/gem_render_linear_blits.c b/tests/gem_render_linear_blits.c index 60ba831..f83c6d4 100644 --- a/tests/gem_render_linear_blits.c +++ b/tests/gem_render_linear_blits.c @@ -73,25 +73,21 @@ check_bo(int fd, uint32_t handle, uint32_t val) gem_read(fd, handle, 0, linear, sizeof(linear)); for (i = 0; i < WIDTH*HEIGHT; i++) { igt_assert_f(linear[i] == val, - "Expected 0x%08x, found 0x%08x " - "at offset 0x%08x\n", - val, linear[i], i * 4); + "Expected 0x%08x, found 0x%08x " + "at offset 0x%08x\n", + val, linear[i], i * 4); val++; } } -int main(int argc, char **argv) +static void run_test (int fd, int count) { drm_intel_bufmgr *bufmgr; struct intel_batchbuffer *batch; uint32_t *start_val; drm_intel_bo **bo; uint32_t start = 0; - int i, j, fd, count; - - igt_simple_init(argc, argv); - - fd = drm_open_any(); + int i, j; render_copy = igt_get_render_copyfunc(intel_get_drm_devid(fd)); igt_require(render_copy); @@ -99,24 +95,6 @@ int main(int argc, char **argv) bufmgr = drm_intel_bufmgr_gem_init(fd, 4096); batch = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd)); - count = 0; - if (igt_run_in_simulation()) - count = 2; - if (argc > 1) - count = atoi(argv[1]); - - if (count == 0) - count = 3 * gem_aperture_size(fd) / SIZE / 2; - else if (count < 2) { - igt_warn("count must be >= 2\n"); - return 1; - } - - if (count > intel_get_total_ram_mb() * 9 / 10) { - count = intel_get_total_ram_mb() * 9 / 10; - igt_info("not enough RAM to run test, reducing buffer count\n"); - } - bo = malloc(sizeof(*bo)*count); start_val = malloc(sizeof(*start_val)*count); @@ -128,7 +106,7 @@ int main(int argc, char **argv) gem_write(fd, bo[i]->handle, 0, linear, sizeof(linear)); } - igt_info("Verifying initialisation...\n"); + igt_info("Verifying initialisation - %d buffers of %d bytes\n", count, SIZE); for (i = 0; i < count; i++) check_bo(fd, bo[i]->handle, start_val[i]); @@ -153,7 +131,7 @@ int main(int argc, char **argv) check_bo(fd, bo[i]->handle, start_val[i]); if (igt_run_in_simulation()) - return 0; + return; igt_info("Cyclic blits, backward...\n"); for (i = 0; i < count * 4; i++) { @@ -200,5 +178,43 @@ int main(int argc, char **argv) for (i = 0; i < count; i++) check_bo(fd, bo[i]->handle, start_val[i]); + /* release resources */ + for (i = 0; i < count; i++) { + drm_intel_bo_unreference(bo[i]); + } + intel_batchbuffer_free(batch); + drm_intel_bufmgr_destroy(bufmgr); +} + +igt_main +{ + static int fd = 0; + int count=0; + + igt_fixture { + fd = drm_open_any(); + } + + igt_subtest("basic") { + run_test(fd, 2); + } + + /* the rest of the tests are too long for simulation */ + igt_skip_on_simulation(); + + igt_subtest("apperture-thrash") { + count = 3 * gem_aperture_size(fd) / SIZE / 2; + intel_require_memory(count, SIZE, CHECK_RAM); + run_test(fd, count); + } + + igt_subtest("swap-thrash") { + uint64_t swap_mb = intel_get_total_swap_mb(); + igt_require(swap_mb > 0); + count = ((intel_get_avail_ram_mb() + (swap_mb / 2)) * 1024*1024) / SIZE; + intel_require_memory(count, SIZE, CHECK_RAM | CHECK_SWAP); + run_test(fd, count); + } + igt_exit(); }