From patchwork Wed Jun 24 09:42:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derek Morton X-Patchwork-Id: 6666571 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 628649F39B for ; Wed, 24 Jun 2015 09:42:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9691D20698 for ; Wed, 24 Jun 2015 09:42:17 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id C380520696 for ; Wed, 24 Jun 2015 09:42:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2CA526EB2A; Wed, 24 Jun 2015 02:42:16 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id 628106EB2A for ; Wed, 24 Jun 2015 02:42:15 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP; 24 Jun 2015 02:42:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,671,1427785200"; d="scan'208";a="716736004" Received: from djmorton-linux.isw.intel.com ([10.102.226.153]) by orsmga001.jf.intel.com with ESMTP; 24 Jun 2015 02:42:13 -0700 From: Derek Morton To: intel-gfx@lists.freedesktop.org Date: Wed, 24 Jun 2015 10:42:11 +0100 Message-Id: <1435138931-9496-1-git-send-email-derek.j.morton@intel.com> X-Mailer: git-send-email 1.9.1 Subject: [Intel-gfx] [PATCH i-g-t v3] tests/gem_fence_thrash.c: Reduce memory usage 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 On android platforms with 1Gb RAM gem_fence_thrash was failing with an out of memory error. This patch causes gem_close() to be called when a handle is no longer required rather than relying on the cleanup when the fd is closed. This greatly improves the memory footprint of the test allowing it to run on 1Mb systems. Also fixed a leak of the 'threads' variable. v2: Simplified as per Chris Wilson's suggestion. v3: Added calls to munmap() from bo_copy() Signed-off-by: Derek Morton --- tests/gem_fence_thrash.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/gem_fence_thrash.c b/tests/gem_fence_thrash.c index 6447e13..f4ccfc0 100644 --- a/tests/gem_fence_thrash.c +++ b/tests/gem_fence_thrash.c @@ -63,7 +63,7 @@ static void * bo_create (int fd, int tiling) { void *ptr; - int handle; + uint32_t handle; handle = gem_create(fd, OBJECT_SIZE); @@ -80,6 +80,7 @@ bo_create (int fd, int tiling) /* XXX: mmap_gtt pulls the bo into the GTT read domain. */ gem_sync(fd, handle); + gem_close(fd, handle); return ptr; } @@ -100,6 +101,9 @@ bo_copy (void *_arg) sched_yield (); } + munmap(a, OBJECT_SIZE); + munmap(b, OBJECT_SIZE); + return NULL; } @@ -188,6 +192,8 @@ static int run_test(int threads_per_fence, void *f, int tiling, for (n = 0; n < num_threads; n++) pthread_join (threads[n], NULL); + + free(threads); } else { void *(*func)(void *) = f; igt_assert(func(&t) == (void *)0);