From patchwork Tue Jul 22 10:14:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 4600571 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EF5CEC0514 for ; Tue, 22 Jul 2014 10:15:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 268BC20154 for ; Tue, 22 Jul 2014 10:15:58 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 145932014A for ; Tue, 22 Jul 2014 10:15:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A005F6E27C; Tue, 22 Jul 2014 03:15:56 -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 460186E27C for ; Tue, 22 Jul 2014 03:15:55 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP; 22 Jul 2014 03:09:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,709,1400050800"; d="scan'208";a="565378550" Received: from tursulin-linux.iwi.intel.com ([172.28.253.62]) by fmsmga001.fm.intel.com with ESMTP; 22 Jul 2014 03:15:53 -0700 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Date: Tue, 22 Jul 2014 11:14:51 +0100 Message-Id: <1406024091-30396-1-git-send-email-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 1.9.3 Subject: [Intel-gfx] [PATCH] igt/gem_userptr_blits: Fix multi-threaded mm stress tester X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 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=-3.2 required=5.0 tests=BAYES_00,HK_RANDOM_FROM, 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 Two parts to the fix: 1. Do not use pthread_cancel since not available on Android. 2. Do not assert in the thread since that does not get propagated to the process. Rather pass out any failures so we know test did not work as expected. Signed-off-by: Tvrtko Ursulin Cc: Tim Gore Reviewed-by: Tim Gore --- tests/gem_userptr_blits.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/tests/gem_userptr_blits.c b/tests/gem_userptr_blits.c index 2a52856..3277096 100644 --- a/tests/gem_userptr_blits.c +++ b/tests/gem_userptr_blits.c @@ -1137,21 +1137,32 @@ static void test_unmap_cycles(int fd, int expected) test_unmap(fd, expected); } +struct stress_thread_data { + unsigned int stop; + int exit_code; +}; + static void *mm_stress_thread(void *data) { - void *ptr; - int ret; + struct stress_thread_data *stdata = (struct stress_thread_data *)data; + void *ptr; + int ret; - for (;;) { + while (!stdata->stop) { ptr = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); - igt_assert(ptr != MAP_FAILED); + if (ptr == MAP_FAILED) { + stdata->exit_code = -EFAULT; + break; + } ret = munmap(ptr, PAGE_SIZE); - igt_assert(ret == 0); - pthread_testcancel(); - } + if (ret) { + stdata->exit_code = errno; + break; + } + } - return NULL; + return NULL; } static void test_stress_mm(int fd) @@ -1161,10 +1172,13 @@ static void test_stress_mm(int fd) unsigned int loops = 100000; uint32_t handle; void *ptr; + struct stress_thread_data stdata; + + memset(&stdata, 0, sizeof(stdata)); igt_assert(posix_memalign(&ptr, PAGE_SIZE, PAGE_SIZE) == 0); - ret = pthread_create(&t, NULL, mm_stress_thread, NULL); + ret = pthread_create(&t, NULL, mm_stress_thread, &stdata); igt_assert(ret == 0); while (loops--) { @@ -1176,10 +1190,11 @@ static void test_stress_mm(int fd) free(ptr); - ret = pthread_cancel(t); - igt_assert(ret == 0); + stdata.stop = 1; ret = pthread_join(t, NULL); igt_assert(ret == 0); + + igt_assert(stdata.exit_code == 0); } unsigned int total_ram;