From patchwork Fri Sep 22 13:44:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13395803 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 B0AC1E6FE32 for ; Fri, 22 Sep 2023 13:44:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E211410E66D; Fri, 22 Sep 2023 13:44:52 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id B5D0610E192; Fri, 22 Sep 2023 13:44:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695390285; x=1726926285; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=N90svU8/+EDmL4BDCuEXsesNgibQ3RFAYJlT34EqpXQ=; b=TJ1iaaK3I0V4bWtjL1YlMe23Rpcy5c9dGPZ4n4wHJ+rT15IuXVbXcLiX bYHRsSAHnXyuzGXUrS1qwyUP26u17HJ0/3DDv+IB6DrPZrk2XN0vgofTY i73In+4ACBbBNNvLTBsRY2W63xSYanKGPIUPayh7ZvIWHh4sNfaO13hla 4izi2c4IKlgV9LEUb+0zVzPfZCavx4xLz+wrcEOWhBqKzozy9k1p5i0ks BYW34OIfX4zSvzFxkhQ5Niqq2iZjFMf2io57V6nbdvziRG5QYhMfSZ557 A7G1mhDLtXIWOdySZJlti5wFhpsG7OQnT+NMbnQGj/E0SlOsYty0Sg6fP w==; X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="378117128" X-IronPort-AV: E=Sophos;i="6.03,167,1694761200"; d="scan'208";a="378117128" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2023 06:44:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="871243535" X-IronPort-AV: E=Sophos;i="6.03,167,1694761200"; d="scan'208";a="871243535" Received: from placki-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.200.149]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2023 06:44:44 -0700 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Date: Fri, 22 Sep 2023 14:44:26 +0100 Message-Id: <20230922134437.234888-2-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230922134437.234888-1-tvrtko.ursulin@linux.intel.com> References: <20230922134437.234888-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 01/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 aca19db50680..a9910900358d 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) @@ -847,6 +902,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 22 13:44:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13395804 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 1070EE6FE2F for ; Fri, 22 Sep 2023 13:44:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 17BB410E66B; Fri, 22 Sep 2023 13:44:55 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9030410E66B; Fri, 22 Sep 2023 13:44:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695390287; x=1726926287; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=I8249JXAqv/kV3PYHEo/h4SylRn5+WSxIu3nF5FwMKA=; b=m/FdAR8h7t2W+gA4/S4YO4pPZbA0h/19QeAIzf7Zy0sTxwZnmg08T46Y bdKQwn1gBdwdedaHchXWcH+x62v4at6md7+tTjEiiw1cbL8QzT0JBW3sF GLUBUqC+SLT8sMwnMu0Asb4o+fKKHylPLKBix8iPmCo9c8inbCpQtJJeQ 84KGWT0ds9fDuBguFDZgMpZEmvcTXmQuCfgQiynm6rIlG5ske7giEZSYK gL1UIaDdcRwG3jxo2pQQhU2f1YKpbRFL88ZwwFw6QFMY6vAM0e0eyAb9C waJrCP23ghCiOxefnbrhgyGurCJ0+4fHI2rRhcLWlqElL1u6R3PtB6tJf Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="378117133" X-IronPort-AV: E=Sophos;i="6.03,167,1694761200"; d="scan'208";a="378117133" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2023 06:44:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="871243550" X-IronPort-AV: E=Sophos;i="6.03,167,1694761200"; d="scan'208";a="871243550" Received: from placki-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.200.149]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2023 06:44:45 -0700 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Date: Fri, 22 Sep 2023 14:44:27 +0100 Message-Id: <20230922134437.234888-3-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230922134437.234888-1-tvrtko.ursulin@linux.intel.com> References: <20230922134437.234888-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 02/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 | 201 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 201 insertions(+) diff --git a/tests/intel/drm_fdinfo.c b/tests/intel/drm_fdinfo.c index a9910900358d..8e0d04bde62b 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,156 @@ 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; +} + +#define fdinfo_assert(cond, d, sz, total) \ + igt_assert_f(cond, "\ndelta=%"PRIu64" sz=%"PRIu64" total=%"PRIu64"\n%s\n", d, sz, total, fdinfo_buf) + +static void +test_memory(int i915, struct gem_memory_region *r, unsigned int flags) +{ + struct drm_client_fdinfo prev_info = { }; + struct drm_client_fdinfo info = { }; + const uint64_t max_mem = 512ull * 1024 * 1024; + const uint64_t max_bo = 16ull * 1024 * 1024; + uint64_t total = 0, sz, d; + char buf[64], fdinfo_buf[4096]; + igt_spin_t *spin = NULL; + int ret, dir; + + i915 = drm_reopen_driver(i915); + + 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)); + + while (total < max_mem) { + static const char *region_map[] = { + "system0", + "local0", + }; + uint32_t bo; + int j; + + /* Align to 1MiB to work around drm_print_memory_stats */ + sz = 1ull * 1024 * 1024 + random() % (max_bo - 1ull * 1024 * 1024); + sz &= ~((1ull * 1024 * 1024) - 1); + ret = __gem_create_in_memory_region_list(i915, &bo, &sz, 0, &r->ci, 1); + igt_assert_eq(ret, 0); + total += sz; + + if (flags & (TEST_RESIDENT | TEST_PURGEABLE)) { + struct drm_i915_gem_exec_object2 obj[2]; + struct drm_i915_gem_execbuffer2 eb = { + .buffers_ptr = to_user_pointer(obj), + .buffer_count = 2, + }; + const uint32_t bbe = MI_BATCH_BUFFER_END; + + obj[0].handle = bo; + obj[1].handle = gem_create(i915, 4096); + gem_write(i915, obj[1].handle, 0, &bbe, sizeof(bbe)); + gem_execbuf(i915, &eb); + gem_sync(i915, obj[1].handle); + gem_close(i915, obj[1].handle); + } + + if (flags & TEST_PURGEABLE) + gem_madvise(i915, bo, I915_MADV_DONTNEED); + + 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); + } + + if (flags & TEST_ACTIVE) + spin = igt_spin_new(i915, .dependency = bo); + + 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); + + /* See region map */ + j = r->ci.memory_class == I915_MEMORY_CLASS_SYSTEM ? 0 : 1; + + fdinfo_assert(info.region_mem[j].total > prev_info.region_mem[j].total, d, sz, total); + + d = info.region_mem[j].total - prev_info.region_mem[j].total; + /* >= to account for objects out of our control */ + fdinfo_assert(d >= sz, d, sz, total); + + d = info.region_mem[j].resident - prev_info.region_mem[j].resident; + if (flags & (TEST_RESIDENT | TEST_PURGEABLE | TEST_ACTIVE)) + fdinfo_assert(d >= sz, d, sz, total); + else + fdinfo_assert(d < sz, d, sz, total); + + d = info.region_mem[j].shared - prev_info.region_mem[j].shared; + if (flags & TEST_SHARED) + fdinfo_assert(d >= sz, d, sz, total); + else + fdinfo_assert(d == 0, d, sz, total); + + d = info.region_mem[j].purgeable - prev_info.region_mem[j].purgeable; + if (flags & TEST_PURGEABLE) + fdinfo_assert(d >= sz, d, sz, total); + else + fdinfo_assert(d < sz, d, sz, total); + + /* Active is one at a time so can't use delta */ + if (flags & TEST_ACTIVE) + fdinfo_assert(info.region_mem[j].active >= sz, d, sz, total); + else + fdinfo_assert(info.region_mem[j].active < sz, d, sz, total); + + memcpy(&prev_info, &info, sizeof(info)); + + if (flags & TEST_ACTIVE) { + igt_spin_free(i915, spin); + gem_quiescent_gpu(i915); + } + } + + 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) @@ -902,6 +1068,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 22 13:44:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13395805 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 37648E6FE32 for ; Fri, 22 Sep 2023 13:45:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D6A4A10E696; Fri, 22 Sep 2023 13:45:12 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7892B10E66C; Fri, 22 Sep 2023 13:44:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695390288; x=1726926288; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=amYHoNFok9nHYNtkc2sVU2CV+dAKQhf+XkDxwv1v6GI=; b=XM4jxK6dyMmkSHfTmme1aIk3VNog0rOvRkkH9VZCy2CfuqS+Wul+dAbn 9mr6QbTFV08Ww1tJW4GSSoJJowpc5Me9lvT7lUTroroGSTSUsbTwZnJ0J J34wa7nLkC3krHqMqFE/To+v6L6q44mI40dXJISP/q4xwPSbVwSDpTcKg hLsuPD1+ITzsQex/syorZccgXjJ8VYKxaXfoGyLKQB8gAdqtq2xMLYwBr fN9725j9wCKnhCU8BGoIbFVy5nu4TYhV/R7U5KdEzbX3gvxplPxKj+bXJ LOpc2uKcg82pZ5LFUBjONB/7yevXaoYTH2Ngg5hNT54WAsRjET+4KFFht A==; X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="378117136" X-IronPort-AV: E=Sophos;i="6.03,167,1694761200"; d="scan'208";a="378117136" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2023 06:44:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="871243557" X-IronPort-AV: E=Sophos;i="6.03,167,1694761200"; d="scan'208";a="871243557" Received: from placki-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.200.149]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2023 06:44:46 -0700 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Date: Fri, 22 Sep 2023 14:44:28 +0100 Message-Id: <20230922134437.234888-4-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230922134437.234888-1-tvrtko.ursulin@linux.intel.com> References: <20230922134437.234888-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 03/12] tools/intel_gpu_top: Restore user friendly error message 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 We have a nice error message displayed when an user with insufficient permissions tries to run the tool, but that got lost while Meteorlake support was added. Bring it back in. Signed-off-by: Tvrtko Ursulin Cc: Umesh Nerlige Ramappa --- tools/intel_gpu_top.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c index 87e9681e53b4..e01355f90458 100644 --- a/tools/intel_gpu_top.c +++ b/tools/intel_gpu_top.c @@ -554,9 +554,11 @@ static int get_num_gts(uint64_t type) close(fd); } - assert(!errno || errno == ENOENT); - assert(cnt > 0); - errno = 0; + + if (!cnt) + cnt = errno; + else + errno = 0; return cnt; } @@ -590,6 +592,8 @@ static int pmu_init(struct engines *engines) engines->fd = -1; engines->num_counters = 0; engines->num_gts = get_num_gts(type); + if (engines->num_gts <= 0) + return -1; engines->irq.config = I915_PMU_INTERRUPTS; fd = _open_pmu(type, engines->num_counters, &engines->irq, engines->fd); From patchwork Fri Sep 22 13:44:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13395806 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 DB737E6FE32 for ; Fri, 22 Sep 2023 13:45:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9B35C10E66C; Fri, 22 Sep 2023 13:45:43 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id C7EA010E66D; Fri, 22 Sep 2023 13:44:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695390289; x=1726926289; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EVMxRqjB9gaHRMSHsxPm1b+2XFN8n7tU7dm8akjKYKs=; b=LITM5u90oJ5BLgypNpoX6lOIisUZFYB6u2gynSp90Q7Sc20r0dD59lsD DCSpNUaXHSf2e1C7fJeRZ3mShmYLb6XSA2pkM8RynaWUy9qe68UkKw6Eq 8qhFeNsCJBxsgI27XyvR8qMhSyN8bSF6mAJ7UxND+4PJleDX9OS6QaFdz kvJ7CiqWp/a1IRYDSF9FijLKEXTOeMojlMzwC3G7gQsCg81RIF6l57vIQ S9reAiWfOpFWyqJFuKWD03NFCeDgyVieNkr3bV66BfVLNs3rS+rc2wRSZ Q4Sl3Athag6NAq61nyjqbSDqxsa5vzExEQLt7a44mTeDgGacegmWtSWcQ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="378117139" X-IronPort-AV: E=Sophos;i="6.03,167,1694761200"; d="scan'208";a="378117139" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2023 06:44:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="871243568" X-IronPort-AV: E=Sophos;i="6.03,167,1694761200"; d="scan'208";a="871243568" Received: from placki-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.200.149]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2023 06:44:48 -0700 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Date: Fri, 22 Sep 2023 14:44:29 +0100 Message-Id: <20230922134437.234888-5-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230922134437.234888-1-tvrtko.ursulin@linux.intel.com> References: <20230922134437.234888-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 e01355f90458..76956619eaae 100644 --- a/tools/intel_gpu_top.c +++ b/tools/intel_gpu_top.c @@ -1969,6 +1969,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; @@ -1992,9 +1994,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 22 13:44:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13395807 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 EE005E6FE32 for ; Fri, 22 Sep 2023 13:45:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4667610E66D; Fri, 22 Sep 2023 13:45:56 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2E3F110E66B; Fri, 22 Sep 2023 13:44:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695390291; x=1726926291; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=n2K9IrbXdRiICRY6FYfzQGK165O4mFQTgTDnPLiqswM=; b=BaAgAxsVMyr24gsf5ow2Z+91nbK0W5MOfQj/yoVNXs/D5UsJW+dWeObt MChdSWe/KQ/qkC7UZIbu1JlQUogpReyCKufMf8zl03vRooSYeIECXVdcK FTzEMkwB/nyCQIMtUF2gHFcJTdkwGMQotrSFl30dXxvpPGp9STyCT8x6+ YvI20ODeNTKOMTocv6vRYHv7DKygH0RXXNMa/lGpkGm7A2cIL/iEngEBl P2KT6Me1esFp/u5CurO4ydLF4eBRV1bQnKXkll5KV9cP7Itiky0bT2of7 PmmWw1Rez7dyXyNg5MAg+fGBZ858MkuDmGJPMDfCwcIErcABaSQNJLLq2 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="378117141" X-IronPort-AV: E=Sophos;i="6.03,167,1694761200"; d="scan'208";a="378117141" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2023 06:44:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="871243575" X-IronPort-AV: E=Sophos;i="6.03,167,1694761200"; d="scan'208";a="871243575" Received: from placki-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.200.149]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2023 06:44:49 -0700 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Date: Fri, 22 Sep 2023 14:44:30 +0100 Message-Id: <20230922134437.234888-6-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230922134437.234888-1-tvrtko.ursulin@linux.intel.com> References: <20230922134437.234888-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 76956619eaae..6363f460c892 100644 --- a/tools/intel_gpu_top.c +++ b/tools/intel_gpu_top.c @@ -930,12 +930,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 @@ -2045,14 +2047,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 22 13:44:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13395810 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 B017BE6FE32 for ; Fri, 22 Sep 2023 13:46:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A23C110E66E; Fri, 22 Sep 2023 13:46:02 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id F273E10E674; Fri, 22 Sep 2023 13:45:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695390338; x=1726926338; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Sr43CvzG/k974mK43Pj+WtTVAi0698tnjW5IM1nJZgg=; b=fS6YWuFIxsM4ulD7dC/YDkREFQ4StnL6Vy3jN0hKiFiDYpRJp2K10tZt pclNxVd4JGzpgRXBG9gijSu0ISZgxv50trkIKb9qoRNa5lkXQ84C0XeC5 lwXbLkJm/gHFGOJ+KOJSxbmWj9qe+8xBunXcNiorxeNJy+bQD6FuYzKzo NbTpNjRJZIdeONOWITfDgVyb19FLglfpEB9RGNQ+268VQCJhAPKgtFY3Q woZ+bHDKybD0YXaKxizuS1rf14Z7mOWUULuEvjQkOed5gChGTSjtevv3l huUwS7IbrfQDzQ+GIsDlDkpHXm4QueVPI/bSn2kGuLDa89WtP+tC9c9wF g==; X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="378117145" X-IronPort-AV: E=Sophos;i="6.03,167,1694761200"; d="scan'208";a="378117145" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2023 06:44:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="871243586" X-IronPort-AV: E=Sophos;i="6.03,167,1694761200"; d="scan'208";a="871243586" Received: from placki-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.200.149]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2023 06:44:50 -0700 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Date: Fri, 22 Sep 2023 14:44:31 +0100 Message-Id: <20230922134437.234888-7-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230922134437.234888-1-tvrtko.ursulin@linux.intel.com> References: <20230922134437.234888-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 6363f460c892..a7a24e527f01 100644 --- a/tools/intel_gpu_top.c +++ b/tools/intel_gpu_top.c @@ -928,14 +928,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; } @@ -943,6 +969,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 22 13:44:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13395808 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 6E2D0E6FE32 for ; Fri, 22 Sep 2023 13:46:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4705610E192; Fri, 22 Sep 2023 13:46:00 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id F381010E676; Fri, 22 Sep 2023 13:45:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695390338; x=1726926338; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Yt46lnO79fw85Z3m8LKQvMLLP745R4hvjLbFZi57wa0=; b=BNGTQEy1402pkOuWozSalVNweb2EJX/8Q71pxtq0xEJ7VG1cBMY7cDlX K5yO7ME7O9ejt6gmxGXnmsQqcWxWyrmokbSOzb9Yye7guaFL0GYDa+5jE Yvq5CeGdQQjwgkgUdsb/jTWTPbwXcJLSI0mGPCK8Gfr9X7blrXYiR+1w/ +vqw7UGHgOYxR2H83vq8GKvdDigeA0BDQDc4tA9pJAGv9sbMBeNtQPsHW SRIJkneU/9RjKFp7y4sWL1hY9rOuJH/8Rbr5yY1RKQ/jM2zJjxWZytWB/ ortbxQECLq1d4Pa5gkSmbn5FOB4U1a9HixQN6nOQxlsZPMKqUw22DMdDs Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="378117149" X-IronPort-AV: E=Sophos;i="6.03,167,1694761200"; d="scan'208";a="378117149" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2023 06:44:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="871243598" X-IronPort-AV: E=Sophos;i="6.03,167,1694761200"; d="scan'208";a="871243598" Received: from placki-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.200.149]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2023 06:44:52 -0700 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Date: Fri, 22 Sep 2023 14:44:32 +0100 Message-Id: <20230922134437.234888-8-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230922134437.234888-1-tvrtko.ursulin@linux.intel.com> References: <20230922134437.234888-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 22 13:44:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13395811 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 BE0CDE6FE33 for ; Fri, 22 Sep 2023 13:46:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F3C8610E671; Fri, 22 Sep 2023 13:46:03 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id F304C10E675; Fri, 22 Sep 2023 13:45:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695390338; x=1726926338; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ODuRqiCEYhg8FjXO8Q7WnDSgkg8CIzYwYZaG7QoCb8o=; b=AgrkWe4DN/wOOM5bXzCbKr6UQdeBk8AFgCt9U98VKuXIbxwuyyzbfJns lA5EpPZxh2eNFeXppuiDSzIqOw0YL/0pLbmbZnBrgc27LgLC/+DVo5K5G fwiixh90RUfk6RY3AvYrZvX9H6OlFV/sk3Dy5OrL0NopAkYT2j6XSiTLS xfJw+6c2gT02bAZijh4xUE6z/3ambiSp/5b2SQZwacOR8H3dM9ZqBeWdT wqWVj6i0V3fhXTiD1cgQjUhLi0ugdkjfR3et/a6tFUhloXvvFcPa6EhNh zMvBW9lQjA1nBs3T2H1LRKGUjFJh7ZNaFcFMds5Tvz80q879tV+0jLx+N A==; X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="378117154" X-IronPort-AV: E=Sophos;i="6.03,167,1694761200"; d="scan'208";a="378117154" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2023 06:44:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="871243606" X-IronPort-AV: E=Sophos;i="6.03,167,1694761200"; d="scan'208";a="871243606" Received: from placki-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.200.149]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2023 06:44:53 -0700 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Date: Fri, 22 Sep 2023 14:44:33 +0100 Message-Id: <20230922134437.234888-9-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230922134437.234888-1-tvrtko.ursulin@linux.intel.com> References: <20230922134437.234888-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 a7a24e527f01..e18ec25e8036 100644 --- a/tools/intel_gpu_top.c +++ b/tools/intel_gpu_top.c @@ -2106,7 +2106,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 22 13:44:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13395809 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 BBAF3E6FE34 for ; Fri, 22 Sep 2023 13:46:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B106A10E66B; Fri, 22 Sep 2023 13:46:01 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 187CC10E669; Fri, 22 Sep 2023 13:45:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695390341; x=1726926341; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ypMid9qz8w3EISgLqRrSIozWij9gpQmaY7umHfWSeKo=; b=gRobfyjlwf9Fh6GNUuupGrRODB9TyqloSkPamZouGjTKQM0eJZVCEYbj mPXuJjjCcA1g9+InIKFwnVrkqtcGjdj82AMGmosHHZgmE8cD66eupgTUz BzkUgH1/DodXauvJxc5xahAl2vUeLstWZawf2ttB/aR6idOGseTc2szvF Kl0WONHRDRObwNVgdDJFBc80X3RsVY9Fh7yE3dsLddH+7szgV1WtgMRqa Bokvb/TAwoHBrZg5lgTBXAmiQbOzfVmsn9k/ubt0T3lcL/KpAJMtR3Amp cKpXftJUSQgJ3i4Au00MX5Mhh6NZmAD5H1Rx2fIOiyDc43RRAfCtBrITH A==; X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="378117156" X-IronPort-AV: E=Sophos;i="6.03,167,1694761200"; d="scan'208";a="378117156" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2023 06:44:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="871243614" X-IronPort-AV: E=Sophos;i="6.03,167,1694761200"; d="scan'208";a="871243614" Received: from placki-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.200.149]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2023 06:44:55 -0700 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Date: Fri, 22 Sep 2023 14:44:34 +0100 Message-Id: <20230922134437.234888-10-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230922134437.234888-1-tvrtko.ursulin@linux.intel.com> References: <20230922134437.234888-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 e18ec25e8036..eb0ef00abeaf 100644 --- a/tools/intel_gpu_top.c +++ b/tools/intel_gpu_top.c @@ -2619,8 +2619,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) @@ -2655,7 +2656,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 22 13:44:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13395812 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 3FCB9E6FE2F for ; Fri, 22 Sep 2023 13:46:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A242E10E673; Fri, 22 Sep 2023 13:46:06 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 19B8510E66B; Fri, 22 Sep 2023 13:45:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695390341; x=1726926341; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=adCZNLUCZ7uY5BPeOIFOoCuGXlax+PNTuajWcjCuRhg=; b=Ptf6g8asnHFS3JWnzKfVixsWz9246f0AF6lYG1aEj3dHt0fLYbGo4Bys WPuIR8Z7S4ZAVvR1AjFkUyYj3pfdrVPAqrCxHiWADs5mvjBT3pF0Y+d/O S5BxxH7xGncjn8xeBWVPgf8SWGO73N74mb6e548vCnLI3ydJVLdDsAdTr 31Gu/5LpBT+jdTs80w6pGtSLDtGQLU3IIGo0FI3ebQuszmlm/zTlZ2zEP 2MF1EyP4qmOeyVBh8zrux6gbQbvhA9T0oL18chyhODBd3lG4T9wHgYQ/a 7QEMRNQfmRnkTqAaiem5qGWpD5alP622Imk+skLRzdVnCkUe55aPP3fax Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="378117159" X-IronPort-AV: E=Sophos;i="6.03,167,1694761200"; d="scan'208";a="378117159" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2023 06:44:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="871243620" X-IronPort-AV: E=Sophos;i="6.03,167,1694761200"; d="scan'208";a="871243620" Received: from placki-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.200.149]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2023 06:44:56 -0700 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Date: Fri, 22 Sep 2023 14:44:35 +0100 Message-Id: <20230922134437.234888-11-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230922134437.234888-1-tvrtko.ursulin@linux.intel.com> References: <20230922134437.234888-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 eb0ef00abeaf..27503ac03ebd 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; @@ -2436,19 +2437,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", @@ -2456,6 +2460,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; @@ -2613,15 +2626,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) @@ -2652,12 +2661,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) @@ -2708,7 +2713,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) @@ -2723,10 +2728,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 22 13:44:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13395814 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 95305E6FE33 for ; Fri, 22 Sep 2023 13:46:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 40F7310E678; Fri, 22 Sep 2023 13:46:27 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1705B10E192; Fri, 22 Sep 2023 13:45:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695390341; x=1726926341; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=n+EnFC8AWmNcXHW2jMhVhlk71dYyN9VYXI4CLNN9rqg=; b=A+EA9HJSz1t6OMNB2Hi/1xkIaCEpsILoFom01tB3JSPjFO/tcYGY19Jo TJmJeIx5Bhupd4slE2CIfAAOdWrusMPv+4r67zozHCubWILVKLrst2VMD ybWHhZqk+UHD8FyF03UXFAWpaIGoxEUAW7Yf5iKxvpQrjBV/0VQRSQ85Z 5bj9b1Q+4rNN74BuBvPnT3F3Mnac5v822M27eYzVSXJD8Oh2jVvcRpVJ0 jNx9tfDAxrfC9CliejoTV48it5j4tkzB+nfilA0/mB0dSkmdGJwnzFpoO ESic2yP5yQczol6cxkFkQ3fYv2PFshbtJKw+j4kMLDASTGsps3AvEdmQ4 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="378117167" X-IronPort-AV: E=Sophos;i="6.03,167,1694761200"; d="scan'208";a="378117167" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2023 06:44:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="871243633" X-IronPort-AV: E=Sophos;i="6.03,167,1694761200"; d="scan'208";a="871243633" Received: from placki-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.200.149]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2023 06:44:57 -0700 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Date: Fri, 22 Sep 2023 14:44:36 +0100 Message-Id: <20230922134437.234888-12-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230922134437.234888-1-tvrtko.ursulin@linux.intel.com> References: <20230922134437.234888-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 27503ac03ebd..c239a0d4f350 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, ...) { @@ -884,6 +897,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; } @@ -898,6 +914,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; @@ -922,8 +946,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); @@ -2016,6 +2042,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; @@ -2059,6 +2088,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) @@ -2076,6 +2119,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; @@ -2115,6 +2170,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"); @@ -2460,10 +2551,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 22 13:44:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13395813 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 E670DE6FE32 for ; Fri, 22 Sep 2023 13:46:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ECD9010E675; Fri, 22 Sep 2023 13:46:06 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id A445110E66E; Fri, 22 Sep 2023 13:45:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695390350; x=1726926350; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oM5KgvS3/rVcQWKHqWRfHGdi4keXyO+LXS7MrBqu9z4=; b=hatpE4OR5i8nbWVYX8n/9g1ZWgF95zzQGeKRSQwe6lJmbMYjWozjbNP0 +yEGeD/XPT2e8B8Msov9mvgXeR826oaufYhRdUl0t7ppYY4QtZEHy3mAt g6j1iEmhxW1nqjSLTX9OeEv4pdah6JnNdXDmWONhYj/XkBxYfZ0agal00 cwUWxY8DJK7QgrJdARjsKb3eqUg29K+LP6dgoO5RS04ap0NZOCmJY8T7x aDJkr4zTMgBLhgk32zCVXNqDh/mj6e78L8fv+TJltQu4EfGjjv17HpWUf j5dwBpnZKF+X1cH5rXhGD6nQqGTB9oUwHpg6FOsKE8AximgjxM/96qWWF g==; X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="378117179" X-IronPort-AV: E=Sophos;i="6.03,167,1694761200"; d="scan'208";a="378117179" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2023 06:45:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="871243646" X-IronPort-AV: E=Sophos;i="6.03,167,1694761200"; d="scan'208";a="871243646" Received: from placki-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.200.149]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2023 06:44:59 -0700 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Date: Fri, 22 Sep 2023 14:44:37 +0100 Message-Id: <20230922134437.234888-13-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230922134437.234888-1-tvrtko.ursulin@linux.intel.com> References: <20230922134437.234888-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 c239a0d4f350..3b45fcc21331 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[] = { @@ -1049,6 +1050,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(); @@ -2030,7 +2032,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) @@ -2042,11 +2044,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++) { @@ -2120,15 +2128,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++) { @@ -2405,6 +2424,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; }; } } @@ -2453,6 +2479,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"); @@ -2580,6 +2607,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; @@ -2592,7 +2620,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; @@ -2606,6 +2634,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; @@ -2649,6 +2680,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: