From patchwork Wed May 13 11:53:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: ankitprasad.r.sharma@intel.com X-Patchwork-Id: 6396491 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 463F39F1C2 for ; Wed, 13 May 2015 12:07:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 40E3F203E6 for ; Wed, 13 May 2015 12:07:38 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 2A46720390 for ; Wed, 13 May 2015 12:07:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 930FA6E18F; Wed, 13 May 2015 05:07:36 -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 F02D76E21E for ; Wed, 13 May 2015 05:07:34 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP; 13 May 2015 05:07:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,420,1427785200"; d="scan'208";a="570691585" Received: from ankitprasad-desktop.iind.intel.com ([10.223.82.39]) by orsmga003.jf.intel.com with ESMTP; 13 May 2015 05:07:34 -0700 From: ankitprasad.r.sharma@intel.com To: intel-gfx@lists.freedesktop.org Date: Wed, 13 May 2015 17:23:43 +0530 Message-Id: <1431518024-16296-3-git-send-email-ankitprasad.r.sharma@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1431518024-16296-1-git-send-email-ankitprasad.r.sharma@intel.com> References: <1431518024-16296-1-git-send-email-ankitprasad.r.sharma@intel.com> MIME-Version: 1.0 Cc: Ankitprasad Sharma , akash.goel@intel.com, shashidhar.hiremath@intel.com Subject: [Intel-gfx] [PATCH 2/3] igt/gem_pread: Support to verify pread/pwrite for non-shmem backed obj 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: , 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: Ankitprasad Sharma This patch adds support to verify pread/pwrite for non-shmem backed objects. It also shows the pread/pwrite speed. It also tests speeds for pread with and without user side page faults Signed-off-by: Ankitprasad Sharma --- tests/gem_pread.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/gem_pwrite.c | 45 ++++++++++++++++++++++++ 2 files changed, 145 insertions(+) diff --git a/tests/gem_pread.c b/tests/gem_pread.c index cc83948..95162d5 100644 --- a/tests/gem_pread.c +++ b/tests/gem_pread.c @@ -41,6 +41,10 @@ #include "drmtest.h" #define OBJECT_SIZE 16384 +#define LARGE_OBJECT_SIZE 1024 * 1024 +#define KGRN "\x1B[32m" +#define KRED "\x1B[31m" +#define KNRM "\x1B[0m" static void do_gem_read(int fd, uint32_t handle, void *buf, int len, int loops) { @@ -76,11 +80,14 @@ static const char *bytes_per_sec(char *buf, double v) uint32_t *src, dst; +uint32_t *dst_user, src_stolen, large_stolen; +uint32_t *stolen_pf_user, *stolen_nopf_user; int fd, count; int main(int argc, char **argv) { int object_size = 0; + int large_obj_size = LARGE_OBJECT_SIZE; uint32_t buf[20]; const struct { int level; @@ -90,6 +97,9 @@ int main(int argc, char **argv) { 1, "snoop" }, { 2, "display" }, { -1 }, + { -1, "stolen-uncached"}, + { -1, "stolen-snoop"}, + { -1, "stolen-display"}, }, *c; igt_subtest_init(argc, argv); @@ -106,6 +116,8 @@ int main(int argc, char **argv) dst = gem_create(fd, object_size); src = malloc(object_size); + src_stolen = gem_create_stolen(fd, object_size); + dst_user = malloc(object_size); } igt_subtest("normal") { @@ -142,9 +154,97 @@ int main(int argc, char **argv) } } + igt_subtest("stolen-normal") { + for (count = 1; count <= 1<<17; count <<= 1) { + struct timeval start, end; + + gettimeofday(&start, NULL); + do_gem_read(fd, src_stolen, dst_user, object_size, count); + gettimeofday(&end, NULL); + igt_info("Time to pread %d bytes x %6d: %7.3fµs, %s\n", + object_size, count, + elapsed(&start, &end, count), + bytes_per_sec((char *)buf, + object_size/elapsed(&start, &end, count)*1e6)); + fflush(stdout); + } + } + for (c = cache; c->level != -1; c++) { + igt_subtest((c + 4)->name) { + gem_set_caching(fd, src_stolen, c->level); + + for (count = 1; count <= 1<<17; count <<= 1) { + struct timeval start, end; + + gettimeofday(&start, NULL); + do_gem_read(fd, src_stolen, dst_user, + object_size, count); + gettimeofday(&end, NULL); + igt_info("Time to %s pread %d bytes x %6d: %7.3fµs, %s\n", + (c + 4)->name, object_size, count, + elapsed(&start, &end, count), + bytes_per_sec((char *)buf, + object_size/elapsed(&start, &end, count)*1e6)); + fflush(stdout); + } + } + } + + /* List pread times for stolen area with 1 page fault (page fault only + * first time) and multiple page faults (unmapping the pages at the + * end of each iteration) + */ + igt_subtest("pagefault-pread") { + large_stolen = gem_create_stolen(fd, large_obj_size); + stolen_nopf_user = (uint32_t *) mmap(NULL, large_obj_size, + PROT_WRITE, + MAP_ANONYMOUS|MAP_PRIVATE, + -1, 0); + + for (count = 1; count <= 10; count ++) { + struct timeval start, end; + uint32_t t_elapsed = 0; + + gettimeofday(&start, NULL); + do_gem_read(fd, large_stolen, stolen_nopf_user, + large_obj_size, 1); + gettimeofday(&end, NULL); + t_elapsed = elapsed(&start, &end, 1); + igt_info("Pagefault-N - Time to pread %d bytes: %7.3fµs, %s\n", + large_obj_size, + elapsed(&start, &end, 1), + bytes_per_sec((char *)buf, + large_obj_size/elapsed(&start, &end, 1)*1e6)); + + stolen_pf_user = (uint32_t *) mmap(NULL, large_obj_size, + PROT_WRITE, + MAP_ANONYMOUS|MAP_PRIVATE, + -1, 0); + + gettimeofday(&start, NULL); + do_gem_read(fd, large_stolen, stolen_pf_user, + large_obj_size, 1); + gettimeofday(&end, NULL); + igt_info("Pagefault-Y - Time to pread %d bytes: %7.3fµs, %s%s%s\n", + large_obj_size, + elapsed(&start, &end, 1), + t_elapsed < elapsed(&start, &end, 1) ? KGRN : KRED, + bytes_per_sec((char *)buf, + large_obj_size/elapsed(&start, &end, 1)*1e6), + KNRM); + fflush(stdout); + munmap(stolen_pf_user, large_obj_size); + } + munmap(stolen_nopf_user, large_obj_size); + gem_close(fd, large_stolen); + } + + igt_fixture { free(src); gem_close(fd, dst); + free(dst_user); + gem_close(fd, src_stolen); close(fd); } diff --git a/tests/gem_pwrite.c b/tests/gem_pwrite.c index 6378b0a..dd1ca95 100644 --- a/tests/gem_pwrite.c +++ b/tests/gem_pwrite.c @@ -82,6 +82,7 @@ static const char *bytes_per_sec(char *buf, double v) uint32_t *src, dst; +uint32_t *src_user, dst_stolen; int fd; int main(int argc, char **argv) @@ -97,6 +98,9 @@ int main(int argc, char **argv) { 1, "snoop" }, { 2, "display" }, { -1 }, + { -1, "stolen-uncached"}, + { -1, "stolen-snoop"}, + { -1, "stolen-display"}, }, *c; igt_skip_on_simulation(); @@ -114,6 +118,8 @@ int main(int argc, char **argv) dst = gem_create(fd, object_size); src = malloc(object_size); + dst_stolen = gem_create_stolen(fd, object_size); + src_user = malloc(object_size); } igt_subtest("normal") { @@ -150,9 +156,48 @@ int main(int argc, char **argv) } } + igt_subtest("stolen-normal") { + for (count = 1; count <= 1<<17; count <<= 1) { + struct timeval start, end; + + gettimeofday(&start, NULL); + do_gem_write(fd, dst_stolen, src_user, + object_size, count); + gettimeofday(&end, NULL); + igt_info("Time to pwrite %d bytes x %6d: %7.3fµs, %s\n", + object_size, count, + elapsed(&start, &end, count), + bytes_per_sec((char *)buf, + object_size/elapsed(&start, &end, count)*1e6)); + fflush(stdout); + } + } + + for (c = cache; c->level != -1; c++) { + igt_subtest((c + 4)->name) { + gem_set_caching(fd, dst, c->level); + for (count = 1; count <= 1<<17; count <<= 1) { + struct timeval start, end; + + gettimeofday(&start, NULL); + do_gem_write(fd, dst_stolen, src_user, + object_size, count); + gettimeofday(&end, NULL); + igt_info("Time to %s pwrite %d bytes x %6d: %7.3fµs, %s\n", + (c + 4)->name, object_size, count, + elapsed(&start, &end, count), + bytes_per_sec((char *)buf, + object_size/elapsed(&start, &end, count)*1e6)); + fflush(stdout); + } + } + } + igt_fixture { free(src); gem_close(fd, dst); + free(src_user); + gem_close(fd, dst_stolen); close(fd); }