From patchwork Tue Jun 23 15:45:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derek Morton X-Patchwork-Id: 6662041 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 00AD59F380 for ; Tue, 23 Jun 2015 15:46:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 22BAB20636 for ; Tue, 23 Jun 2015 15:46:00 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 3EBFE20515 for ; Tue, 23 Jun 2015 15:45:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9EA876E9E2; Tue, 23 Jun 2015 08:45:58 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTP id 6B8F66E9E2 for ; Tue, 23 Jun 2015 08:45:57 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP; 23 Jun 2015 08:45:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,666,1427785200"; d="scan'208";a="751801401" Received: from djmorton-linux.isw.intel.com ([10.102.226.153]) by orsmga002.jf.intel.com with ESMTP; 23 Jun 2015 08:45:55 -0700 From: Derek Morton To: intel-gfx@lists.freedesktop.org Date: Tue, 23 Jun 2015 16:45:52 +0100 Message-Id: <1435074352-19241-1-git-send-email-derek.j.morton@intel.com> X-Mailer: git-send-email 1.9.1 Cc: thomas.wood@intel.com Subject: [Intel-gfx] [PATCH i-g-t v2] 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. Signed-off-by: Derek Morton --- tests/gem_fence_thrash.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/gem_fence_thrash.c b/tests/gem_fence_thrash.c index 6447e13..e2ed024 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; } @@ -188,6 +189,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);