From patchwork Fri Sep 29 12:25:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13404190 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D7C1EE71D22 for ; Fri, 29 Sep 2023 12:25:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6096F10E6FD; Fri, 29 Sep 2023 12:25:30 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6F7DE10E6FC; Fri, 29 Sep 2023 12:25:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695990326; x=1727526326; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fHoj1IsAZty2I0ZpHfNKydpjxbohb3jClnXT5IDWVHs=; b=XpHUXgd5hmRpSfX2n9RMt7gOxMEHOaccq+uSuGgHfyCsD0rIKgwYzLTX DceglttEsvRjuUbuExVJ8OCYhUwPY89clHb+s6LN0Z3RKy80K0R+22aH8 YIV/ptaVCkAVlsl/mKiVKstphtUaEfyqmZnihM5OYoM+ydD0DxKcQ9FJm zXqoal5rFUwOJM/8x1SeGJYdYJ9ydOoB0yI3d0tn3OopQ7ji0hl6IGW2p rNs4d9vT8LtQAytG9s7UC6WESoiHBqCQGp/Xye+RkjqOPiYSJIyOvpqnr Rbon/oJUb+ZEXomRVGhj68snQVR7XaGgHaQ+r3GaTgUJXJMgEAOJh0bNx g==; X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="446443760" X-IronPort-AV: E=Sophos;i="6.03,187,1694761200"; d="scan'208";a="446443760" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 05:25:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="726577127" X-IronPort-AV: E=Sophos;i="6.03,187,1694761200"; d="scan'208";a="726577127" Received: from pbrady4x-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.203.84]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 05:25:25 -0700 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Date: Fri, 29 Sep 2023 13:25:06 +0100 Message-Id: <20230929122517.349348-2-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230929122517.349348-1-tvrtko.ursulin@linux.intel.com> References: <20230929122517.349348-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 01/12] tests/i915/drm_fdinfo: Check engine info is supported X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" From: Tvrtko Ursulin On top of checking that parsing works, check that there are some engines present. This will be needed once the memory stats are added and so return value from __igt_parse_drm_fdinfo() will then be possible to be greater than zero even when engine stats are not supported. Signed-off-by: Tvrtko Ursulin --- tests/intel/drm_fdinfo.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/intel/drm_fdinfo.c b/tests/intel/drm_fdinfo.c index aca19db50680..344c44dce78b 100644 --- a/tests/intel/drm_fdinfo.c +++ b/tests/intel/drm_fdinfo.c @@ -737,6 +737,7 @@ igt_main igt_require_gem(i915); igt_require(igt_parse_drm_fdinfo(i915, &info, NULL, 0, NULL, 0)); + igt_require(info.num_engines); ctx = intel_ctx_create_all_physical(i915); From patchwork Fri Sep 29 12:25:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13404189 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D369EE71D22 for ; Fri, 29 Sep 2023 12:25:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 330A810E6FE; Fri, 29 Sep 2023 12:25:30 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id ACB0D10E6FD; Fri, 29 Sep 2023 12:25:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695990327; x=1727526327; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3nWxMUgQDs+lJ2jqZ/3fRn69jkLn2xn7nq16lXtvZgI=; b=eNZYOj4mmKX86H84W/uo0aQnB+PeTsoimPppgKz6ZaA/5xxeHX4/sein VvJr7A6gXAxNDvPClWxPho+/gqRpIvrH+zNCXVx38hLEGVO8AK+mgeg35 2hjEY/a9s2vXZgTOCHfq2hWxqGIqxJ4ox2ss6SOf0w+mhVSSURiQRZoID iKI4lPomufb1V76BgwhpW1jjGfDRyaMw9Yn8zmlWC/qurV/42cRwFkNId moYcuQj0GNlGjIVMgWDxrNvAl1VwTgpq50AcR9nQ8ItvJrBjOJ6VTI6ik DLOHzUHncsTrSbmaudiuVOqFiELyT1L2J+hqG7WcvgqlLaTA33H/L2LgT Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="446443761" X-IronPort-AV: E=Sophos;i="6.03,187,1694761200"; d="scan'208";a="446443761" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 05:25:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="726577138" X-IronPort-AV: E=Sophos;i="6.03,187,1694761200"; d="scan'208";a="726577138" Received: from pbrady4x-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.203.84]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 05:25:26 -0700 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Date: Fri, 29 Sep 2023 13:25:07 +0100 Message-Id: <20230929122517.349348-3-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230929122517.349348-1-tvrtko.ursulin@linux.intel.com> References: <20230929122517.349348-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 02/12] tests/i915/drm_fdinfo: Stress test context close versus fdinfo reads X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" From: Tvrtko Ursulin A short smoke tests to exercise fdinfo reads in parallel to contexts getting created and destroyed. Signed-off-by: Tvrtko Ursulin --- tests/intel/drm_fdinfo.c | 68 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/tests/intel/drm_fdinfo.c b/tests/intel/drm_fdinfo.c index 344c44dce78b..c4218b0d16e6 100644 --- a/tests/intel/drm_fdinfo.c +++ b/tests/intel/drm_fdinfo.c @@ -22,11 +22,14 @@ * */ +#include + #include "igt.h" #include "igt_core.h" #include "igt_device.h" #include "igt_drm_fdinfo.h" #include "i915/gem.h" +#include "i915/gem_create.h" #include "i915/gem_vm.h" #include "intel_ctx.h" /** @@ -72,6 +75,8 @@ * SUBTEST: virtual-busy-idle-all * * SUBTEST: virtual-idle + * + * SUBTEST: context-close-stress */ IGT_TEST_DESCRIPTION("Test the i915 drm fdinfo data"); @@ -717,6 +722,56 @@ virtual_all(int i915, const intel_ctx_cfg_t *base_cfg, unsigned int flags) } } +static void stress_context_close(int i915) +{ + const uint32_t bbe = MI_BATCH_BUFFER_END; + struct igt_helper_process reader = { }; + struct drm_client_fdinfo info; + uint32_t batch; + int dir, ret; + char buf[64]; + + ret = snprintf(buf, sizeof(buf), "%u", i915); + igt_assert(ret > 0 && ret < sizeof(buf)); + + dir = open("/proc/self/fdinfo", O_DIRECTORY | O_RDONLY); + igt_assert_fd(dir); + + memset(&info, 0, sizeof(info)); + ret = __igt_parse_drm_fdinfo(dir, buf, &info, NULL, 0, NULL, 0); + igt_assert(ret > 0); + igt_require(info.num_regions); + + batch = gem_create(i915, 4096); + gem_write(i915, batch, 0, &bbe, sizeof(bbe)); + + igt_fork_helper(&reader) { + for (;;) { + memset(&info, 0, sizeof(info)); + ret = __igt_parse_drm_fdinfo(dir, buf, &info, + NULL, 0, NULL, 0); + igt_assert(ret > 0); + } + } + + igt_until_timeout(10) { + struct drm_i915_gem_exec_object2 obj = { + .handle = batch, + }; + struct drm_i915_gem_execbuffer2 eb = { + .buffers_ptr = to_user_pointer(&obj), + .buffer_count = 1, + }; + + eb.rsvd1 = gem_context_create(i915); + igt_assert(eb.rsvd1); + gem_execbuf(i915, &eb); + gem_context_destroy(i915, eb.rsvd1); + } + + igt_stop_helper(&reader); +} + #define test_each_engine(T, i915, ctx, e) \ igt_subtest_with_dynamic(T) for_each_ctx_engine(i915, ctx, e) \ igt_dynamic_f("%s", e->name) @@ -848,6 +903,19 @@ igt_main test_each_engine("isolation", i915, ctx, e) single(i915, ctx, e, TEST_BUSY | TEST_ISOLATION); + igt_subtest_group { + int newfd; + + igt_fixture + newfd = drm_reopen_driver(i915); + + igt_subtest("context-close-stress") + stress_context_close(newfd); + + igt_fixture + drm_close_driver(newfd); + } + igt_fixture { intel_ctx_destroy(i915, ctx); drm_close_driver(i915); From patchwork Fri Sep 29 12:25:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13404191 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D9A7EE71D20 for ; Fri, 29 Sep 2023 12:25:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 71AED10E702; Fri, 29 Sep 2023 12:25:33 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 971D810E6FD; Fri, 29 Sep 2023 12:25:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695990329; x=1727526329; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PRebmyDH50utciPFwqa7O3shuhf57IGoHhVfz8Wwcuw=; b=C873gftfc3LL5kYZ1BDzMQR859EnSKCFTUjrgQkBDMfwKbpSBZ2iKfk/ CBU46tfukxIfmaIjn4CICFtij5TyvXeyONayUtOUuvzbgSfa4WOKd7XYE l4BfNb9oaIB0+zT25AToE1f9hhtGy1C04xiyZnS/95sHAmdU7/+WLxADS RHlu0/SGxFqXDcL9nrc/3cN4JKDunBaXTU5PvLtGBHZ79XtLL/yxH2MA+ Xv+uxcONNjL5wup7JPXNZBXNt8Q4O2CcWDdsQwdCtEuwXfPSXpOcKXAdu fF14W4tUY4dBuMP+TvAxQhmj7ZrMJp6iYpuFgSQ7lKQfSk5CeC5GBZmL7 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="446443764" X-IronPort-AV: E=Sophos;i="6.03,187,1694761200"; d="scan'208";a="446443764" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 05:25:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="726577144" X-IronPort-AV: E=Sophos;i="6.03,187,1694761200"; d="scan'208";a="726577144" Received: from pbrady4x-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.203.84]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 05:25:27 -0700 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Date: Fri, 29 Sep 2023 13:25:08 +0100 Message-Id: <20230929122517.349348-4-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230929122517.349348-1-tvrtko.ursulin@linux.intel.com> References: <20230929122517.349348-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 03/12] tests/i915/drm_fdinfo: Add some memory info tests X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" From: Tvrtko Ursulin A few basic smoke tests to check per client memory info looks legit. Signed-off-by: Tvrtko Ursulin --- tests/intel/drm_fdinfo.c | 217 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 217 insertions(+) diff --git a/tests/intel/drm_fdinfo.c b/tests/intel/drm_fdinfo.c index c4218b0d16e6..3ced658f2faa 100644 --- a/tests/intel/drm_fdinfo.c +++ b/tests/intel/drm_fdinfo.c @@ -23,6 +23,7 @@ */ #include +#include #include "igt.h" #include "igt_core.h" @@ -76,6 +77,16 @@ * * SUBTEST: virtual-idle * + * SUBTEST: memory-info-idle + * + * SUBTEST: memory-info-active + * + * SUBTEST: memory-info-resident + * + * SUBTEST: memory-info-purgeable + * + * SUBTEST: memory-info-shared + * * SUBTEST: context-close-stress */ @@ -143,6 +154,11 @@ static unsigned int measured_usleep(unsigned int usec) #define FLAG_HANG (8) #define TEST_ISOLATION (16) +#define TEST_ACTIVE TEST_BUSY +#define TEST_RESIDENT (32) +#define TEST_PURGEABLE (64) +#define TEST_SHARED (128) + static void end_spin(int fd, igt_spin_t *spin, unsigned int flags) { if (!spin) @@ -772,6 +788,172 @@ static void stress_context_close(int i915) igt_stop_helper(&reader); } +static size_t read_fdinfo(char *buf, const size_t sz, int at, const char *name) +{ + size_t count; + int fd; + + fd = openat(at, name, O_RDONLY); + if (fd < 0) + return 0; + + count = read(fd, buf, sz - 1); + if (count > 0) + buf[count - 1] = 0; + close(fd); + + return count > 0 ? count : 0; +} + +/* + * At least this much, but maybe less if we started with a driver internal + * baseline which can go away behind our back. + */ +#define fdinfo_assert_gte(cur, prev, sz, base) \ +({ \ + int64_t __sz = (sz) - (base); \ + int64_t __d = (cur) - (prev); \ + igt_assert_f(__d >= __sz, \ + "prev=%"PRIu64" cur=%"PRIu64" delta=%"PRId64" sz=%"PRIu64" baseline=%"PRIu64"\n%s\n", \ + (prev), (cur), __d, (sz), (base), fdinfo_buf); \ +}) + +#define fdinfo_assert_eq(cur, prev, sz, base) \ +({ \ + int64_t __d = (cur) - (prev); \ + igt_assert_f(__d == 0, \ + "prev=%"PRIu64" cur=%"PRIu64" delta=%"PRId64" sz=%"PRIu64" baseline=%"PRIu64"\n%s\n", \ + (prev), (cur), __d, (sz), (base), fdinfo_buf); \ +}) + +static void +test_memory(int i915, struct gem_memory_region *mr, unsigned int flags) +{ + const unsigned int r = mr->ci.memory_class == I915_MEMORY_CLASS_SYSTEM ? 0 : 1; /* See region map */ + const uint64_t max_mem = 512ull * 1024 * 1024; + const uint64_t max_bo = 16ull * 1024 * 1024; + struct drm_client_fdinfo base_info, prev_info = { }; + struct drm_client_fdinfo info = { }; + char buf[64], fdinfo_buf[4096]; + igt_spin_t *spin = NULL; + uint64_t total = 0, sz; + uint64_t ahnd; + int ret, dir; + + i915 = drm_reopen_driver(i915); + + ahnd = get_reloc_ahnd(i915, 0); + + ret = snprintf(buf, sizeof(buf), "%u", i915); + igt_assert(ret > 0 && ret < sizeof(buf)); + + dir = open("/proc/self/fdinfo", O_DIRECTORY | O_RDONLY); + igt_assert_fd(dir); + + gem_quiescent_gpu(i915); + ret = __igt_parse_drm_fdinfo(dir, buf, &info, NULL, 0, NULL, 0); + igt_assert(ret > 0); + igt_require(info.num_regions); + memcpy(&prev_info, &info, sizeof(info)); + memcpy(&base_info, &info, sizeof(info)); + + while (total < max_mem) { + static const char *region_map[] = { + "system0", + "local0", + }; + uint32_t bo; + + sz = random() % max_bo; + ret = __gem_create_in_memory_region_list(i915, &bo, &sz, 0, + &mr->ci, 1); + igt_assert_eq(ret, 0); + total += sz; + + if (flags & (TEST_RESIDENT | TEST_PURGEABLE | TEST_ACTIVE)) + spin = igt_spin_new(i915, + .dependency = bo, + .ahnd = ahnd); + else + spin = NULL; + + if (flags & TEST_PURGEABLE) { + gem_madvise(i915, bo, I915_MADV_DONTNEED); + igt_spin_free(i915, spin); + gem_quiescent_gpu(i915); + spin = NULL; + } + + if (flags & TEST_SHARED) { + struct drm_gem_open open_struct; + struct drm_gem_flink flink; + + flink.handle = bo; + ret = ioctl(i915, DRM_IOCTL_GEM_FLINK, &flink); + igt_assert_eq(ret, 0); + + open_struct.name = flink.name; + ret = ioctl(i915, DRM_IOCTL_GEM_OPEN, &open_struct); + igt_assert_eq(ret, 0); + igt_assert(open_struct.handle != 0); + } + + memset(&info, 0, sizeof(info)); + ret = __igt_parse_drm_fdinfo(dir, buf, &info, + NULL, 0, + region_map, ARRAY_SIZE(region_map)); + igt_assert(ret > 0); + igt_assert(info.num_regions); + + read_fdinfo(fdinfo_buf, sizeof(fdinfo_buf), dir, buf); + + /* >= to account for objects out of our control */ + fdinfo_assert_gte(info.region_mem[r].total, + prev_info.region_mem[r].total, + sz, + base_info.region_mem[r].total); + + if (flags & TEST_SHARED) + fdinfo_assert_gte(info.region_mem[r].shared, + prev_info.region_mem[r].shared, + sz, + base_info.region_mem[r].shared); + else + fdinfo_assert_eq(info.region_mem[r].shared, + prev_info.region_mem[r].shared, + sz, + base_info.region_mem[r].shared); + + if (flags & (TEST_RESIDENT | TEST_PURGEABLE | TEST_ACTIVE)) + fdinfo_assert_gte(info.region_mem[r].resident, + (uint64_t)0, /* We can only be sure the current buffer is resident. */ + sz, + (uint64_t)0); + + if (flags & TEST_PURGEABLE) + fdinfo_assert_gte(info.region_mem[r].purgeable, + (uint64_t)0, /* We can only be sure the current buffer is purgeable (subset of resident). */ + sz, + (uint64_t)0); + + if (flags & TEST_ACTIVE) + fdinfo_assert_gte(info.region_mem[r].active, + (uint64_t)0, /* We can only be sure the current buffer is active. */ + sz, + (uint64_t)0); + + memcpy(&prev_info, &info, sizeof(info)); + + if (spin) { + igt_spin_free(i915, spin); + gem_quiescent_gpu(i915); + } + } + + put_ahnd(ahnd); + close(i915); +} + #define test_each_engine(T, i915, ctx, e) \ igt_subtest_with_dynamic(T) for_each_ctx_engine(i915, ctx, e) \ igt_dynamic_f("%s", e->name) @@ -903,6 +1085,41 @@ igt_main test_each_engine("isolation", i915, ctx, e) single(i915, ctx, e, TEST_BUSY | TEST_ISOLATION); + igt_subtest_with_dynamic("memory-info-idle") { + for_each_memory_region(r, i915) { + igt_dynamic_f("%s", r->name) + test_memory(i915, r, 0); + } + } + + igt_subtest_with_dynamic("memory-info-resident") { + for_each_memory_region(r, i915) { + igt_dynamic_f("%s", r->name) + test_memory(i915, r, TEST_RESIDENT); + } + } + + igt_subtest_with_dynamic("memory-info-purgeable") { + for_each_memory_region(r, i915) { + igt_dynamic_f("%s", r->name) + test_memory(i915, r, TEST_PURGEABLE); + } + } + + igt_subtest_with_dynamic("memory-info-active") { + for_each_memory_region(r, i915) { + igt_dynamic_f("%s", r->name) + test_memory(i915, r, TEST_ACTIVE); + } + } + + igt_subtest_with_dynamic("memory-info-shared") { + for_each_memory_region(r, i915) { + igt_dynamic_f("%s", r->name) + test_memory(i915, r, TEST_SHARED); + } + } + igt_subtest_group { int newfd; From patchwork Fri Sep 29 12:25:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13404192 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F2DFDE71D21 for ; Fri, 29 Sep 2023 12:25:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2144310E700; Fri, 29 Sep 2023 12:25:34 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id CAA1110E700; Fri, 29 Sep 2023 12:25:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695990330; x=1727526330; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EL/WRwIdQJULtNfoc/4uDTgdJ0QIo7VKKQvLcvWWoAY=; b=Epkm6zVpYXdhpbMjqzv4I46026SngvLSJ0sD70uSauVpyitMojdiZ4aH mou/YVEFklwEgvbkTxFk827XCHjymSiqh3UyFlsvHDL6HvZPmPiZ2GCww FFRC0KYhdoKd2BFiuKpVwI0eItUzcFfoi9U+h6gy1jxymH3e/JYhy3Jz2 4d2J6BG6dII7kuvP4Z5Qt7FOFFVQOQcgTE+8w7mPXu/ulT+vjiETPE8td v31c4uliKMl0UIwHubdTQ34nHPccO24InXl6Y23d7L9bVIhp2I8+irKTJ JDmjTlngHA3A5oqht07pIY5atoeuIyBsE5OrMer7tup8YdEe2cLp8cdOI g==; X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="446443767" X-IronPort-AV: E=Sophos;i="6.03,187,1694761200"; d="scan'208";a="446443767" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 05:25:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="726577148" X-IronPort-AV: E=Sophos;i="6.03,187,1694761200"; d="scan'208";a="726577148" Received: from pbrady4x-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.203.84]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 05:25:29 -0700 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Date: Fri, 29 Sep 2023 13:25:09 +0100 Message-Id: <20230929122517.349348-5-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230929122517.349348-1-tvrtko.ursulin@linux.intel.com> References: <20230929122517.349348-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 04/12] tools/intel_gpu_top: Fix clients header width when no clients X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" From: Tvrtko Ursulin Recent refactoring broke the clients header in cases when there are no clients displayed. To fix it we need to account the width of the "NAME" label. Signed-off-by: Tvrtko Ursulin --- tools/intel_gpu_top.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c index 87e9681e53b4..66b76c4afed0 100644 --- a/tools/intel_gpu_top.c +++ b/tools/intel_gpu_top.c @@ -1965,6 +1965,8 @@ print_clients_header(struct igt_drm_clients *clients, int lines, int con_w, int con_h, int *class_w) { struct intel_clients *iclients = clients->private_data; + const int max_name_len = clients->max_name_len < 4 ? + 4 : clients->max_name_len; /* At least "NAME" */ if (output_mode == INTERACTIVE) { unsigned int num_active = 0; @@ -1988,9 +1990,8 @@ print_clients_header(struct igt_drm_clients *clients, int lines, num_active++; } - *class_w = width = - (con_w - len - clients->max_name_len - 1) / - num_active; + *class_w = width = (con_w - len - max_name_len - 1) / + num_active; for (i = 0; i <= iclients->classes.max_engine_id; i++) { const char *name = iclients->classes.names[i]; From patchwork Fri Sep 29 12:25:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13404195 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1A95EE71D22 for ; Fri, 29 Sep 2023 12:25:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 33F6A10E714; Fri, 29 Sep 2023 12:25:53 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0DFFB10E700; Fri, 29 Sep 2023 12:25:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695990332; x=1727526332; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fFC8zeAXYse+bJ24oEkQAdx6LySDbjEi5siD3StUVRM=; b=ibDScVqzXAEASgaZHTmA1VjbjYgffVFkjFEMppsZ8xVp1tpl58dcgdvw +K0x+aCTWLNB7uEAAvhmGWwqV7u9mJC8GUrWIMtOqRli5mumwo9ypEdoH fO/BtGVu+EdSPEUBdzYhKuV/yfeV4g9el+IUW3RulobWN3uHuKvaoxE/D AC6ud3APBQ5EIe+pzDWXgS7s/9l3YC4Z/MkcgvFM2DtNgWvbsVIA/2Vkc 86x06R1GqY2Rp0aViFAAu6m9lq2uYirZzMMw1e+GDApXfoo9HLfzjiJHe LRbC7C3bzYESQgdIB4njhFIsh+G1GrOp98PpX78vegrvM8I1BjBIrrKWI A==; X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="446443770" X-IronPort-AV: E=Sophos;i="6.03,187,1694761200"; d="scan'208";a="446443770" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 05:25:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="726577151" X-IronPort-AV: E=Sophos;i="6.03,187,1694761200"; d="scan'208";a="726577151" Received: from pbrady4x-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.203.84]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 05:25:30 -0700 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Date: Fri, 29 Sep 2023 13:25:10 +0100 Message-Id: <20230929122517.349348-6-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230929122517.349348-1-tvrtko.ursulin@linux.intel.com> References: <20230929122517.349348-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 05/12] tools/intel_gpu_top: Fix client layout on first sample period X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" From: Tvrtko Ursulin When I moved the client name to be last, I did not account for the fact current code skips showing engine utilisation until at least two sampling periods have passed. Consequence of this is that client name gets printed as the second field and not under the "NAME" column header. Fix it by emitting spaces instead of engine utilisation until two samples have been collected. Signed-off-by: Tvrtko Ursulin --- tools/intel_gpu_top.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c index 66b76c4afed0..de37ff603b6f 100644 --- a/tools/intel_gpu_top.c +++ b/tools/intel_gpu_top.c @@ -926,12 +926,14 @@ static void free_display_clients(struct igt_drm_clients *clients) static const char *bars[] = { " ", "▏", "▎", "▍", "▌", "▋", "▊", "▉", "█" }; -static void n_spaces(const unsigned int n) +static unsigned int n_spaces(const unsigned int n) { unsigned int i; for (i = 0; i < n; i++) putchar(' '); + + return n; } static void @@ -2041,14 +2043,17 @@ print_client(struct igt_drm_client *c, struct engines *engines, double t, int li len = printf("%*s ", clients->max_pid_len, c->pid_str); - for (i = 0; - c->samples > 1 && i <= iclients->classes.max_engine_id; - i++) { + for (i = 0; i <= iclients->classes.max_engine_id; i++) { double pct, max; if (!iclients->classes.capacity[i]) continue; + if (c->samples < 2) { + len += n_spaces(*class_w); + continue; + } + pct = (double)c->val[i] / period_us / 1e3 * 100; /* From patchwork Fri Sep 29 12:25:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13404193 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 25F27E71D20 for ; Fri, 29 Sep 2023 12:25:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9A79610E712; Fri, 29 Sep 2023 12:25:51 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3FFC310E700; Fri, 29 Sep 2023 12:25:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695990333; x=1727526333; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oqQtG3eFdKpNTeHhN9seKrtmb5X/ts/8KtaJB0RjSXU=; b=IvgmPZh6dZCvJVxvmM+3VsvgEf++ugAFSmtCgzJzlCICfKzlK/2Raexc pJ73N5Y1EtRayfQbIRtAQmqp0XCu1bx5z58VTNbMkMYIfu5pfsHZ10Xfl v8PwP6o6Hp9wWVaPPCPnGOEASwmpY4ACwefavnIHUacLn15kqZEEkBB/b aC2Y469iRWwZUoeZweU1rn2FzH9oJzjGa7tnFuzDhGSL+LlHjiXw8aPFM /wqH72oUK5LpXjM99Bx0pQYpvAXKA96vhEDtIxzRiyGD4nJLtMh3Pbc6G W330eFHo7U2GtNiqm3C1NQlljLGR/rwKMigqLBwEhg02jo1M+4lahX+xL A==; X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="446443772" X-IronPort-AV: E=Sophos;i="6.03,187,1694761200"; d="scan'208";a="446443772" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 05:25:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="726577154" X-IronPort-AV: E=Sophos;i="6.03,187,1694761200"; d="scan'208";a="726577154" Received: from pbrady4x-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.203.84]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 05:25:31 -0700 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Date: Fri, 29 Sep 2023 13:25:11 +0100 Message-Id: <20230929122517.349348-7-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230929122517.349348-1-tvrtko.ursulin@linux.intel.com> References: <20230929122517.349348-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 06/12] tools/intel_gpu_top: Optimise interactive display a bit X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" From: Tvrtko Ursulin Padding the percentage bars and table columns with spaces happens quite a lot so lets do better than putchar at a time. Have a table of visually empty strings and build the required length out of those chunks. While at it, also move the percentage bar table into its function scope. Signed-off-by: Tvrtko Ursulin --- tools/intel_gpu_top.c | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c index de37ff603b6f..739ed9839961 100644 --- a/tools/intel_gpu_top.c +++ b/tools/intel_gpu_top.c @@ -924,14 +924,40 @@ static void free_display_clients(struct igt_drm_clients *clients) free(clients); } -static const char *bars[] = { " ", "▏", "▎", "▍", "▌", "▋", "▊", "▉", "█" }; - static unsigned int n_spaces(const unsigned int n) { - unsigned int i; + static const char *spaces[] = { + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", +#define MAX_SPACES 19 + }; + unsigned int i, r = n; - for (i = 0; i < n; i++) - putchar(' '); + while (r) { + if (r > MAX_SPACES) + i = MAX_SPACES - 1; + else + i = r - 1; + fputs(spaces[i], stdout); + r -= i + 1; + } return n; } @@ -939,6 +965,8 @@ static unsigned int n_spaces(const unsigned int n) static void print_percentage_bar(double percent, double max, int max_len, bool numeric) { + static const char *bars[] = + { " ", "▏", "▎", "▍", "▌", "▋", "▊", "▉", "█" }; int bar_len, i, len = max_len - 2; const int w = 8; From patchwork Fri Sep 29 12:25:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13404194 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7F042E71D21 for ; Fri, 29 Sep 2023 12:25:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F3DD210E713; Fri, 29 Sep 2023 12:25:52 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7812310E708; Fri, 29 Sep 2023 12:25:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695990334; x=1727526334; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Yt46lnO79fw85Z3m8LKQvMLLP745R4hvjLbFZi57wa0=; b=MKkukp018IghU8yxaljZcvzibEov+bkmIlCM8nWFFfn0ylq6EZ22pP/J XxpVjQn5jFVhZR7lCF6y2Iz+02dFAAc67l/Z9BVt3zJqA8bYR+qKNccWD Rb3vVaeg+U+0fUFmlFxNsVSAHZH0WaZQLuyiU/AWUAN0q+p/4XHLHahj9 ZgOrJgdht/+v05UQ2TAHu+AJNA55zEfWwLCdzlnIUF2U5V39REkMdE5s2 JM084nknMB3O3U6Cx5vc5tNtnEvjszAv6Jqs841kC6z9zNtbsatoxOmVH hlNqh9tVw+oAUEl1qXBuUShTJxPjPIkk6EBLXZkFZ37st5VhBxKY1oS6W Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="446443776" X-IronPort-AV: E=Sophos;i="6.03,187,1694761200"; d="scan'208";a="446443776" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 05:25:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="726577159" X-IronPort-AV: E=Sophos;i="6.03,187,1694761200"; d="scan'208";a="726577159" Received: from pbrady4x-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.203.84]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 05:25:33 -0700 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Date: Fri, 29 Sep 2023 13:25:12 +0100 Message-Id: <20230929122517.349348-8-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230929122517.349348-1-tvrtko.ursulin@linux.intel.com> References: <20230929122517.349348-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 07/12] lib/igt_drm_fdinfo: Copy over region map name on match X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" From: Tvrtko Ursulin I will need some record of which regions were found for intel_gpu_top so lets just copy over the region name from the map on the first match. Signed-off-by: Tvrtko Ursulin --- lib/igt_drm_fdinfo.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/igt_drm_fdinfo.c b/lib/igt_drm_fdinfo.c index b72822894782..222ccbfb1fd6 100644 --- a/lib/igt_drm_fdinfo.c +++ b/lib/igt_drm_fdinfo.c @@ -148,6 +148,10 @@ static int parse_region(char *line, struct drm_client_fdinfo *info, for (i = 0; i < region_entries; i++) { if (!strncmp(name, region_map[i], name_len)) { found = i; + if (!info->region_names[info->num_regions][0]) { + assert(name_len < sizeof(info->region_names[i])); + strncpy(info->region_names[i], name, name_len); + } break; } } From patchwork Fri Sep 29 12:25:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13404199 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E89B1E71D21 for ; Fri, 29 Sep 2023 12:26:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0948610E71B; Fri, 29 Sep 2023 12:25:58 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id C23A310E70A; Fri, 29 Sep 2023 12:25:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695990335; x=1727526335; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cBaFm1ac9yKFb5jgD+NCZxo7kujT+Lwyy2+WipwqjHw=; b=DyER4VdUBVfavehptjOqzqxvhja7/KmLkR+RVpglErQRz9QY/0XX62yB SXFi5zOLBwxQd4Z3KdS7b6xW1FTQsI9jIPfhO0vZdq6OXVkGP/iGjyYD5 hG4jcNpObPlt6j1WCmf6axxZVRs3uH8YUTsmaJVAtxkN6V335g1fhIrPY a0htCniAe/BUShofx6j4JHKDZbR14cGNgaC4EjWQdJdJGIq9miqUNH9Z8 GgtInL3q+wOkyeNsbynN7YeedXm9n83UIJmmtjwQqWBZ7T+bGIH5zzDGa /ge/Pw2NMPaFwU4I/ai4/XxLAYHqoIWYIClj4ZB0n+3G5gC+0Fj9/dqts A==; X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="446443779" X-IronPort-AV: E=Sophos;i="6.03,187,1694761200"; d="scan'208";a="446443779" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 05:25:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="726577171" X-IronPort-AV: E=Sophos;i="6.03,187,1694761200"; d="scan'208";a="726577171" Received: from pbrady4x-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.203.84]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 05:25:34 -0700 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Date: Fri, 29 Sep 2023 13:25:13 +0100 Message-Id: <20230929122517.349348-9-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230929122517.349348-1-tvrtko.ursulin@linux.intel.com> References: <20230929122517.349348-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 08/12] lib/igt_drm_clients: Fix client id type confusion X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" From: Tvrtko Ursulin Igt_drm_fdinfo defines it as an unsigned long so it is best that it matches here as well. Signed-off-by: Tvrtko Ursulin --- lib/igt_drm_clients.c | 2 +- lib/igt_drm_clients.h | 2 +- tools/intel_gpu_top.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/igt_drm_clients.c b/lib/igt_drm_clients.c index 47ad137d5f1f..da51d7335b2b 100644 --- a/lib/igt_drm_clients.c +++ b/lib/igt_drm_clients.c @@ -49,7 +49,7 @@ struct igt_drm_clients *igt_drm_clients_init(void *private_data) static struct igt_drm_client * igt_drm_clients_find(struct igt_drm_clients *clients, enum igt_drm_client_status status, - unsigned int drm_minor, unsigned int id) + unsigned int drm_minor, unsigned long id) { unsigned int start, num; struct igt_drm_client *c; diff --git a/lib/igt_drm_clients.h b/lib/igt_drm_clients.h index 07bd236d43bf..cd37f8508b20 100644 --- a/lib/igt_drm_clients.h +++ b/lib/igt_drm_clients.h @@ -56,7 +56,7 @@ struct igt_drm_client { enum igt_drm_client_status status; struct igt_drm_client_regions *regions; /* Memory regions present in this client, to map with memory usage. */ struct igt_drm_client_engines *engines; /* Engines used by this client, to map with busynees data. */ - unsigned int id; /* DRM client id from fdinfo. */ + unsigned long id; /* DRM client id from fdinfo. */ unsigned int drm_minor; /* DRM minor of this client. */ unsigned int pid; /* PID which has this DRM fd open. */ char pid_str[10]; /* Cached PID representation. */ diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c index 739ed9839961..35c125f22c48 100644 --- a/tools/intel_gpu_top.c +++ b/tools/intel_gpu_top.c @@ -2102,7 +2102,7 @@ print_client(struct igt_drm_client *c, struct engines *engines, double t, int li } else if (output_mode == JSON) { char buf[64]; - snprintf(buf, sizeof(buf), "%u", c->id); + snprintf(buf, sizeof(buf), "%lu", c->id); pops->open_struct(buf); __json_add_member("name", c->print_name); From patchwork Fri Sep 29 12:25:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13404197 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A287DE71D20 for ; Fri, 29 Sep 2023 12:25:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8CC1410E719; Fri, 29 Sep 2023 12:25:54 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id E6D7F10E70C; Fri, 29 Sep 2023 12:25:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695990337; x=1727526337; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7tAx0labasHjnhMtKedAE3s87O/HYmVjGaZSj3x+WiM=; b=d58V532t8E5PrrHHJ197b7jq62UBRQbaHSrSN5Wde47W8X8YfGSxEoJa p8KZM9h7Eh1cpRtEWPFjrPaneafoX1HZkI0z1QBT4XL2Pb9mQGYKgZrg3 wbThi36d9yoI3kAvFyC/ENaPlNfcT1LdiBy5WQQ9j7v2FZgp63ZHOVxpz rYRMNPwHkjAV57KsH47R32aG3ePutWt7WdKAQfGiXI3cNAQtoMIgjGb3t uzf9gbq+265oiHMbcYozLNihAFGi+NYgh77piVcGLinobQ4fWzQ820HAf AAsAeHysCHxJgWIrQ+H7u7RrZxUow7LJPxkuHXEXq25sOy/EzXwSmrs40 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="446443780" X-IronPort-AV: E=Sophos;i="6.03,187,1694761200"; d="scan'208";a="446443780" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 05:25:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="726577177" X-IronPort-AV: E=Sophos;i="6.03,187,1694761200"; d="scan'208";a="726577177" Received: from pbrady4x-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.203.84]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 05:25:35 -0700 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Date: Fri, 29 Sep 2023 13:25:14 +0100 Message-Id: <20230929122517.349348-10-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230929122517.349348-1-tvrtko.ursulin@linux.intel.com> References: <20230929122517.349348-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 09/12] lib/igt_drm_clients: Allow passing in the memory region map X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" From: Tvrtko Ursulin Same concept as with the engine map, allowing callers to pass in fixed map of names to indices, simplifying their implementation and avoiding auto-detection while parsing. Signed-off-by: Tvrtko Ursulin --- lib/igt_drm_clients.c | 5 +++-- lib/igt_drm_clients.h | 3 ++- tools/gputop.c | 4 ++-- tools/intel_gpu_top.c | 8 +++++--- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/igt_drm_clients.c b/lib/igt_drm_clients.c index da51d7335b2b..025d60c51503 100644 --- a/lib/igt_drm_clients.c +++ b/lib/igt_drm_clients.c @@ -445,7 +445,8 @@ struct igt_drm_clients * igt_drm_clients_scan(struct igt_drm_clients *clients, bool (*filter_client)(const struct igt_drm_clients *, const struct drm_client_fdinfo *), - const char **name_map, unsigned int map_entries) + const char **name_map, unsigned int map_entries, + const char **region_map, unsigned int region_entries) { struct dirent *proc_dent; struct igt_drm_client *c; @@ -524,7 +525,7 @@ igt_drm_clients_scan(struct igt_drm_clients *clients, if (!__igt_parse_drm_fdinfo(dirfd(fdinfo_dir), fdinfo_dent->d_name, &info, name_map, map_entries, - NULL, 0)) + region_map, region_entries)) continue; if (filter_client && !filter_client(clients, &info)) diff --git a/lib/igt_drm_clients.h b/lib/igt_drm_clients.h index cd37f8508b20..52888aedc25a 100644 --- a/lib/igt_drm_clients.h +++ b/lib/igt_drm_clients.h @@ -93,7 +93,8 @@ struct igt_drm_clients * igt_drm_clients_scan(struct igt_drm_clients *clients, bool (*filter_client)(const struct igt_drm_clients *, const struct drm_client_fdinfo *), - const char **name_map, unsigned int map_entries); + const char **name_map, unsigned int map_entries, + const char **region_map, unsigned int region_entries); struct igt_drm_clients * igt_drm_clients_sort(struct igt_drm_clients *clients, diff --git a/tools/gputop.c b/tools/gputop.c index ea95e0333dd2..71e28f43ee4c 100644 --- a/tools/gputop.c +++ b/tools/gputop.c @@ -253,7 +253,7 @@ int main(int argc, char **argv) if (!clients) exit(1); - igt_drm_clients_scan(clients, NULL, NULL, 0); + igt_drm_clients_scan(clients, NULL, NULL, 0, NULL, 0); for (;;) { struct igt_drm_client *c, *prevc = NULL; @@ -270,7 +270,7 @@ int main(int argc, char **argv) } } - igt_drm_clients_scan(clients, NULL, NULL, 0); + igt_drm_clients_scan(clients, NULL, NULL, 0, NULL, 0); igt_drm_clients_sort(clients, client_cmp); printf("\033[H\033[J"); diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c index 35c125f22c48..5d44ba45335e 100644 --- a/tools/intel_gpu_top.c +++ b/tools/intel_gpu_top.c @@ -2615,8 +2615,9 @@ int main(int argc, char **argv) } pmu_sample(engines); - igt_drm_clients_scan(clients, client_match, engine_map, - ARRAY_SIZE(engine_map)); + igt_drm_clients_scan(clients, client_match, + engine_map, ARRAY_SIZE(engine_map), + NULL, 0); gettime(&ts); if (output_mode == JSON) @@ -2651,7 +2652,8 @@ int main(int argc, char **argv) display_clients(igt_drm_clients_scan(clients, client_match, engine_map, - ARRAY_SIZE(engine_map))); + ARRAY_SIZE(engine_map), + NULL, 0)); scan_us = elapsed_us(&ts, period_us); if (stop_top) From patchwork Fri Sep 29 12:25:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13404196 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 97359E71D23 for ; Fri, 29 Sep 2023 12:25:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CFC2410E717; Fri, 29 Sep 2023 12:25:53 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2AECC10E710; Fri, 29 Sep 2023 12:25:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695990338; x=1727526338; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SBlohh86QOHfY143nw7+zFyN4Bvc25Dx3drHIT9j2NQ=; b=ky2C3u8g9ahTZn70rtzSR6I6ixja5K5VZs/j9DbyhLgY2kb+A0ShQC1I ln9XqBUKdaOO/YclaJZzIqMyRfdE2SL6CMpj+yGO14Eyv6xzuglzSi2cA hI0uCCGgJemnKS5ga/hqkbOOwz9bqOldL7gZsz+29RbW7iZhO+/pR80QT bdd279SQegiI6k8z5OBB1SM4ISkjKL3kTgtz/drhaia7b7CyqtNykLhvh SJcEQMTHby7OfEKrhh51UzPH4NGjoyeebsZteNhkRCmZo4ilvaqqSS+M4 Qj+bbYEtRFYuO/tErwu/i5FuLp1iuPmKuZGZ/cF8UumyNL0ofuj4TjzOT w==; X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="446443782" X-IronPort-AV: E=Sophos;i="6.03,187,1694761200"; d="scan'208";a="446443782" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 05:25:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="726577183" X-IronPort-AV: E=Sophos;i="6.03,187,1694761200"; d="scan'208";a="726577183" Received: from pbrady4x-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.203.84]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 05:25:36 -0700 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Date: Fri, 29 Sep 2023 13:25:15 +0100 Message-Id: <20230929122517.349348-11-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230929122517.349348-1-tvrtko.ursulin@linux.intel.com> References: <20230929122517.349348-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 10/12] tools/intel_gpu_top: Fully wrap clients operations X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" From: Tvrtko Ursulin Wrap all operations on clients via the Intel specific wrappers in order to simplify upcoming work. Signed-off-by: Tvrtko Ursulin --- tools/intel_gpu_top.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c index 5d44ba45335e..4b9ef306ca8e 100644 --- a/tools/intel_gpu_top.c +++ b/tools/intel_gpu_top.c @@ -132,6 +132,7 @@ struct engines { struct intel_clients { const char *pci_slot; struct igt_drm_client_engines classes; + struct igt_drm_clients *clients; }; static struct termios termios_orig; @@ -2432,19 +2433,22 @@ intel_init_clients(struct intel_clients *iclients, iclients->classes.capacity[i] = engines->class[i].num_engines; iclients->classes.names[i] = strdup(engines->class[i].name); } + + iclients->clients = igt_drm_clients_init(iclients); } static void intel_free_clients(struct intel_clients *iclients) { + if (iclients->clients) + igt_drm_clients_free(iclients->clients); + free((void *)iclients->pci_slot); free(iclients->classes.capacity); free(iclients->classes.names); } -int main(int argc, char **argv) +static void intel_scan_clients(struct intel_clients *iclients) { - unsigned int period_us = DEFAULT_PERIOD_MS * 1000; - struct igt_drm_clients *clients = NULL; static const char *engine_map[] = { "render", "copy", @@ -2452,6 +2456,15 @@ int main(int argc, char **argv) "video-enhance", "compute", }; + + igt_drm_clients_scan(iclients->clients, client_match, + engine_map, ARRAY_SIZE(engine_map), + NULL, 0); +} + +int main(int argc, char **argv) +{ + unsigned int period_us = DEFAULT_PERIOD_MS * 1000; bool physical_engines = false; struct intel_clients iclients; int con_w = -1, con_h = -1; @@ -2609,15 +2622,11 @@ int main(int argc, char **argv) init_engine_classes(engines); - if (has_drm_fdinfo(&card)) { + if (has_drm_fdinfo(&card)) intel_init_clients(&iclients, &card, engines); - clients = igt_drm_clients_init(&iclients); - } pmu_sample(engines); - igt_drm_clients_scan(clients, client_match, - engine_map, ARRAY_SIZE(engine_map), - NULL, 0); + intel_scan_clients(&iclients); gettime(&ts); if (output_mode == JSON) @@ -2648,12 +2657,8 @@ int main(int argc, char **argv) pmu_sample(engines); t = (double)(engines->ts.cur - engines->ts.prev) / 1e9; - disp_clients = - display_clients(igt_drm_clients_scan(clients, - client_match, - engine_map, - ARRAY_SIZE(engine_map), - NULL, 0)); + intel_scan_clients(&iclients); + disp_clients = display_clients(iclients.clients); scan_us = elapsed_us(&ts, period_us); if (stop_top) @@ -2704,7 +2709,7 @@ int main(int argc, char **argv) pops->close_struct(); } - if (disp_clients != clients) + if (disp_clients != iclients.clients) free_display_clients(disp_clients); if (stop_top) @@ -2719,10 +2724,7 @@ int main(int argc, char **argv) if (output_mode == JSON) printf("]\n"); - if (clients) { - igt_drm_clients_free(clients); - intel_free_clients(&iclients); - } + intel_free_clients(&iclients); free(codename); err_pmu: From patchwork Fri Sep 29 12:25:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13404200 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C7725E71D20 for ; Fri, 29 Sep 2023 12:26:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DA28F10E71C; Fri, 29 Sep 2023 12:25:58 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6724610E70E; Fri, 29 Sep 2023 12:25:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695990339; x=1727526339; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GbBTPxT1jd/y+LasjDoqAKHcRt5iS2iPoihH1b3aj/4=; b=SrbZX3YXiDiWj+4i1hx0/8StuHBpi83crkCrVJ8MbQiJSiNXpYMCFhYO /+3eE8NA/ophZJKEyDN23l4MRAYE8jVdUQf5uIRrKeqgR4i2LWGSUSJ35 UkiZsyDrMmS9/2XuvJUEsHELTHwGkoWgMzbQN/gl8fE1BGzHI/tJjcul5 7YYDcVrCaq+n/OOZX5Y0iB/ShLnLyWBSWHN7ffVUQvxMaA7jcEZSNnGEt UT+J5eWXPzBYRQTHl2+QzsCSDmi/JDzMKdb3BKaLqOkD6jwUY6N4BB3w4 F2iiicxk9ka64IG5mA+D+pDN2jFePuu4/ESLkYJv4CnuYpxByk13Ocy3Z w==; X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="446443786" X-IronPort-AV: E=Sophos;i="6.03,187,1694761200"; d="scan'208";a="446443786" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 05:25:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="726577190" X-IronPort-AV: E=Sophos;i="6.03,187,1694761200"; d="scan'208";a="726577190" Received: from pbrady4x-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.203.84]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 05:25:38 -0700 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Date: Fri, 29 Sep 2023 13:25:16 +0100 Message-Id: <20230929122517.349348-12-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230929122517.349348-1-tvrtko.ursulin@linux.intel.com> References: <20230929122517.349348-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 11/12] tools/intel_gpu_top: Add per client memory info X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" From: Tvrtko Ursulin JSON output has the full breakdown but for now the interactive mode only shows total and resident aggregated for all memory regions. Signed-off-by: Tvrtko Ursulin --- tools/intel_gpu_top.c | 114 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 112 insertions(+), 2 deletions(-) diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c index 4b9ef306ca8e..958df42e8c20 100644 --- a/tools/intel_gpu_top.c +++ b/tools/intel_gpu_top.c @@ -133,11 +133,24 @@ struct intel_clients { const char *pci_slot; struct igt_drm_client_engines classes; struct igt_drm_clients *clients; + struct igt_drm_client_regions *regions; /* Borrowed from first client */ }; static struct termios termios_orig; static bool class_view; +/* Maps i915 fdinfo names to indices */ +static const char *memory_region_map[] = { + "system0", + "local0", +}; + +/* For JSON, 1:1 with indices above. */ +static const char *json_memory_region_names[] = { + "system", + "local", +}; + __attribute__((format(scanf,3,4))) static int igt_sysfs_scanf(int dir, const char *attr, const char *fmt, ...) { @@ -880,6 +893,9 @@ static struct igt_drm_clients *display_clients(struct igt_drm_clients *clients) ac->val = calloc(c->engines->max_engine_id + 1, sizeof(ac->val[0])); assert(ac->val); + ac->regions = c->regions; + ac->memory = calloc(c->regions->max_region_id + 1, + sizeof(ac->memory[0])); ac->samples = 1; } @@ -894,6 +910,14 @@ static struct igt_drm_clients *display_clients(struct igt_drm_clients *clients) for (i = 0; i <= c->engines->max_engine_id; i++) ac->val[i] += c->val[i]; + + for (i = 0; i <= c->regions->max_region_id; i++) { + ac->memory[i].total += c->memory[i].total; + ac->memory[i].shared += c->memory[i].shared; + ac->memory[i].resident += c->memory[i].resident; + ac->memory[i].purgeable += c->memory[i].purgeable; + ac->memory[i].active += c->memory[i].active; + } } aggregated->num_clients = num; @@ -918,8 +942,10 @@ static void free_display_clients(struct igt_drm_clients *clients) * "display" clients are not proper clients and have un-initialized * or borrowed fields which we don't want the library to try and free. */ - igt_for_each_drm_client(clients, c, tmp) + igt_for_each_drm_client(clients, c, tmp) { free(c->val); + free(c->memory); + } free(clients->client); free(clients); @@ -2012,6 +2038,9 @@ print_clients_header(struct igt_drm_clients *clients, int lines, if (lines++ >= con_h || len >= con_w) return lines; + if (iclients->regions) + len += printf(" MEM RSS "); + if (iclients->classes.num_engines) { unsigned int i; int width; @@ -2055,6 +2084,20 @@ print_clients_header(struct igt_drm_clients *clients, int lines, static bool numeric_clients; static bool filter_idle; +static int print_size(uint64_t sz) +{ + char units[] = { ' ', 'K', 'M', 'G' }; + unsigned int u; + + for (u = 0; u < ARRAY_SIZE(units) - 1; u++) { + if (sz & 1023 || sz < 1024) + break; + sz /= 1024; + } + + return printf("%7"PRIu64"%c ", sz, units[u]); +} + static int print_client(struct igt_drm_client *c, struct engines *engines, double t, int lines, int con_w, int con_h, unsigned int period_us, int *class_w) @@ -2072,6 +2115,18 @@ print_client(struct igt_drm_client *c, struct engines *engines, double t, int li len = printf("%*s ", clients->max_pid_len, c->pid_str); + if (iclients->regions) { + uint64_t sz; + + for (sz = 0, i = 0; i <= c->regions->max_region_id; i++) + sz += c->memory[i].total; + len += print_size(sz); + + for (sz = 0, i = 0; i <= c->regions->max_region_id; i++) + sz += c->memory[i].resident; + len += print_size(sz); + } + for (i = 0; i <= iclients->classes.max_engine_id; i++) { double pct, max; @@ -2111,6 +2166,42 @@ print_client(struct igt_drm_client *c, struct engines *engines, double t, int li snprintf(buf, sizeof(buf), "%u", c->pid); __json_add_member("pid", buf); + if (iclients->regions) { + pops->open_struct("memory"); + + for (i = 0; i < ARRAY_SIZE(json_memory_region_names); + i++) { + if (i > c->regions->max_region_id) + break; + + pops->open_struct(json_memory_region_names[i]); + + snprintf(buf, sizeof(buf), "%" PRIu64, + c->memory[i].total); + __json_add_member("total", buf); + + snprintf(buf, sizeof(buf), "%" PRIu64, + c->memory[i].shared); + __json_add_member("shared", buf); + + snprintf(buf, sizeof(buf), "%" PRIu64, + c->memory[i].resident); + __json_add_member("resident", buf); + + snprintf(buf, sizeof(buf), "%" PRIu64, + c->memory[i].purgeable); + __json_add_member("purgeable", buf); + + snprintf(buf, sizeof(buf), "%" PRIu64, + c->memory[i].active); + __json_add_member("active", buf); + + pops->close_struct(); + } + + pops->close_struct(); + } + if (c->samples > 1) { pops->open_struct("engine-classes"); @@ -2456,10 +2547,29 @@ static void intel_scan_clients(struct intel_clients *iclients) "video-enhance", "compute", }; + struct igt_drm_client *c; + unsigned int i; igt_drm_clients_scan(iclients->clients, client_match, engine_map, ARRAY_SIZE(engine_map), - NULL, 0); + memory_region_map, ARRAY_SIZE(memory_region_map)); + + iclients->regions = NULL; + + if (!iclients->clients) + return; + + /* + * Borrow memory region data from first client so we can use it + * when displaying stuff. All regions are the same due our client_match. + */ + igt_for_each_drm_client(iclients->clients, c, i) { + if (c->status == IGT_DRM_CLIENT_ALIVE) { + if (c->regions->num_regions) + iclients->regions = c->regions; + break; + } + } } int main(int argc, char **argv) From patchwork Fri Sep 29 12:25:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13404198 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 04999E71D22 for ; Fri, 29 Sep 2023 12:26:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0750110E71D; Fri, 29 Sep 2023 12:25:55 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9CF7010E70E; Fri, 29 Sep 2023 12:25:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695990340; x=1727526340; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jktdmJcrS+xP6X5qLzjKHJJ+ekIvcY263WUPIhVG4Ls=; b=A51b9Vm52NEBvzwjz6yLQCyeLGCZUkWafyezTUNg9mVP5Dtz120iQMb/ dBRknjiq5tCv7USSD3nAadS+PsIwOVXu4cnYVEXQws+5NKVV1qFDxbXtP oE3Wrdr9/l60RaVdqG9apsP3MnU/T7MLlFxEL0Rl7VYsgGtCJ0pYNcbwb iHYGfAgz8E3SaXWjOZ43v0FMQmX5vYErkQekAF6Zlw3Rrn2eSd3MP11Xp OUZLCw7hTDz0w+7J8MlBEfs5T77++K3XdyhuAenpock0e0g8uT/94I7Xg kGSg0cQKue0ZpZKqfsAETzIbN/jWRAaQsh1hFeIPKhU6hROvAPT9pFKya g==; X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="446443788" X-IronPort-AV: E=Sophos;i="6.03,187,1694761200"; d="scan'208";a="446443788" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 05:25:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="726577196" X-IronPort-AV: E=Sophos;i="6.03,187,1694761200"; d="scan'208";a="726577196" Received: from pbrady4x-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.203.84]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 05:25:39 -0700 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Date: Fri, 29 Sep 2023 13:25:17 +0100 Message-Id: <20230929122517.349348-13-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230929122517.349348-1-tvrtko.ursulin@linux.intel.com> References: <20230929122517.349348-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 12/12] tools/intel_gpu_top: Add ability to show memory region breakdown X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" From: Tvrtko Ursulin Similar as we can toggle between aggregated engines and clients, add the capability to toggle between aggregated and per memory region stats. It starts in aggregated mode by default and interactive command 'm' and command line switch '-m' can be used to toggle that. Both only affect the interactive view, while JSON output always contains separate memory regions. Signed-off-by: Tvrtko Ursulin --- man/intel_gpu_top.rst | 4 ++++ tools/intel_gpu_top.c | 56 +++++++++++++++++++++++++++++++++---------- 2 files changed, 48 insertions(+), 12 deletions(-) diff --git a/man/intel_gpu_top.rst b/man/intel_gpu_top.rst index 9499f87f1b4d..44a54a5f219d 100644 --- a/man/intel_gpu_top.rst +++ b/man/intel_gpu_top.rst @@ -55,6 +55,9 @@ OPTIONS -p Default to showing physical engines instead of aggregated classes. +-m + Default to showing all memory regions separately. + RUNTIME CONTROL =============== @@ -68,6 +71,7 @@ Supported keys: | 's' Toggle between sort modes (runtime, total runtime, pid, client id). | 'i' Toggle display of clients which used no GPU time. | 'H' Toggle between per PID aggregation and individual clients. +| 'm' Toggle between aggregated memory regions and full breakdown. DEVICE SELECTION ================ diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c index 958df42e8c20..3f376e233fe2 100644 --- a/tools/intel_gpu_top.c +++ b/tools/intel_gpu_top.c @@ -138,6 +138,7 @@ struct intel_clients { static struct termios termios_orig; static bool class_view; +static bool aggregate_regions; /* Maps i915 fdinfo names to indices */ static const char *memory_region_map[] = { @@ -1045,6 +1046,7 @@ usage(const char *appname) "\t[-L] List all cards.\n" "\t[-d ] Device filter, please check manual page for more details.\n" "\t[-p] Default to showing physical engines instead of classes.\n" + "\t[-m] Default to showing all memory regions.\n" "\n", appname, DEFAULT_PERIOD_MS); igt_device_print_filter_types(); @@ -2026,7 +2028,7 @@ print_clients_header(struct igt_drm_clients *clients, int lines, 4 : clients->max_name_len; /* At least "NAME" */ if (output_mode == INTERACTIVE) { - unsigned int num_active = 0; + unsigned int num_active = 0, i; int len; if (lines++ >= con_h) @@ -2038,11 +2040,17 @@ print_clients_header(struct igt_drm_clients *clients, int lines, if (lines++ >= con_h || len >= con_w) return lines; - if (iclients->regions) - len += printf(" MEM RSS "); + if (iclients->regions) { + if (aggregate_regions) { + len += printf(" MEM RSS "); + } else { + len += printf(" RAM RSS "); + if (iclients->regions->num_regions > 1) + len += printf(" VRAM VRSS "); + } + } if (iclients->classes.num_engines) { - unsigned int i; int width; for (i = 0; i <= iclients->classes.max_engine_id; i++) { @@ -2116,15 +2124,26 @@ print_client(struct igt_drm_client *c, struct engines *engines, double t, int li len = printf("%*s ", clients->max_pid_len, c->pid_str); if (iclients->regions) { - uint64_t sz; + if (aggregate_regions) { + uint64_t sz; - for (sz = 0, i = 0; i <= c->regions->max_region_id; i++) - sz += c->memory[i].total; - len += print_size(sz); + for (sz = 0, i = 0; + i <= c->regions->max_region_id; i++) + sz += c->memory[i].total; + len += print_size(sz); - for (sz = 0, i = 0; i <= c->regions->max_region_id; i++) - sz += c->memory[i].resident; - len += print_size(sz); + for (sz = 0, i = 0; + i <= c->regions->max_region_id; i++) + sz += c->memory[i].resident; + len += print_size(sz); + } else { + len += print_size(c->memory[0].total); + len += print_size(c->memory[0].resident); + if (c->regions->num_regions > 1) { + len += print_size(c->memory[1].total); + len += print_size(c->memory[1].resident); + } + } } for (i = 0; i <= iclients->classes.max_engine_id; i++) { @@ -2401,6 +2420,13 @@ static void process_normal_stdin(void) else header_msg = "Showing individual clients."; break; + case 'm': + aggregate_regions ^= true; + if (aggregate_regions) + header_msg = "Aggregating memory regions."; + else + header_msg = "Showing memory regions."; + break; }; } } @@ -2449,6 +2475,7 @@ static void show_help_screen(void) " 's' Toggle between sort modes (runtime, total runtime, pid, client id).\n" " 'i' Toggle display of clients which used no GPU time.\n" " 'H' Toggle between per PID aggregation and individual clients.\n" +" 'm' Toggle between aggregated memory regions and full breakdown.\n" "\n" " 'h' or 'q' Exit interactive help.\n" "\n"); @@ -2576,6 +2603,7 @@ int main(int argc, char **argv) { unsigned int period_us = DEFAULT_PERIOD_MS * 1000; bool physical_engines = false; + bool separate_regions = false; struct intel_clients iclients; int con_w = -1, con_h = -1; char *output_path = NULL; @@ -2588,7 +2616,7 @@ int main(int argc, char **argv) struct timespec ts; /* Parse options */ - while ((ch = getopt(argc, argv, "o:s:d:pcJLlh")) != -1) { + while ((ch = getopt(argc, argv, "o:s:d:mpcJLlh")) != -1) { switch (ch) { case 'o': output_path = optarg; @@ -2602,6 +2630,9 @@ int main(int argc, char **argv) case 'p': physical_engines = true; break; + case 'm': + separate_regions = true; + break; case 'c': output_mode = CSV; break; @@ -2645,6 +2676,7 @@ int main(int argc, char **argv) fprintf(stderr, "Failed to install signal handler!\n"); class_view = !physical_engines; + aggregate_regions = !separate_regions; switch (output_mode) { case INTERACTIVE: